From 93acacfa62bf18eee95d5a76424d34c05728dee2 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 1 Sep 2009 12:16:51 +0200 Subject: [PATCH] Improve FindCheck module. --- CMakeLists.txt | 3 +-- cmake/Modules/FindCheck.cmake | 49 ++++++++++------------------------- 2 files changed, 14 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6819c9b84..82cd35262 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,6 @@ include(MacroCopyFile) if (WITH_LOG4C) find_package(Log4C REQUIRED) endif (WITH_LOG4C) -find_package(Check) include(ConfigureChecks.cmake) configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) @@ -55,8 +54,8 @@ add_subdirectory(client) add_subdirectory(config) add_subdirectory(doc) +find_package(Check) if (CHECK_FOUND AND UNIT_TESTING) - include(MacroAddCheckTest) add_subdirectory(tests) endif (CHECK_FOUND AND UNIT_TESTING) diff --git a/cmake/Modules/FindCheck.cmake b/cmake/Modules/FindCheck.cmake index c25daacbd..ce32b1067 100644 --- a/cmake/Modules/FindCheck.cmake +++ b/cmake/Modules/FindCheck.cmake @@ -6,7 +6,7 @@ # CHECK_LIBRARIES - Link these to use Check # CHECK_DEFINITIONS - Compiler switches required for using Check # -# Copyright (c) 2008 Andreas Schneider +# Copyright (c) 2009 Andreas Schneider # # Redistribution and use is allowed according to the terms of the New # BSD license. @@ -16,19 +16,13 @@ if (CHECK_LIBRARIES AND CHECK_INCLUDE_DIRS) # in cache already - set(CHECK_FOUND TRUE) + set(CHECK_FOUND TRUE PARENT_SCOPE) else (CHECK_LIBRARIES AND CHECK_INCLUDE_DIRS) - # use pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) - include(UsePkgConfig) - pkgconfig(check _CHECK_INCLUDEDIR _CHECK_LIBDIR _CHECK_LDFLAGS _CHECK_CFLAGS) - else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) - find_package(PkgConfig) - if (PKG_CONFIG_FOUND) - pkg_check_modules(_CHECK check) - endif (PKG_CONFIG_FOUND) - endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(_CHECK check) + endif (PKG_CONFIG_FOUND) + find_path(CHECK_INCLUDE_DIR NAMES check.h @@ -44,40 +38,23 @@ else (CHECK_LIBRARIES AND CHECK_INCLUDE_DIRS) NAMES check PATHS - ${_Check_LIBDIR} + ${_CHECK_LIBDIR} /usr/lib /usr/local/lib /opt/local/lib /sw/lib ) - if (CHECK_LIBRARY) - set(CHECK_FOUND TRUE) - endif (CHECK_LIBRARY) - set(CHECK_INCLUDE_DIRS ${CHECK_INCLUDE_DIR} ) - if (CHECK_FOUND) - set(CHECK_LIBRARIES - ${CHECK_LIBRARY} - ) - endif (CHECK_FOUND) + set(CHECK_LIBRARIES + ${CHECK_LIBRARY} + ) - if (CHECK_INCLUDE_DIRS AND CHECK_LIBRARIES) - set(CHECK_FOUND TRUE) - endif (CHECK_INCLUDE_DIRS AND CHECK_LIBRARIES) - - if (CHECK_FOUND) - if (NOT Check_FIND_QUIETLY) - message(STATUS "Found Check: ${CHECK_LIBRARIES}") - endif (NOT Check_FIND_QUIETLY) - else (CHECK_FOUND) - if (Check_FIND_REQUIRED) - message(FATAL_ERROR "Could not find Check") - endif (Check_FIND_REQUIRED) - endif (CHECK_FOUND) + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Check DEFAULT_MSG CHECK_LIBRARIES CHECK_INCLUDE_DIRS) # show the CHECK_INCLUDE_DIRS and CHECK_LIBRARIES variables only in the advanced view mark_as_advanced(CHECK_INCLUDE_DIRS CHECK_LIBRARIES)