These two functions were being checked using check_function_exists. This
CMake macro does not check to see if the given function is declared in
any header as it declares its own function prototype and relies on
linking to determine function availability. This causes two issues.
Firstly, it will always succeed when the CMake toolchain file sets
CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY as no linking will take
place. See: https://gitlab.kitware.com/cmake/cmake/-/issues/18121
Secondly, it will not correctly detect macros or inline functions, or
whether the function is even declared in a header at all.
Switch to check_symbol_exists at CMake's recommendation, the logic of
which actually matches the same checks in the configure script.
if(NOT HAVE_FSEEKO)
add_definitions(-DNO_FSEEKO)
endif()
+
check_function_exists(strerror HAVE_STRERROR)
if(NOT HAVE_STRERROR)
add_definitions(-DNO_STRERROR)
endif()
+
set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L)
-check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN)
+check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
if(HAVE_POSIX_MEMALIGN)
add_definitions(-DHAVE_POSIX_MEMALIGN)
endif()
set(CMAKE_REQUIRED_DEFINITIONS)
+
set(CMAKE_REQUIRED_DEFINITIONS -D_ISOC11_SOURCE=1)
-check_function_exists(aligned_alloc HAVE_ALIGNED_ALLOC)
+check_symbol_exists(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
if(HAVE_ALIGNED_ALLOC)
add_definitions(-DHAVE_ALIGNED_ALLOC)
endif()