From a0ad1d127ae6ff14cd54849c72347762a52e200a Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 24 Apr 2024 12:46:22 +0200 Subject: [PATCH] build: fix symbol and library detection Do not unset CMAKE_REQUIRED_* variables in order to allow various feature tests to work properly with nonstandard locations. Fixes: #186 Signed-off-by: Jo-Philipp Wich --- CMakeLists.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 084c4417..1ffcadcc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,8 +103,8 @@ if(NOT FMOD_FUNCTION_EXISTS) target_link_libraries(libucode m) endif() -set(CMAKE_REQUIRED_INCLUDES ${JSONC_INCLUDE_DIRS}) -set(CMAKE_REQUIRED_LIBRARIES ${JSONC_LINK_LIBRARIES}) +list(APPEND CMAKE_REQUIRED_INCLUDES ${JSONC_INCLUDE_DIRS}) +list(APPEND CMAKE_REQUIRED_LIBRARIES ${JSONC_LINK_LIBRARIES}) check_symbol_exists(json_tokener_get_parse_end "json-c/json.h" HAVE_PARSE_END) if(HAVE_PARSE_END) add_definitions(-DHAVE_PARSE_END) @@ -117,8 +117,6 @@ check_symbol_exists(json_object_new_uint64 "json-c/json.h" HAVE_JSON_UINT64) if(HAVE_JSON_UINT64) add_definitions(-DHAVE_JSON_UINT64) endif() -unset(CMAKE_REQUIRED_INCLUDES) -unset(CMAKE_REQUIRED_LIBRARIES) set(LIBRARIES "") @@ -237,11 +235,10 @@ if(ULOOP_SUPPORT) add_library(uloop_lib MODULE lib/uloop.c) set_target_properties(uloop_lib PROPERTIES OUTPUT_NAME uloop PREFIX "") target_link_options(uloop_lib PRIVATE ${UCODE_MODULE_LINK_OPTIONS}) - set(CMAKE_REQUIRED_LIBRARIES ${libubox}) + list(APPEND CMAKE_REQUIRED_LIBRARIES ${libubox}) check_function_exists(uloop_timeout_remaining64 REMAINING64_FUNCTION_EXISTS) check_function_exists(uloop_interval_set INTERVAL_FUNCTION_EXISTS) check_function_exists(uloop_signal_add SIGNAL_FUNCTION_EXISTS) - unset(CMAKE_REQUIRED_LIBRARIES) if(REMAINING64_FUNCTION_EXISTS) target_compile_definitions(uloop_lib PUBLIC HAVE_ULOOP_TIMEOUT_REMAINING64) endif()