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 |
|
---|
14 | include(FindPackageHandleStandardArgs)
|
---|
15 |
|
---|
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()
|
---|
25 | endif()
|
---|
26 |
|
---|
27 |
|
---|
28 |
|
---|
29 | set(LOG4CXX_INC_LIST
|
---|
30 | "/usr/include"
|
---|
31 | "/usr/local/include"
|
---|
32 | )
|
---|
33 |
|
---|
34 | set(LOG4CXX_LIB_LIST
|
---|
35 | "/usr/lib"
|
---|
36 | "/usr/local/lib"
|
---|
37 | )
|
---|
38 |
|
---|
39 | # If LOG4CXX_ROOT is available, set up our hints
|
---|
40 | if(LOG4CXX_ROOT)
|
---|
41 | # Includes
|
---|
42 | list(APPEND LOG4CXX_INC_LIST
|
---|
43 | "${LOG4CXX_ROOT}/include"
|
---|
44 | "${LOG4CXX_ROOT}"
|
---|
45 | )
|
---|
46 |
|
---|
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()
|
---|
58 |
|
---|
59 | # Libraries all
|
---|
60 | list(APPEND LOG4CXX_LIB_LIST "${LOG4CXX_ROOT}/lib")
|
---|
61 | endif()
|
---|
62 |
|
---|
63 | # Find headers
|
---|
64 | find_path(
|
---|
65 | LOG4CXX_INCLUDE_DIR
|
---|
66 | NAMES
|
---|
67 | log4cxx/log4cxx.h
|
---|
68 | HINTS
|
---|
69 | ${LOG4CXX_INC_LIST}
|
---|
70 | )
|
---|
71 |
|
---|
72 | # Find release library
|
---|
73 | find_library(
|
---|
74 | LOG4CXX_LIBRARY
|
---|
75 | NAMES
|
---|
76 | log4cxx
|
---|
77 | HINTS
|
---|
78 | ${LOG4CXX_LIB_LIST}
|
---|
79 | )
|
---|
80 |
|
---|
81 | # Find debug library, if on UNIX this is the same as release
|
---|
82 | if(WIN32)
|
---|
83 | find_library(LOG4CXX_LIBRARY_DEBUG NAMES log4cxx_d HINTS ${LOG4CXX_LIB_LIST})
|
---|
84 | else()
|
---|
85 | set(LOG4CXX_LIBRARY_DEBUG ${LOG4CXX_LIBRARY})
|
---|
86 | endif()
|
---|
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
|
---|
92 | if(LOG4CXX_FOUND)
|
---|
93 | # Include dirs
|
---|
94 | set(LOG4CXX_INCLUDE_DIRS ${LOG4CXX_INCLUDE_DIR})
|
---|
95 |
|
---|
96 | # Release Libraries
|
---|
97 | if(LOG4CXX_LIBRARY)
|
---|
98 | LIST(APPEND LOG4CXX_LIBRARIES optimized ${LOG4CXX_LIBRARY})
|
---|
99 | endif()
|
---|
100 |
|
---|
101 | # Debug Libraries
|
---|
102 | if(LOG4CXX_LIBRARY_DEBUG)
|
---|
103 | LIST(APPEND LOG4CXX_LIBRARIES debug ${LOG4CXX_LIBRARY_DEBUG})
|
---|
104 | endif()
|
---|
105 |
|
---|
106 | # Link dirs
|
---|
107 | get_filename_component(LOG4CXX_LIBRARY_DIRS ${LOG4CXX_LIBRARY} PATH)
|
---|
108 | else()
|
---|
109 | message(FATAL_ERROR "LOG4CXX library not found")
|
---|
110 | endif()
|
---|
111 |
|
---|
112 | # Advanced options for not cluttering the cmake UIs
|
---|
113 | mark_as_advanced(LOG4CXX_INCLUDE_DIR LOG4CXX_LIBRARY LOG4CXX_LIBRARY_DEBUG)
|
---|