[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 |
|
---|
| 16 | # See if LOG4CXX_ROOT is not already set in CMake
|
---|
[50] | 17 | if(NOT LOG4CXX_ROOT)
|
---|
[3] | 18 | # See if LOG4CXX_ROOT is set in process environment
|
---|
[50] | 19 | if( NOT $ENV{LOG4CXX_ROOT} STREQUAL "" )
|
---|
| 20 | SET(LOG4CXX_ROOT "$ENV{LOG4CXX_ROOT}")
|
---|
| 21 | MESSAGE(STATUS "Detected LOG4CXX_ROOT set to '${LOG4CXX_ROOT}'")
|
---|
| 22 | endif()
|
---|
| 23 | endif()
|
---|
[3] | 24 |
|
---|
[50] | 25 | set(LOG4CXX_INC_LIST
|
---|
| 26 | "/usr/include"
|
---|
| 27 | "/usr/local/include"
|
---|
[3] | 28 | )
|
---|
| 29 |
|
---|
[50] | 30 | set(LOG4CXX_LIB_LIST
|
---|
| 31 | "/usr/lib"
|
---|
| 32 | "/usr/local/lib"
|
---|
[3] | 33 | )
|
---|
| 34 |
|
---|
| 35 | # If LOG4CXX_ROOT is available, set up our hints
|
---|
[50] | 36 | if(LOG4CXX_ROOT)
|
---|
[3] | 37 | # Includes
|
---|
[50] | 38 | list(APPEND LOG4CXX_INC_LIST
|
---|
[3] | 39 | "${LOG4CXX_ROOT}/include"
|
---|
| 40 | "${LOG4CXX_ROOT}"
|
---|
| 41 | )
|
---|
| 42 |
|
---|
[50] | 43 | # Libraries win32
|
---|
| 44 | if(MSVC)
|
---|
| 45 | # Visual Studio 2008
|
---|
| 46 | if(MSVC9)
|
---|
| 47 | list(APPEND LOG4CXX_LIB_LIST "${LOG4CXX_ROOT}/lib/msvc2008")
|
---|
| 48 | endif()
|
---|
| 49 | # Visual Studio 2010
|
---|
| 50 | if(MSVC10)
|
---|
| 51 | list(APPEND LOG4CXX_LIB_LIST "${LOG4CXX_ROOT}/lib/msvc2010")
|
---|
| 52 | endif()
|
---|
| 53 | endif()
|
---|
[3] | 54 |
|
---|
[50] | 55 | # Libraries all
|
---|
| 56 | list(APPEND LOG4CXX_LIB_LIST "${LOG4CXX_ROOT}/lib")
|
---|
| 57 | endif()
|
---|
[3] | 58 |
|
---|
| 59 | # Find headers
|
---|
[50] | 60 | find_path(
|
---|
| 61 | LOG4CXX_INCLUDE_DIR
|
---|
| 62 | NAMES
|
---|
| 63 | log4cxx/log4cxx.h
|
---|
| 64 | HINTS
|
---|
| 65 | ${LOG4CXX_INC_LIST}
|
---|
[3] | 66 | )
|
---|
| 67 |
|
---|
| 68 | # Find release library
|
---|
[50] | 69 | find_library(
|
---|
| 70 | LOG4CXX_LIBRARY
|
---|
| 71 | NAMES
|
---|
| 72 | log4cxx
|
---|
| 73 | HINTS
|
---|
| 74 | ${LOG4CXX_LIB_LIST}
|
---|
[3] | 75 | )
|
---|
| 76 |
|
---|
| 77 | # Find debug library, if on UNIX this is the same as release
|
---|
[50] | 78 | if(WIN32)
|
---|
[55] | 79 | find_library(LOG4CXX_LIBRARY_DEBUG NAMES log4cxx_d HINTS ${LOG4CXX_LIB_LIST})
|
---|
[50] | 80 | else()
|
---|
[55] | 81 | set(LOG4CXX_LIBRARY_DEBUG ${LOG4CXX_LIBRARY})
|
---|
[50] | 82 | endif()
|
---|
[3] | 83 |
|
---|
| 84 | # Set LOG4CXX_FOUND honoring the QUIET and REQUIRED arguments
|
---|
| 85 | find_package_handle_standard_args(LOG4CXX DEFAULT_MSG LOG4CXX_LIBRARY LOG4CXX_INCLUDE_DIR)
|
---|
| 86 |
|
---|
| 87 | # Output variables
|
---|
[50] | 88 | set(LOG4CXX_LIBRARIES "")
|
---|
| 89 | if(LOG4CXX_FOUND)
|
---|
| 90 | # Include dirs
|
---|
| 91 | set(LOG4CXX_INCLUDE_DIRS ${LOG4CXX_INCLUDE_DIR})
|
---|
[3] | 92 |
|
---|
[50] | 93 | # Release Libraries
|
---|
| 94 | if(LOG4CXX_LIBRARY)
|
---|
| 95 | LIST(APPEND LOG4CXX_LIBRARIES optimized ${LOG4CXX_LIBRARY})
|
---|
| 96 | endif()
|
---|
[3] | 97 |
|
---|
[50] | 98 | # Debug Libraries
|
---|
[55] | 99 | if(LOG4CXX_LIBRARY_DEBUG)
|
---|
| 100 | LIST(APPEND LOG4CXX_LIBRARIES debug ${LOG4CXX_LIBRARY_DEBUG})
|
---|
[50] | 101 | endif()
|
---|
[3] | 102 |
|
---|
[50] | 103 | # Link dirs
|
---|
| 104 | get_filename_component(LOG4CXX_LIBRARY_DIRS ${LOG4CXX_LIBRARY} PATH)
|
---|
| 105 | endif()
|
---|
| 106 |
|
---|
[3] | 107 | # Advanced options for not cluttering the cmake UIs
|
---|
[55] | 108 | mark_as_advanced(LOG4CXX_INCLUDE_DIR LOG4CXX_LIBRARY LOG4CXX_LIBRARY_DEBUG) |
---|