mirror of
https://github.com/lifegpc/c-utils.git
synced 2026-06-06 21:28:50 +08:00
24 lines
1.1 KiB
CMake
24 lines
1.1 KiB
CMake
function(test_strerror_r OUTPUT_VAR HAVE_GNU_SOURCE)
|
|
if (DEFINED STRERROR_R_TEST_RESULT_CACHE)
|
|
if (STRERROR_R_TEST_RESULT_CACHE)
|
|
set(${OUTPUT_VAR} 1 PARENT_SCOPE)
|
|
else()
|
|
unset(${OUTPUT_VAR} PARENT_SCOPE)
|
|
endif()
|
|
message(STATUS "Check strerror_r is GNU complatable - ${STRERROR_R_TEST_RESULT_CACHE} (Cached)")
|
|
else()
|
|
message(STATUS "Check strerror_r is GNU complatable")
|
|
if (HAVE_GNU_SOURCE)
|
|
set(TMP_DEF -D_GNU_SOURCE)
|
|
endif()
|
|
try_compile(STRERROR_R_TEST_RESULT "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/test_strerror_r.c" COMPILE_DEFINITIONS -Werror=int-conversion ${TMP_DEF})
|
|
set(STRERROR_R_TEST_RESULT_CACHE ${STRERROR_R_TEST_RESULT} CACHE BOOL "Is strerror_r is GNU complatable.")
|
|
if (STRERROR_R_TEST_RESULT)
|
|
set(${OUTPUT_VAR} 1 PARENT_SCOPE)
|
|
else()
|
|
unset(${OUTPUT_VAR} PARENT_SCOPE)
|
|
endif()
|
|
message(STATUS "Check strerror_r is GNU complatable - ${STRERROR_R_TEST_RESULT}")
|
|
endif()
|
|
endfunction()
|