Skip to content

Commit efc4cd7

Browse files
committed
[FIXUP] Better document a workaround
1 parent 3b303a9 commit efc4cd7

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

cmake/module/CrossPkgConfig.cmake

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@
55
find_package(PkgConfig REQUIRED)
66

77
function(remove_isystem_from_include_directories_internal target)
8+
#[=[
9+
A workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/20652.
10+
11+
When the pkg-config provides CFLAGS with -isystem options, for instance:
12+
13+
$ pkg-config --cflags-only-I libzmq
14+
-isystem /usr/include/mit-krb5 -I/usr/include/pgm-5.3 -I/usr/include/libxml2
15+
16+
an old CMake fails to parse them properly and the INTERFACE_INCLUDE_DIRECTORIES
17+
property contains "-isystem" as a separated element:
18+
19+
-isystem;/usr/include/mit-krb5;/usr/include/pgm-5.3;/usr/include/libxml2
20+
21+
which ends with an error "Imported target includes non-existent path".
22+
23+
Fixing by removing the "-isystem" element from the INTERFACE_INCLUDE_DIRECTORIES.
24+
]=]
25+
826
get_target_property(include_directories ${target} INTERFACE_INCLUDE_DIRECTORIES)
927
if(include_directories)
1028
list(REMOVE_ITEM include_directories -isystem)
@@ -25,7 +43,6 @@ macro(cross_pkg_check_modules prefix)
2543
pkg_check_modules(${prefix} ${ARGN})
2644
endif()
2745

28-
# A workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/20652.
2946
if(CMAKE_VERSION VERSION_LESS 3.17.3 AND TARGET PkgConfig::${prefix})
3047
remove_isystem_from_include_directories_internal(PkgConfig::${prefix})
3148
endif()

0 commit comments

Comments
 (0)