[3] | 1 | ################################################################################
|
---|
| 2 | #
|
---|
| 3 | # CMake script for finding Log4cxx.
|
---|
| 4 | # The default CMake search process is used to locate files.
|
---|
| 5 | #
|
---|
| 6 | # This script creates the following variables:
|
---|
| 7 | # LOG4CXX_FOUND: Boolean that indicates if the package was found
|
---|
| 8 | # LOG4CXX_INCLUDE_DIRS: Paths to the necessary header files
|
---|
| 9 | # LOG4CXX_LIBRARIES: Package libraries
|
---|
| 10 | # LOG4CXX_LIBRARY_DIRS: Path to package libraries
|
---|
| 11 | #
|
---|
| 12 | ################################################################################
|
---|
| 13 |
|
---|
[50] | 14 | include(FindPackageHandleStandardArgs)
|
---|
[3] | 15 |
|
---|
[91] | 16 | # For Windows, when building Pacpus use the local log4cxx files, else use the log4cxx files in the pacpus install dir
|
---|
| 17 | if(WIN32)
|
---|
| 18 | if(IS_BUILDING_PACPUS)
|
---|
| 19 | SET(LOG4CXX_ROOT "3rd/apache-log4cxx")
|
---|
| 20 | elseif(PACPUS_ROOT)
|
---|
| 21 | SET(LOG4CXX_ROOT "${PACPUS_ROOT}/3rd/apache-log4cxx")
|
---|
| 22 | else()
|
---|
| 23 | SET(LOG4CXX_ROOT "$ENV{PACPUS_ROOT}/3rd/apache-log4cxx")
|
---|
| 24 | endif()
|
---|
[50] | 25 | endif()
|
---|
[3] | 26 |
|
---|
[91] | 27 |
|
---|
| 28 |
|
---|
[50] | 29 | set(LOG4CXX_INC_LIST
|
---|
| 30 | "/usr/include"
|
---|
| 31 | "/usr/local/include"
|
---|
[3] | 32 | )
|
---|
| 33 |
|
---|
[50] | 34 | set(LOG4CXX_LIB_LIST
|
---|
| 35 | "/usr/lib"
|
---|
| 36 | "/usr/local/lib"
|
---|
[3] | 37 | )
|
---|
| 38 |
|
---|
| 39 | # If LOG4CXX_ROOT is available, set up our hints
|
---|
[50] | 40 | if(LOG4CXX_ROOT)
|
---|
[3] | 41 | # Includes
|
---|
[50] | 42 | list(APPEND LOG4CXX_INC_LIST
|
---|
[3] | 43 | "${LOG4CXX_ROOT}/include"
|
---|
| 44 | "${LOG4CXX_ROOT}"
|
---|
| 45 | )
|
---|
| 46 |
|
---|
[50] | 47 | # Libraries win32
|
---|
| 48 | if(MSVC)
|
---|
| 49 | # Visual Studio 2008
|
---|
| 50 | if(MSVC9)
|
---|
| 51 | list(APPEND LOG4CXX_LIB_LIST "${LOG4CXX_ROOT}/lib/msvc2008")
|
---|
| 52 | endif()
|
---|
| 53 | # Visual Studio 2010
|
---|
| 54 | if(MSVC10)
|
---|
| 55 | list(APPEND LOG4CXX_LIB_LIST "${LOG4CXX_ROOT}/lib/msvc2010")
|
---|
| 56 | endif()
|
---|
| 57 | endif()
|
---|
[3] | 58 |
|
---|
[50] | 59 | # Libraries all
|
---|
| 60 | list(APPEND LOG4CXX_LIB_LIST "${LOG4CXX_ROOT}/lib")
|
---|
| 61 | endif()
|
---|
[3] | 62 |
|
---|
| 63 | # Find headers
|
---|
[50] | 64 | find_path(
|
---|
| 65 | LOG4CXX_INCLUDE_DIR
|
---|
| 66 | NAMES
|
---|
| 67 | log4cxx/log4cxx.h
|
---|
| 68 | HINTS
|
---|
| 69 | ${LOG4CXX_INC_LIST}
|
---|
[3] | 70 | )
|
---|
| 71 |
|
---|
| 72 | # Find release library
|
---|
[50] | 73 | find_library(
|
---|
| 74 | LOG4CXX_LIBRARY
|
---|
| 75 | NAMES
|
---|
| 76 | log4cxx
|
---|
| 77 | HINTS
|
---|
| 78 | ${LOG4CXX_LIB_LIST}
|
---|
[3] | 79 | )
|
---|
| 80 |
|
---|
| 81 | # Find debug library, if on UNIX this is the same as release
|
---|
[50] | 82 | if(WIN32)
|
---|
[55] | 83 | find_library(LOG4CXX_LIBRARY_DEBUG NAMES log4cxx_d HINTS ${LOG4CXX_LIB_LIST})
|
---|
[50] | 84 | else()
|
---|
[55] | 85 | set(LOG4CXX_LIBRARY_DEBUG ${LOG4CXX_LIBRARY})
|
---|
[50] | 86 | endif()
|
---|
[3] | 87 |
|
---|
| 88 | # Set LOG4CXX_FOUND honoring the QUIET and REQUIRED arguments
|
---|
| 89 | find_package_handle_standard_args(LOG4CXX DEFAULT_MSG LOG4CXX_LIBRARY LOG4CXX_INCLUDE_DIR)
|
---|
| 90 |
|
---|
| 91 | # Output variables
|
---|
[50] | 92 | if(LOG4CXX_FOUND)
|
---|
| 93 | # Include dirs
|
---|
| 94 | set(LOG4CXX_INCLUDE_DIRS ${LOG4CXX_INCLUDE_DIR})
|
---|
[3] | 95 |
|
---|
[50] | 96 | # Release Libraries
|
---|
| 97 | if(LOG4CXX_LIBRARY)
|
---|
| 98 | LIST(APPEND LOG4CXX_LIBRARIES optimized ${LOG4CXX_LIBRARY})
|
---|
| 99 | endif()
|
---|
[3] | 100 |
|
---|
[50] | 101 | # Debug Libraries
|
---|
[55] | 102 | if(LOG4CXX_LIBRARY_DEBUG)
|
---|
| 103 | LIST(APPEND LOG4CXX_LIBRARIES debug ${LOG4CXX_LIBRARY_DEBUG})
|
---|
[50] | 104 | endif()
|
---|
[3] | 105 |
|
---|
[50] | 106 | # Link dirs
|
---|
| 107 | get_filename_component(LOG4CXX_LIBRARY_DIRS ${LOG4CXX_LIBRARY} PATH)
|
---|
[84] | 108 | else()
|
---|
| 109 | message(FATAL_ERROR "LOG4CXX library not found")
|
---|
[50] | 110 | endif()
|
---|
| 111 |
|
---|
[3] | 112 | # Advanced options for not cluttering the cmake UIs
|
---|
[91] | 113 | mark_as_advanced(LOG4CXX_INCLUDE_DIR LOG4CXX_LIBRARY LOG4CXX_LIBRARY_DEBUG)
|
---|