source: pacpusframework/trunk/cmake/Findlog4cxx.cmake@ 85

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

FATAL_ERROR => WARNING

  • Property svn:keywords set to Id
File size: 3.0 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
16IF(IS_BUILDING_PACPUS)
17 MESSAGE(AUTHOR_WARNING "Find log4cxx should use the folder inside pacpusframework to set include and library directories and not the environment variable LOG4CXX_ROOT")
18ENDIF(IS_BUILDING_PACPUS)
19
20# See if LOG4CXX_ROOT is not already set in CMake
21if(NOT LOG4CXX_ROOT)
22 # See if LOG4CXX_ROOT is set in process environment
23 if( NOT $ENV{LOG4CXX_ROOT} STREQUAL "" )
24 SET(LOG4CXX_ROOT "$ENV{LOG4CXX_ROOT}")
25 MESSAGE(STATUS "Detected LOG4CXX_ROOT set to '${LOG4CXX_ROOT}'")
26 endif()
27endif()
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
92set(LOG4CXX_LIBRARIES "")
93if(LOG4CXX_FOUND)
94 # Include dirs
95 set(LOG4CXX_INCLUDE_DIRS ${LOG4CXX_INCLUDE_DIR})
96
97 # Release Libraries
98 if(LOG4CXX_LIBRARY)
99 LIST(APPEND LOG4CXX_LIBRARIES optimized ${LOG4CXX_LIBRARY})
100 endif()
101
102 # Debug Libraries
103 if(LOG4CXX_LIBRARY_DEBUG)
104 LIST(APPEND LOG4CXX_LIBRARIES debug ${LOG4CXX_LIBRARY_DEBUG})
105 endif()
106
107 # Link dirs
108 get_filename_component(LOG4CXX_LIBRARY_DIRS ${LOG4CXX_LIBRARY} PATH)
109else()
110 message(FATAL_ERROR "LOG4CXX library not found")
111endif()
112
113# Advanced options for not cluttering the cmake UIs
114mark_as_advanced(LOG4CXX_INCLUDE_DIR LOG4CXX_LIBRARY LOG4CXX_LIBRARY_DEBUG)
Note: See TracBrowser for help on using the repository browser.