mirror of
https://github.com/lifegpc/c-utils.git
synced 2026-06-06 13:18:57 +08:00
20 lines
1006 B
CMake
20 lines
1006 B
CMake
function(test_strerror_r OUTPUT_VAR HAVE_GNU_SOURCE)
|
|
if (DEFINED STRERROR_R_TEST_RESULT_CACHE)
|
|
set(${OUTPUT_VAR} ${STRERROR_R_TEST_RESULT_CACHE} PARENT_SCOPE)
|
|
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()
|