From 13f05db93484ad6100c1987d11e7a6d33bd5d754 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Sat, 14 Apr 2012 00:05:52 +0200 Subject: [PATCH] cmake: Make Log4C optional. Signed-off-by: Andreas Schneider --- CMakeLists.txt | 4 +-- cmake/Modules/FindLog4C.cmake | 49 ++++++++++------------------------- src/CMakeLists.txt | 8 ++++-- 3 files changed, 21 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c247212d4..9e138b23d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake/Modules/FindLog4C.cmake b/cmake/Modules/FindLog4C.cmake index 1f05ed2db..17260b118 100644 --- a/cmake/Modules/FindLog4C.cmake +++ b/cmake/Modules/FindLog4C.cmake @@ -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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9ef5cd0bf..8b6b4812a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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