Skip to content

Commit 14d4bee

Browse files
committed
fix: include the includes of a system lib in BUILD_INTERFACE
1 parent 8195bdf commit 14d4bee

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/SystemLink.cmake

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,23 @@ function(target_include_system_directories target)
1010

1111
foreach(scope IN ITEMS INTERFACE PUBLIC PRIVATE)
1212
foreach(lib_include_dirs IN LISTS ARG_${scope})
13-
if(MSVC)
13+
if(NOT MSVC)
1414
# system includes do not work in MSVC
1515
# awaiting https://gitlab.kitware.com/cmake/cmake/-/issues/18272#
1616
# awaiting https://gitlab.kitware.com/cmake/cmake/-/issues/17904
17-
target_include_directories(${target} ${scope} ${lib_include_dirs})
17+
set(_SYSTEM SYSTEM)
18+
endif()
19+
if(${scope} STREQUAL "INTERFACE" OR ${scope} STREQUAL "PUBLIC")
20+
target_include_directories(
21+
${target}
22+
${_SYSTEM}
23+
${scope}
24+
"$<BUILD_INTERFACE:${lib_include_dirs}>"
25+
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}>")
1826
else()
1927
target_include_directories(
2028
${target}
21-
SYSTEM
29+
${_SYSTEM}
2230
${scope}
2331
${lib_include_dirs})
2432
endif()
@@ -39,7 +47,7 @@ function(
3947
if(lib_include_dirs)
4048
target_include_system_directories(${target} ${scope} ${lib_include_dirs})
4149
else()
42-
message(STATUS "${lib} library does not have the INTERFACE_INCLUDE_DIRECTORIES property.")
50+
message(TRACE "${lib} library does not have the INTERFACE_INCLUDE_DIRECTORIES property.")
4351
endif()
4452
endif()
4553
endfunction()

0 commit comments

Comments
 (0)