diff options
author | Petr Hosek <phosek@google.com> | 2022-03-28 14:12:23 -0700 |
---|---|---|
committer | Petr Hosek <phosek@google.com> | 2022-06-12 22:17:50 +0000 |
commit | 186a13f647acac623898bcffa4b966624d2358ba (patch) | |
tree | ab28c080432605b4468af5368f337a742db32e69 /runtimes | |
parent | d378268ead93c85803c270277f0243737b536ae7 (diff) | |
download | llvm-186a13f647acac623898bcffa4b966624d2358ba.zip llvm-186a13f647acac623898bcffa4b966624d2358ba.tar.gz llvm-186a13f647acac623898bcffa4b966624d2358ba.tar.bz2 |
[CMake][libcxx] Use target_include_directories for libc++ headers
This is the idiomatic way to handle include directories in CMake.
Differential Revision: https://reviews.llvm.org/D122614
Diffstat (limited to 'runtimes')
-rw-r--r-- | runtimes/CMakeLists.txt | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt index c8766b9..35b9b65 100644 --- a/runtimes/CMakeLists.txt +++ b/runtimes/CMakeLists.txt @@ -73,6 +73,26 @@ include(LLVMCheckCompilerLinkerFlag) include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) +# CMake omits default compiler include paths, but in runtimes build, we use +# -nostdinc and -nostdinc++ and control include paths manually so this behavior +# is undesirable. Filtering CMAKE_{LANG}_IMPLICIT_INCLUDE_DIRECTORIES to remove +# paths that are inside the build directory disables this behavior. +# +# See https://gitlab.kitware.com/cmake/cmake/-/issues/19227 for further details. + +function(filter_prefixed list prefix outvar) + foreach(str ${list}) + string(FIND "${str}" "${prefix}" out) + if(NOT "${out}" EQUAL 0) + list(APPEND result ${str}) + endif() + endforeach() + set(${outvar} ${result} PARENT_SCOPE) +endfunction() + +filter_prefixed("${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES) +filter_prefixed("${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES) +filter_prefixed("${CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES) check_c_compiler_flag("" LLVM_RUNTIMES_LINKING_WORKS) if (NOT LLVM_RUNTIMES_LINKING_WORKS) |