From 9c7c8c3f4215157e2a3528e524e2d98f319e197f Mon Sep 17 00:00:00 2001 From: Evan McClain Date: Mon, 10 Oct 2022 23:32:03 -0400 Subject: [PATCH 21/46] Link against libm if needed. --- libairspyhf/src/CMakeLists.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libairspyhf/src/CMakeLists.txt b/libairspyhf/src/CMakeLists.txt index 9d8d483..6180376 100644 --- a/libairspyhf/src/CMakeLists.txt +++ b/libairspyhf/src/CMakeLists.txt @@ -57,6 +57,27 @@ endif() set_target_properties(airspyhf PROPERTIES CLEAN_DIRECT_OUTPUT 1) set_target_properties(airspyhf-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) +include(CheckFunctionExists) + +if(NOT COS_FUNCTION_EXISTS AND NOT NEED_LINKING_AGAINST_LIBM) + CHECK_FUNCTION_EXISTS(cos COS_FUNCTION_EXISTS) + if(NOT COS_FUNCTION_EXISTS) + unset(COS_FUNCTION_EXISTS CACHE) + list(APPEND CMAKE_REQUIRED_LIBRARIES m) + CHECK_FUNCTION_EXISTS(cos COS_FUNCTION_EXISTS) + if(COS_FUNCTION_EXISTS) + set(NEED_LINKING_AGAINST_LIBM True CACHE BOOL "" FORCE) + else() + message(FATAL_ERROR "Failed making the cos() function available") + endif() + endif() +endif() + +if (NEED_LINKING_AGAINST_LIBM) + target_link_libraries(airspyhf m) +endif() + + # Dependencies target_link_libraries(airspyhf ${LIBUSB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) -- 2.47.3