]> git.ipfire.org Git - thirdparty/zlib-ng.git/commit
Fix CMake check for posix_memalign and aligned_alloc
authorlawadr <3211473+lawadr@users.noreply.github.com>
Tue, 4 Apr 2023 13:53:35 +0000 (14:53 +0100)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sat, 15 Apr 2023 13:23:05 +0000 (15:23 +0200)
commit58c76217ecefcbeeccb32189ad27d162450a2e7b
tree60b406ca7b5b761be1e9798e47ec8798391cd50e
parent498ed7905a495c108f05cefaf739518dfed70acf
Fix CMake check for posix_memalign and aligned_alloc

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.
CMakeLists.txt