Skip to content

Commit

Permalink
build: fix symbol and library detection
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jow- committed Apr 24, 2024
1 parent 6613368 commit a0ad1d1
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 "")

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit a0ad1d1

Please sign in to comment.