cmake: Fix AutoInclude workaround always being used irrespective of version.

Also fixes Interrogate's reliance on the INTERFACE_INCLUDE_DIRECTORIES target
property before generation time by using a generator expression to determine
Interrogate's include flags.
This commit is contained in:
Sam Edwards 2016-12-01 02:36:40 -08:00
parent f45b4a7917
commit e58697bee4
2 changed files with 12 additions and 18 deletions

View File

@ -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$<JOIN:$<TARGET_PROPERTY:${target},INTERFACE_INCLUDE_DIRECTORIES>,\t-I>")
# The above must also be included when compiling the resulting _igate.cxx file:
include_directories(${include_dirs})
include_directories("$<TARGET_PROPERTY:${target},INTERFACE_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

View File

@ -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()