[libcxx-commits] [PATCH] D122614: [CMake][libcxx] Use target_include_directories for libc++ headers
Petr Hosek via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Mar 28 14:14:06 PDT 2022
phosek created this revision.
phosek added reviewers: ldionne, smeenai, beanz.
Herald added a subscriber: mgorny.
Herald added a project: All.
phosek requested review of this revision.
Herald added projects: libc++, libc++abi.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
Herald added a reviewer: libc++abi.
This is the idiomatic way to handle include directories in CMake.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D122614
Files:
libcxx/include/CMakeLists.txt
runtimes/CMakeLists.txt
Index: runtimes/CMakeLists.txt
===================================================================
--- runtimes/CMakeLists.txt
+++ runtimes/CMakeLists.txt
@@ -92,6 +92,11 @@
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
+# See https://gitlab.kitware.com/cmake/cmake/-/issues/19227 to why this is needed.
+get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
+foreach(language IN_LIST languages)
+ set(CMAKE_${language}_IMPLICIT_INCLUDE_DIRECTORIES "")
+endforeach()
check_c_compiler_flag("" LLVM_RUNTIMES_LINKING_WORKS)
if (NOT LLVM_RUNTIMES_LINKING_WORKS)
Index: libcxx/include/CMakeLists.txt
===================================================================
--- libcxx/include/CMakeLists.txt
+++ libcxx/include/CMakeLists.txt
@@ -577,14 +577,8 @@
add_library(cxx-headers INTERFACE)
add_dependencies(cxx-headers generate-cxx-headers ${LIBCXX_CXX_ABI_HEADER_TARGET})
-# TODO: Use target_include_directories once we figure out why that breaks the runtimes build
-if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
- target_compile_options(cxx-headers INTERFACE /I${LIBCXX_GENERATED_INCLUDE_DIR}
- INTERFACE /I${LIBCXX_GENERATED_INCLUDE_TARGET_DIR})
-else()
- target_compile_options(cxx-headers INTERFACE -I${LIBCXX_GENERATED_INCLUDE_DIR}
- INTERFACE -I${LIBCXX_GENERATED_INCLUDE_TARGET_DIR})
-endif()
+target_include_directories(cxx-headers INTERFACE ${LIBCXX_GENERATED_INCLUDE_DIR}
+ ${LIBCXX_GENERATED_INCLUDE_TARGET_DIR})
if (LIBCXX_INSTALL_HEADERS)
foreach(file ${files})
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122614.418701.patch
Type: text/x-patch
Size: 1677 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220328/8fde4004/attachment.bin>
More information about the libcxx-commits
mailing list