cmake: Make Log4C optional.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Dominik Schmidt 2012-04-14 00:05:52 +02:00 committed by Andreas Schneider
parent 4693f313cd
commit 13f05db934
3 changed files with 21 additions and 40 deletions

View file

@ -39,9 +39,7 @@ macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source buil
include(MacroAddPlugin)
include(MacroCopyFile)
if (WITH_LOG4C)
find_package(Log4C REQUIRED)
endif (WITH_LOG4C)
find_package(Log4C)
include(ConfigureChecks.cmake)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)

View file

@ -13,45 +13,24 @@
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
include(GNUInstallDirs)
if (LOG4C_LIBRARIES AND LOG4C_INCLUDE_DIRS)
# in cache already
set(LOG4C_FOUND TRUE PARENT_SCOPE)
else (LOG4C_LIBRARIES AND LOG4C_INCLUDE_DIRS)
find_path(LOG4C_INCLUDE_DIR
find_path(LOG4C_INCLUDE_DIRS
NAMES
log4c.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
)
HINTS
${CMAKE_INSTALL_INCLUDEDIR}
)
find_library(LOG4C_LIBRARY
find_library(LOG4C_LIBRARIES
NAMES
log4c
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
log4c
HINTS
${CMAKE_INSTALL_LIBDIR}
)
set(LOG4C_INCLUDE_DIRS
${LOG4C_INCLUDE_DIR}
)
set(LOG4C_LIBRARIES
${LOG4C_LIBRARY}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Log4C DEFAULT_MSG LOG4C_LIBRARIES LOG4C_INCLUDE_DIRS)
# show the LOG4C_INCLUDE_DIRS and LOG4C_LIBRARIES variables only in the advanced view
mark_as_advanced(LOG4C_INCLUDE_DIRS LOG4C_LIBRARIES)
endif (LOG4C_LIBRARIES AND LOG4C_INCLUDE_DIRS)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Log4C DEFAULT_MSG LOG4C_LIBRARIES LOG4C_INCLUDE_DIRS)
# show the LOG4C_INCLUDE_DIRS and LOG4C_LIBRARIES variables only in the advanced view
mark_as_advanced(LOG4C_INCLUDE_DIRS LOG4C_LIBRARIES)

View file

@ -13,7 +13,6 @@ set(CSYNC_PUBLIC_INCLUDE_DIRS
set(CSYNC_PRIVATE_INCLUDE_DIRS
${INIPARSER_INCLUDE_DIRS}
${LOG4C_INCLUDE_DIRS}
${SQLITE3_INCLUDE_DIRS}
${CSTDLIB_PUBLIC_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}
@ -29,10 +28,15 @@ set(CSYNC_LINK_LIBRARIES
${CSTDLIB_LIBRARY}
${CSYNC_REQUIRED_LIBRARIES}
${INIPARSER_LIBRARIES}
${LOG4C_LIBRARIES}
${SQLITE3_LIBRARIES}
)
if(LOG4C_FOUND)
list(APPEND CSYNC_PRIVATE_INCLUDE_DIRS ${LOG4C_INCLUDE_DIRS})
list(APPEND CSYNC_LINK_LIBRARIES ${LOG4C_LIBRARIES})
endif()
set(csync_SRCS
csync.c
csync_config.c