diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-08 15:51:16 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-08 15:51:16 +0100 |
commit | e95ca5c778fb9dd0969c842ec57389025a9db913 (patch) | |
tree | 151b005ca918017106ddb263658a2edee1cfffe4 /CMakeLists.txt | |
parent | 5f593737d534de847747a641c75f70b608ae5d74 (diff) | |
download | rspamd-e95ca5c778fb9dd0969c842ec57389025a9db913.tar.gz rspamd-e95ca5c778fb9dd0969c842ec57389025a9db913.zip |
Rework cmake caching.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 112 |
1 files changed, 53 insertions, 59 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 01d5563cc..1d92132df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,8 +224,8 @@ MACRO(FindLua) IF(LUA_LIBRARY AND LUA_INCLUDE_DIR) SET(LUA_FOUND 1) IF(NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR) - SET(CACHE LUA_VERSION_MAJOR ${LUA_VERSION_MAJOR}) - SET(CACHE LUA_VERSION_MINOR ${LUA_VERSION_MINOR}) + SET(LUA_VERSION_MAJOR ${LUA_VERSION_MAJOR}) + SET(LUA_VERSION_MINOR ${LUA_VERSION_MINOR}) ENDIF(NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR) IF(ENABLE_LUAJIT MATCHES "ON") MESSAGE(STATUS "Found luajit ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}") @@ -293,7 +293,7 @@ MACRO(ProcessPackage PKG_NAME) IF(${PKG_NAME}_FOUND) MESSAGE(STATUS "Found package ${PKG_NAME} in pkg-config modules ${PKG_MODULES}") - SET(WITH_${PKG_NAME} 1) + SET(WITH_${PKG_NAME} 1 CACHE INTERNAL "") IF(ENABLE_STATIC MATCHES "ON") SET(_XPREFIX "${PKG_NAME}_STATIC") ELSE(ENABLE_STATIC MATCHES "ON") @@ -317,40 +317,50 @@ MACRO(ProcessPackage PKG_NAME) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "${${_XPREFIX}_LIBRARIES}") INCLUDE_DIRECTORIES(${${_XPREFIX}_INCLUDEDIR}) ELSE() - # Try some more heuristic - FIND_LIBRARY(_lib NAMES ${PKG_LIBRARY} - HINTS "${PKG_ROOT}" "${RSPAMD_SEARCH_PATH}" - PATH_SUFFIXES "${PKG_LIB_SUFFIXES}" lib64 lib - PATHS ${RSPAMD_DEFAULT_LIBRARY_PATHS}) - IF(NOT _lib) - IF(OPTIONAL) - MESSAGE("Cannot find library ${PKG_LIBRARY} for package ${PKG_NAME}") - ELSE() - MESSAGE(FATAL_ERROR "Cannot find library ${PKG_LIBRARY} for package ${PKG_NAME}") - ENDIF() - ENDIF(NOT _lib) - - FIND_PATH(_incl "${PKG_INCLUDE}" + IF(NOT ${PKG_NAME}_GUESSED) + # Try some more heuristic + FIND_LIBRARY(_lib NAMES ${PKG_LIBRARY} HINTS "${PKG_ROOT}" "${RSPAMD_SEARCH_PATH}" - PATH_SUFFIXES "${PKG_INCLUDE_SUFFIXES}" "include" - PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS}) - IF(NOT _incl) - IF(OPTIONAL) - MESSAGE("Cannot find header ${PKG_INCLUDE} for package ${PKG_NAME}") - ELSE() - MESSAGE(FATAL_ERROR "Cannot find header ${PKG_INCLUDE} for package ${PKG_NAME}") + PATH_SUFFIXES "${PKG_LIB_SUFFIXES}" lib64 lib + PATHS ${RSPAMD_DEFAULT_LIBRARY_PATHS}) + IF(NOT _lib) + IF(OPTIONAL) + MESSAGE("Cannot find library ${PKG_LIBRARY} for package ${PKG_NAME}") + ELSE() + MESSAGE(FATAL_ERROR "Cannot find library ${PKG_LIBRARY} for package ${PKG_NAME}") + ENDIF() + ENDIF(NOT _lib) + + FIND_PATH(_incl "${PKG_INCLUDE}" + HINTS "${PKG_ROOT}" "${RSPAMD_SEARCH_PATH}" + PATH_SUFFIXES "${PKG_INCLUDE_SUFFIXES}" "include" + PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS}) + IF(NOT _incl) + IF(OPTIONAL) + MESSAGE("Cannot find header ${PKG_INCLUDE} for package ${PKG_NAME}") + ELSE() + MESSAGE(FATAL_ERROR "Cannot find header ${PKG_INCLUDE} for package ${PKG_NAME}") + ENDIF() + ENDIF(NOT _incl) + + IF(_incl AND _lib) + GET_FILENAME_COMPONENT(_lib_path "${_lib}" PATH) + INCLUDE_DIRECTORIES("${_incl}") + LINK_DIRECTORIES("${_lib_path}") + LIST(APPEND RSPAMD_REQUIRED_LIBRARIES ${_lib}) + SET(${PKG_NAME}_INCLUDE "${_incl}" CACHE INTERNAL "") + SET(${PKG_NAME}_LIBRARY_PATH "${_lib_path}" CACHE INTERNAL "") + SET(${PKG_NAME}_LIBRARY "${_lib}" CACHE INTERNAL "") + SET(${PKG_NAME}_GUESSED 1 CACHE INTERNAL "") + SET(WITH_${PKG_NAME} 1 CACHE INTERNAL "") + MESSAGE(STATUS "Found package ${PKG_NAME} in '${_lib_path}' (${_lib}) and '${_incl}' (${PKG_INCLUDE}).") ENDIF() - ENDIF(NOT _incl) - IF(_incl AND _lib) - GET_FILENAME_COMPONENT(_lib_path "${_lib}" PATH) - INCLUDE_DIRECTORIES("${_incl}") - LINK_DIRECTORIES("${_lib_path}") - LIST(APPEND RSPAMD_REQUIRED_LIBRARIES ${_lib}) - SET(${PKG_NAME}_INCLUDE "${_incl}") - SET(${PKG_NAME}_LIBRARY "${_lib_path}") - SET(${PKG_NAME}_FOUND 1) - MESSAGE(STATUS "Found package ${PKG_NAME} in '${_lib_path}' (${_lib}) and '${_incl}' (${PKG_INCLUDE}).") + ELSE() + MESSAGE(STATUS "Found package ${PKG_NAME} (cached)") + INCLUDE_DIRECTORIES("${${PKG_NAME}_INCLUDE}") + LINK_DIRECTORIES("${${PKG_NAME}_LIBRARY_PATH}") + LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "${${PKG_NAME}_LIBRARY}") ENDIF() ENDIF(${PKG_NAME}_FOUND) @@ -425,7 +435,7 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # Find util library ProcessPackage(LIBUTIL LIBRARY util INCLUDE libutil.h ROOT ${LIBUTIL_ROOT_DIR} OPTIONAL) - IF(LIBUTIL_FOUND) + IF(WITH_LIBUTIL) SET(HAVE_LIBUTIL_H 1) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES util) LIST(APPEND CMAKE_REQUIRED_LIBRARIES util) @@ -560,9 +570,9 @@ ProcessPackage(OPENSSL LIBRARY crypto INCLUDE opensslconf.h INCLUDE_SUFFIXES inc ROOT ${OPENSSL_ROOT_DIR} MODULES openssl) #Check for openssl (required for dkim) -IF(OPENSSL_FOUND) +IF(WITH_OPENSSL) SET(HAVE_OPENSSL 1) -ENDIF(OPENSSL_FOUND) +ENDIF(WITH_OPENSSL) IF(GMIME2_VERSION VERSION_GREATER "2.4.0" OR NOT GMIME2_VERSION) SET(GMIME24 1) @@ -578,7 +588,6 @@ ENDIF(PCRE_LIBRARY) IF(ENABLE_HIREDIS MATCHES "ON") ProcessPackage(HIREDIS LIBRARY hiredis INCLUDE hiredis.h INCLUDE_SUFFIXES include/hiredis ROOT ${HIREDIS_ROOT_DIR} MODULES hiredis libhiredis) - SET(WITH_HIREDIS 1) ENDIF(ENABLE_HIREDIS MATCHES "ON") @@ -753,7 +762,7 @@ CHECK_C_SOURCE_COMPILES( return cmkcheckweak == NULL; }" HAVE_WEAK_SYMBOLS) -IF(ICONV_FOUND) +IF(WITH_ICONV) CHECK_C_SOURCE_COMPILES(" #include <iconv.h> int main(){ @@ -766,7 +775,7 @@ int main(){ return 0; } " ICONV_SECOND_ARGUMENT_IS_CONST) -ENDIF(ICONV_FOUND) +ENDIF(WITH_ICONV) # Check macros CHECK_SYMBOL_EXISTS(PATH_MAX limits.h HAVE_PATH_MAX) @@ -831,7 +840,7 @@ TRY_RUN(_CAN_RUN _CAN_COMPILE "${CMAKE_BINARY_DIR}" "${CMAKE_BINARY_DIR}/pthread_setpshared.c" CMAKE_FLAGS CMAKE_C_FLAGS="-pthread") IF(_CAN_RUN EQUAL 1) - SET(HAVE_PTHREAD_PROCESS_SHARED 1) + SET(HAVE_PTHREAD_PROCESS_SHARED 1 CACHE INTERNAL "") ENDIF(_CAN_RUN EQUAL 1) IF(HAVE_PTHREAD_PROCESS_SHARED) MESSAGE(STATUS "pthread_mutexattr_setpshared is supported") @@ -891,9 +900,9 @@ IF(ENABLE_URL_INCLUDE MATCHES "ON") # Try to find libcurl ProcessPackage(CURL LIBRARY curl INCLUDE curl.h INCLUDE_SUFFIXES include/curl ROOT ${CURL_ROOT}) - IF(NOT CURL_FOUND) + IF(NOT WITH_CURL) MESSAGE(WARNING "Neither libcurl nor libfetch were found, no support of URL includes in configuration") - ENDIF(NOT CURL_FOUND) + ENDIF(NOT WITH_CURL) ENDIF(LIBFETCH_LIBRARY) ENDIF(ENABLE_URL_INCLUDE MATCHES "ON") @@ -966,17 +975,9 @@ LIST(APPEND RSPAMD_REQUIRED_LIBRARIES ottery) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES event) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES xxhash) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES blake2) -LIST(APPEND RSPAMD_REQUIRED_LIBRARIES sqlite3) -IF(OPENSSL_FOUND) - LIST(APPEND RSPAMD_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) -ENDIF(OPENSSL_FOUND) IF(HAVE_FETCH_H) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES fetch) ENDIF(HAVE_FETCH_H) -LIST(APPEND RSPAMD_REQUIRED_LIBRARIES event) -IF(HAVE_LIBEVENT2) - LIST(APPEND RSPAMD_REQUIRED_LIBRARIES event_pthreads) -ENDIF(HAVE_LIBEVENT2) IF(WITH_DB) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES db) ENDIF(WITH_DB) @@ -984,13 +985,6 @@ ENDIF(WITH_DB) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "${LUA_LIBRARY}") -IF(ENABLE_GPERF_TOOLS MATCHES "ON") - LIST(APPEND RSPAMD_REQUIRED_LIBRARIES profiler) -ENDIF(ENABLE_GPERF_TOOLS MATCHES "ON") - -IF(ENABLE_HIREDIS MATCHES "ON") - LIST(APPEND RSPAMD_REQUIRED_LIBRARIES hiredis) -ENDIF(ENABLE_HIREDIS MATCHES "ON") IF(GLIB_COMPAT) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES glibadditions) ENDIF(GLIB_COMPAT) @@ -1128,4 +1122,4 @@ ADD_CUSTOM_TARGET(dist ${CMAKE_SOURCE_DIR}/dist.sh IF(NOT DEBIAN_BUILD) ADD_CUSTOM_TARGET(check DEPENDS rspamd-test) ADD_CUSTOM_TARGET(run-test DEPENDS check COMMAND test/rspamd-test) -ENDIF(NOT DEBIAN_BUILD) +ENDIF(NOT DEBIAN_BUILD)
\ No newline at end of file |