diff options
author | Chris Robinson <[email protected]> | 2020-05-19 08:13:13 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-05-19 08:13:13 -0700 |
commit | 463591663c2421b3436edc446d173380d6a6e106 (patch) | |
tree | f8e738f589a63fc7392eb2ea5e1570672bb24bac /CMakeLists.txt | |
parent | 400a108eade05d616ed0560024b7fd6f5be5fd1d (diff) |
Check that aligned_alloc is available with cmake
Some compilers support C++17 even on targets that lack required functions.
Projects that want to force C++17 will then run into a problem with
std::aligned_alloc not existing on those targets, so it needs to be explicitly
checked for. The alternative is to simply never use it even when it would be
available.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 208a275f..64c8116e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -449,9 +449,16 @@ IF(HAVE_INTRIN_H) }" HAVE_BITSCANFORWARD_INTRINSIC) ENDIF() -CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN) -CHECK_SYMBOL_EXISTS(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC) -CHECK_SYMBOL_EXISTS(proc_pidpath libproc.h HAVE_PROC_PIDPATH) +check_cxx_source_compiles("#include <cstdlib> +int main() +{ + void *ptr{std::aligned_alloc(alignof(int), sizeof(int))}; + std::free(ptr); + return 0; +}" HAVE_STD_ALIGNED_ALLOC) +check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN) +check_symbol_exists(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC) +check_symbol_exists(proc_pidpath libproc.h HAVE_PROC_PIDPATH) IF(NOT WIN32) # We need pthreads outside of Windows, for semaphores. It's also used to |