diff --git a/cmake/macros/Interrogate.cmake b/cmake/macros/Interrogate.cmake index 6387a5ca30..0305d04218 100644 --- a/cmake/macros/Interrogate.cmake +++ b/cmake/macros/Interrogate.cmake @@ -167,18 +167,13 @@ function(interrogate_sources target output database module) endforeach(source) # Interrogate also needs the include paths, so we'll extract them from the - # target: - set(include_flags) - get_target_property(include_dirs "${target}" INTERFACE_INCLUDE_DIRECTORIES) - foreach(include_dir ${include_dirs}) - # To keep the command-line small, also make this relative: - # Note that Interrogate does NOT handle -I paths relative to -srcdir, so - # we make them relative to the directory where it's invoked. - file(RELATIVE_PATH rel_include_dir "${CMAKE_CURRENT_BINARY_DIR}" "${include_dir}") - list(APPEND include_flags "-I${rel_include_dir}") - endforeach(include_dir) + # target using a generator expression. + # Note, the \t is a workaround for a CMake bug where using a plain space in + # a JOIN will cause it to be escaped. Tabs are not escaped and will + # separate correctly. + set(include_flags "-I$,\t-I>") # The above must also be included when compiling the resulting _igate.cxx file: - include_directories(${include_dirs}) + include_directories("$") # 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 diff --git a/cmake/modules/AutoInclude.cmake b/cmake/modules/AutoInclude.cmake index 40916f1e68..c703734bfc 100644 --- a/cmake/modules/AutoInclude.cmake +++ b/cmake/modules/AutoInclude.cmake @@ -6,10 +6,7 @@ # Emulate CMake 2.8.11's CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE behavior if # this version doesn't define CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE. -# CFSworks's version of CMake (2.8.12) doesn't have -# CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE even though it should be supported, -# hence test if it's defined (as either ON or OFF) before trying to use it. -if("${CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE}" STREQUAL "") +if(CMAKE_VERSION VERSION_LESS 2.8.11) # Replace some built-in functions in order to extend their functionality. function(add_library target) _add_library(${target} ${ARGN}) @@ -26,10 +23,12 @@ if("${CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE}" STREQUAL "") get_target_property(target_interface_dirs "${target}" INTERFACE_INCLUDE_DIRECTORIES) foreach(lib ${ARGN}) - get_target_property(lib_interface_dirs "${lib}" INTERFACE_INCLUDE_DIRECTORIES) + if(TARGET "${lib}") + get_target_property(lib_interface_dirs "${lib}" INTERFACE_INCLUDE_DIRECTORIES) - if(lib_interface_dirs) - list(APPEND interface_dirs ${lib_interface_dirs}) + if(lib_interface_dirs) + list(APPEND interface_dirs ${lib_interface_dirs}) + endif() endif() endforeach()