From a42f1a49a4892fbae168c5c63edb83abd8a10c6d Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 29 Aug 2019 23:09:28 -0600 Subject: [PATCH] CMake: Interrogate needs -DNDEBUG when -DNDEBUG is passed as a flag Some buildsystems (Gentoo's Portage, to be specific) are very roughshod about how they use CMake, and might bypass the "configuration types" system altogether, passing their own release flags instead. This change detects that and ensures that Interrogate picks up the NDEBUG flag when it's specified manually. --- cmake/macros/Interrogate.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/macros/Interrogate.cmake b/cmake/macros/Interrogate.cmake index 6cad20cac6..399b3acd20 100644 --- a/cmake/macros/Interrogate.cmake +++ b/cmake/macros/Interrogate.cmake @@ -228,6 +228,11 @@ function(interrogate_sources target output database language_flags) endif() endforeach(build_type) + # In case the user (or a distro buildsystem) is throwing NDEBUG in by hand: + if(CMAKE_CXX_FLAGS MATCHES ".*NDEBUG.*") + list(APPEND define_flags "-DNDEBUG") + endif() + get_filename_component(output_directory "${output}" DIRECTORY) get_filename_component(database_directory "${database}" DIRECTORY)