mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-11 15:29:51 -05:00
Enable "-fsized-deallocation" iif deallocation functions are present
On some systems, although "-fsized-deallocation" compiler flag is there, compilation will fail because some deallocation functions are missing. Typically 'operator delete ( void* ptr, std::size_t sz )' is missing on some macOS systems. This will check their presence. On macOS we can have this case when using a compiler that supports the flag, while the OS doesn't have all the deallocation functions. Typically, ::operator delete(ptr, size) appeared in macOS 10.12 Reported error was: error: call to unavailable function 'operator delete': introduced in macOS 10.12
This commit is contained in:
parent
07564d533a
commit
84f245badb
@ -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 <new>
|
||||
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++")
|
||||
|
Loading…
Reference in New Issue
Block a user