source: pacpusframework/branches/0.0.x/cmake/Findlog4cxx.cmake

Last change on this file was 91, checked in by DHERBOMEZ Gérald, 11 years ago

Improvement of the build system to avoid some workarounds

  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
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
14include(FindPackageHandleStandardArgs)
15
16# For Windows, when building Pacpus use the local log4cxx files, else use the log4cxx files in the pacpus install dir
17if(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()
25endif()
26
27
28
29set(LOG4CXX_INC_LIST
30 "/usr/include"
31 "/usr/local/include"
32)
33
34set(LOG4CXX_LIB_LIST
35 "/usr/lib"
36 "/usr/local/lib"
37)
38
39# If LOG4CXX_ROOT is available, set up our hints
40if(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")
61endif()
62
63# Find headers
64find_path(
65 LOG4CXX_INCLUDE_DIR
66 NAMES
67 log4cxx/log4cxx.h
68 HINTS
69 ${LOG4CXX_INC_LIST}
70)
71
72# Find release library
73find_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
82if(WIN32)
83 find_library(LOG4CXX_LIBRARY_DEBUG NAMES log4cxx_d HINTS ${LOG4CXX_LIB_LIST})
84else()
85 set(LOG4CXX_LIBRARY_DEBUG ${LOG4CXX_LIBRARY})
86endif()
87
88# Set LOG4CXX_FOUND honoring the QUIET and REQUIRED arguments
89find_package_handle_standard_args(LOG4CXX DEFAULT_MSG LOG4CXX_LIBRARY LOG4CXX_INCLUDE_DIR)
90
91# Output variables
92if(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)
108else()
109 message(FATAL_ERROR "LOG4CXX library not found")
110endif()
111
112# Advanced options for not cluttering the cmake UIs
113mark_as_advanced(LOG4CXX_INCLUDE_DIR LOG4CXX_LIBRARY LOG4CXX_LIBRARY_DEBUG)
Note: See TracBrowser for help on using the repository browser.