diff --git a/CMakeLists.txt b/CMakeLists.txt index c6c0b45b6..216a03a17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -318,7 +318,18 @@ set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -check_add_gcc_compiler_flag("-fsized-deallocation" CXX) +check_cxx_compiler_flag("-fsized-deallocation" CXX_HAS_fsized_deallocation) +if(CXX_HAS_fsized_deallocation) + # Do additional check: the deallocation functions must be there too. + set(CMAKE_REQUIRED_FLAGS "-fsized-deallocation") + check_cxx_source_compiles("#include + int main() { void * ptr = nullptr; std::size_t size = 1; ::operator delete(ptr, size); }" + HAVE_DEALLOCATION_FUNCTIONS) + if(HAVE_DEALLOCATION_FUNCTIONS) + check_add_gcc_compiler_flag("-fsized-deallocation" CXX) + endif() + unset(CMAKE_REQUIRED_FLAGS) +endif() if(APPLE AND CMAKE_COMPILER_IS_CLANGXX) add_gcc_compiler_cxxflags("-stdlib=libc++")