summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeParseImplicitIncludeInfo.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-03-27 14:09:22 (GMT)
committerBrad King <brad.king@kitware.com>2019-03-29 12:48:56 (GMT)
commitdad86f1873f6930759795785b5ee4da51ea2050c (patch)
tree9ffb30f99ddfd2680cf8312e20500afa8b0e9883 /Modules/CMakeParseImplicitIncludeInfo.cmake
parentbf02d625325535f485512eba307cff54c08bb257 (diff)
downloadCMake-dad86f1873f6930759795785b5ee4da51ea2050c.zip
CMake-dad86f1873f6930759795785b5ee4da51ea2050c.tar.gz
CMake-dad86f1873f6930759795785b5ee4da51ea2050c.tar.bz2
ParseImplicitIncludeInfo: Canonicalize implicit include dirs
The implicit include directory extraction added by commit 5990ecb741 (Compute implicit include directories from compiler output, 2018-12-07, v3.14.0-rc1~108^2) leaves paths like `/usr/lib/../include` unchanged. Fix the logic to canonicalize such paths (e.g. to `/usr/include`) as we do for implicit link directories already. This is important to ensure the set of implicit directories is represented in the same form as the include directories that will be compared to them. Issue: #19095
Diffstat (limited to 'Modules/CMakeParseImplicitIncludeInfo.cmake')
-rw-r--r--Modules/CMakeParseImplicitIncludeInfo.cmake16
1 files changed, 14 insertions, 2 deletions
diff --git a/Modules/CMakeParseImplicitIncludeInfo.cmake b/Modules/CMakeParseImplicitIncludeInfo.cmake
index 21e24b7..c8d4c5a 100644
--- a/Modules/CMakeParseImplicitIncludeInfo.cmake
+++ b/Modules/CMakeParseImplicitIncludeInfo.cmake
@@ -210,15 +210,27 @@ function(cmake_parse_implicit_include_info text lang dir_var log_var state_var)
endif()
endforeach()
+ set(implicit_dirs "")
+ foreach(d IN LISTS implicit_dirs_tmp)
+ if(IS_ABSOLUTE "${d}")
+ get_filename_component(dir "${d}" ABSOLUTE)
+ list(APPEND implicit_dirs "${dir}")
+ string(APPEND log " collapse include dir [${d}] ==> [${dir}]\n")
+ else()
+ string(APPEND log " skipping relative include dir [${d}]\n")
+ endif()
+ endforeach()
+ list(REMOVE_DUPLICATES implicit_dirs)
+
# Log results.
if(state STREQUAL done)
- string(APPEND log " implicit include dirs: [${implicit_dirs_tmp}]\n")
+ string(APPEND log " implicit include dirs: [${implicit_dirs}]\n")
else()
string(APPEND log " warn: unable to parse implicit include dirs!\n")
endif()
# Return results.
- set(${dir_var} "${implicit_dirs_tmp}" PARENT_SCOPE)
+ set(${dir_var} "${implicit_dirs}" PARENT_SCOPE)
set(${log_var} "${log}" PARENT_SCOPE)
set(${state_var} "${state}" PARENT_SCOPE)