Skip to content

Commit

Permalink
cmake: fix check detection
Browse files Browse the repository at this point in the history
Building on Ubuntu 18.04 fails with missing symbols message
due to lack of proper libraries being automatically linked
against tests.

This patch uses pkgconfig to automatically detect system-installed
libcheck, and also gets rid of the unnecessery symbol requirement in
favor of a simple version check.
  • Loading branch information
pbalcer committed Feb 8, 2019
1 parent b88942a commit 52cc1d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
17 changes: 7 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,13 @@ add_subdirectory(${CCOMMON_SOURCE_DIR} ${PROJECT_BINARY_DIR}/ccommon)
include(FindPackageHandleStandardArgs)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")

find_package(Check)
if(NOT CHECK_FOUND)
message(WARNING "Check is required to build and run tests")
endif(NOT CHECK_FOUND)
if(CHECK_FOUND)
check_symbol_exists(ck_assert_int_eq check.h CHECK_WORKING)
if(NOT CHECK_WORKING)
message(WARNING "Check version too old to build tests")
endif(NOT CHECK_WORKING)
endif(CHECK_FOUND)
find_package(PkgConfig QUIET)

if(PKG_CONFIG_FOUND)
pkg_check_modules(Check REQUIRED check>=0.10)
else()
find_package(Check REQUIRED 0.10)
endif()

find_package(Threads)

Expand Down
11 changes: 0 additions & 11 deletions deps/ccommon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,6 @@ endif(COVERAGE)
include(FindPackageHandleStandardArgs)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")

find_package(Check)
if(NOT CHECK_FOUND)
message(WARNING "Check is required to build and run tests")
endif(NOT CHECK_FOUND)
if(CHECK_FOUND)
check_symbol_exists(ck_assert_int_eq check.h CHECK_WORKING)
if(NOT CHECK_WORKING)
message(WARNING "Check version too old to build tests")
endif(NOT CHECK_WORKING)
endif(CHECK_FOUND)

find_package(Threads)


Expand Down

0 comments on commit 52cc1d8

Please sign in to comment.