Skip to content

Commit e58697b

Browse files
committed
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.
1 parent f45b4a7 commit e58697b

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

cmake/macros/Interrogate.cmake

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,13 @@ function(interrogate_sources target output database module)
167167
endforeach(source)
168168

169169
# Interrogate also needs the include paths, so we'll extract them from the
170-
# target:
171-
set(include_flags)
172-
get_target_property(include_dirs "${target}" INTERFACE_INCLUDE_DIRECTORIES)
173-
foreach(include_dir ${include_dirs})
174-
# To keep the command-line small, also make this relative:
175-
# Note that Interrogate does NOT handle -I paths relative to -srcdir, so
176-
# we make them relative to the directory where it's invoked.
177-
file(RELATIVE_PATH rel_include_dir "${CMAKE_CURRENT_BINARY_DIR}" "${include_dir}")
178-
list(APPEND include_flags "-I${rel_include_dir}")
179-
endforeach(include_dir)
170+
# target using a generator expression.
171+
# Note, the \t is a workaround for a CMake bug where using a plain space in
172+
# a JOIN will cause it to be escaped. Tabs are not escaped and will
173+
# separate correctly.
174+
set(include_flags "-I$<JOIN:$<TARGET_PROPERTY:${target},INTERFACE_INCLUDE_DIRECTORIES>,\t-I>")
180175
# The above must also be included when compiling the resulting _igate.cxx file:
181-
include_directories(${include_dirs})
176+
include_directories("$<TARGET_PROPERTY:${target},INTERFACE_INCLUDE_DIRECTORIES>")
182177

183178
# Get the compiler definition flags. These must be passed to Interrogate
184179
# in the same way that they are passed to the compiler so that Interrogate

cmake/modules/AutoInclude.cmake

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66

77
# Emulate CMake 2.8.11's CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE behavior if
88
# this version doesn't define CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.
9-
# CFSworks's version of CMake (2.8.12) doesn't have
10-
# CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE even though it should be supported,
11-
# hence test if it's defined (as either ON or OFF) before trying to use it.
12-
if("${CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE}" STREQUAL "")
9+
if(CMAKE_VERSION VERSION_LESS 2.8.11)
1310
# Replace some built-in functions in order to extend their functionality.
1411
function(add_library target)
1512
_add_library(${target} ${ARGN})
@@ -26,10 +23,12 @@ if("${CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE}" STREQUAL "")
2623
get_target_property(target_interface_dirs "${target}" INTERFACE_INCLUDE_DIRECTORIES)
2724

2825
foreach(lib ${ARGN})
29-
get_target_property(lib_interface_dirs "${lib}" INTERFACE_INCLUDE_DIRECTORIES)
26+
if(TARGET "${lib}")
27+
get_target_property(lib_interface_dirs "${lib}" INTERFACE_INCLUDE_DIRECTORIES)
3028

31-
if(lib_interface_dirs)
32-
list(APPEND interface_dirs ${lib_interface_dirs})
29+
if(lib_interface_dirs)
30+
list(APPEND interface_dirs ${lib_interface_dirs})
31+
endif()
3332
endif()
3433
endforeach()
3534

0 commit comments

Comments
 (0)