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
RevLine 
[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]14include(FindPackageHandleStandardArgs)
[3]15
[84]16IF(IS_BUILDING_PACPUS)
[85]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")
[84]18ENDIF(IS_BUILDING_PACPUS)
19
[3]20# See if LOG4CXX_ROOT is not already set in CMake
[50]21if(NOT LOG4CXX_ROOT)
[3]22 # See if LOG4CXX_ROOT is set in process environment
[50]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()
[3]28
[50]29set(LOG4CXX_INC_LIST
30 "/usr/include"
31 "/usr/local/include"
[3]32)
33
[50]34set(LOG4CXX_LIB_LIST
35 "/usr/lib"
36 "/usr/local/lib"
[3]37)
38
39# If LOG4CXX_ROOT is available, set up our hints
[50]40if(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")
61endif()
[3]62
63# Find headers
[50]64find_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]73find_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]82if(WIN32)
[55]83 find_library(LOG4CXX_LIBRARY_DEBUG NAMES log4cxx_d HINTS ${LOG4CXX_LIB_LIST})
[50]84else()
[55]85 set(LOG4CXX_LIBRARY_DEBUG ${LOG4CXX_LIBRARY})
[50]86endif()
[3]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
[50]92set(LOG4CXX_LIBRARIES "")
93if(LOG4CXX_FOUND)
94 # Include dirs
95 set(LOG4CXX_INCLUDE_DIRS ${LOG4CXX_INCLUDE_DIR})
[3]96
[50]97 # Release Libraries
98 if(LOG4CXX_LIBRARY)
99 LIST(APPEND LOG4CXX_LIBRARIES optimized ${LOG4CXX_LIBRARY})
100 endif()
[3]101
[50]102 # Debug Libraries
[55]103 if(LOG4CXX_LIBRARY_DEBUG)
104 LIST(APPEND LOG4CXX_LIBRARIES debug ${LOG4CXX_LIBRARY_DEBUG})
[50]105 endif()
[3]106
[50]107 # Link dirs
108 get_filename_component(LOG4CXX_LIBRARY_DIRS ${LOG4CXX_LIBRARY} PATH)
[84]109else()
110 message(FATAL_ERROR "LOG4CXX library not found")
[50]111endif()
112
[3]113# Advanced options for not cluttering the cmake UIs
[55]114mark_as_advanced(LOG4CXX_INCLUDE_DIR LOG4CXX_LIBRARY LOG4CXX_LIBRARY_DEBUG)
Note: See TracBrowser for help on using the repository browser.