From 57944c58d176d0932cf36891797c61699c8c518e Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 31 Jan 2014 13:30:47 -0700 Subject: [PATCH] CMake: Invoke Interrogate with the same compiler definitions as the source itself. --- cmake/macros/Interrogate.cmake | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cmake/macros/Interrogate.cmake b/cmake/macros/Interrogate.cmake index 5c3877b1e4..3dce5256b0 100644 --- a/cmake/macros/Interrogate.cmake +++ b/cmake/macros/Interrogate.cmake @@ -148,6 +148,19 @@ function(interrogate_sources target output database module) # The above must also be included when compiling the resulting _igate.cxx file: include_directories(${include_dirs}) + # Get the compiler definition flags. These must be passed to Interrogate + # in the same way that they are passed to the compiler so that Interrogate + # will preprocess each file in the same way. + set(define_flags) + get_target_property(target_defines "${target}" COMPILE_DEFINITIONS) + foreach(target_define ${target_defines}) + list(APPEND define_flags "-D${target_define}") + endforeach(target_define) + # If this is a release build that has NDEBUG defined, we need that too: + string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type) + if("${CMAKE_CXX_FLAGS_${build_type}}" MATCHES ".*NDEBUG.*") + list(APPEND define_flags "-DNDEBUG") + endif() add_custom_command( OUTPUT "${output}" "${database}" @@ -155,7 +168,9 @@ function(interrogate_sources target output database module) -oc "${output}" -od "${database}" -srcdir "${srcdir}" - -module ${module} -library ${target} ${IGATE_FLAGS} + -module ${module} -library ${target} + ${IGATE_FLAGS} + ${define_flags} -S "${PROJECT_BINARY_DIR}/include" -S "${PROJECT_SOURCE_DIR}/dtool/src/parser-inc" -S "${PROJECT_BINARY_DIR}/include/parser-inc"