diff options
author | Vitaly Chikunov <vt@altlinux.org> | 2019-02-08 21:02:31 +0300 |
---|---|---|
committer | Vitaly Chikunov <vt@altlinux.org> | 2019-02-08 21:02:31 +0300 |
commit | 931811c7142253b80c3a7a8e5e1095a6bdf01774 (patch) | |
tree | 332a12f02b18d0e90f95ac1dc3ad1f15c84a647c | |
parent | eea06158911bb530156ff6e54ec26dcd471e977e (diff) | |
download | gost-engine-931811c7142253b80c3a7a8e5e1095a6bdf01774.zip gost-engine-931811c7142253b80c3a7a8e5e1095a6bdf01774.tar.gz gost-engine-931811c7142253b80c3a7a8e5e1095a6bdf01774.tar.bz2 |
cmake: benchmark/sign - link with rt for clock_gettime when needed
Test if clock_gettime() requires linking with -lrt and link sign
benchmark with rt if needed. clock_gettime() requires -lrt only for
glibc versions before 2.17.
-rw-r--r-- | CMakeLists.txt | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c81c55b..261decd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.0 FATAL_ERROR) project(gost-engine LANGUAGES C) include(GNUInstallDirs) +include(CheckLibraryExists) +include(CheckFunctionExists) enable_testing() @@ -25,7 +27,11 @@ if (ASAN) endif() set(CMAKE_C_STANDARD 90) -list(APPEND CMAKE_REQUIRED_LIBRARIES rt) +CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME_C) +CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_CLOCK_GETTIME_RT) +if(HAVE_CLOCK_GETTIME_RT AND NOT HAVE_CLOCK_GETTIME_C) + set(CLOCK_GETTIME_LIB rt) +endif() include (TestBigEndian) TEST_BIG_ENDIAN(IS_BIG_ENDIAN) @@ -174,7 +180,7 @@ set_tests_properties(engine PROPERTIES ENVIRONMENT endif() add_executable(sign benchmark/sign.c) -target_link_libraries(sign gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY}) +target_link_libraries(sign gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} ${CLOCK_GETTIME_LIB}) add_library(gost_core STATIC ${GOST_LIB_SOURCE_FILES}) set_target_properties(gost_core PROPERTIES POSITION_INDEPENDENT_CODE ON) |