mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-20 04:24:36 +08:00
Clang: Record Clang 16.0 flags for our experimental C++ modules support
LLVM/Clang 16.0 now contains official support for what CMake needs.
This commit is contained in:
@@ -1,17 +1,6 @@
|
|||||||
set(CMake_TEST_CXXModules_UUID "a246741c-d067-4019-a8fb-3d16b0c9d1d3")
|
set(CMake_TEST_CXXModules_UUID "a246741c-d067-4019-a8fb-3d16b0c9d1d3")
|
||||||
|
|
||||||
set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1)
|
set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1)
|
||||||
string(CONCAT CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE
|
|
||||||
"${CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS}"
|
|
||||||
" -format=p1689"
|
|
||||||
" --"
|
|
||||||
" <CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS>"
|
|
||||||
" -x c++ <SOURCE> -c -o <OBJECT>"
|
|
||||||
" -MT <DYNDEP_FILE>"
|
|
||||||
" -MD -MF <DEP_FILE>"
|
|
||||||
" > <DYNDEP_FILE>")
|
|
||||||
set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FORMAT "clang")
|
|
||||||
set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FLAG "@<MODULE_MAP_FILE>")
|
|
||||||
|
|
||||||
# Default to C++ extensions being off. Clang's modules support have trouble
|
# Default to C++ extensions being off. Clang's modules support have trouble
|
||||||
# with extensions right now.
|
# with extensions right now.
|
||||||
|
@@ -57,17 +57,36 @@ dependency scanning. This is similar to the Fortran modules support, but
|
|||||||
relies on external tools to scan C++20 translation units for module
|
relies on external tools to scan C++20 translation units for module
|
||||||
dependencies. The approach is described by Kitware's `D1483r1`_ paper.
|
dependencies. The approach is described by Kitware's `D1483r1`_ paper.
|
||||||
|
|
||||||
The ``CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP`` variable can be set to ``1``
|
In order to activate CMake's experimental support for C++20 module
|
||||||
in order to activate this undocumented experimental infrastructure. This
|
dependencies, set the following variables:
|
||||||
is **intended to make the functionality available to compiler writers** so
|
|
||||||
they can use it to develop and test their dependency scanning tool.
|
|
||||||
The ``CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE`` variable must also be set
|
|
||||||
to tell CMake how to invoke the C++20 module dependency scanning tool.
|
|
||||||
|
|
||||||
MSVC 19.34 (provided with Visual Studio 17.4) and above contains the support
|
``CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API``
|
||||||
that CMake needs and has these variables already set up as required and only
|
Set this to the UUID documented above.
|
||||||
the UUID and the ``CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP`` variables need to be
|
|
||||||
set.
|
``CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP``
|
||||||
|
Set this to ``1`` in order to activate this undocumented experimental
|
||||||
|
infrastructure. This is **intended to make the functionality available
|
||||||
|
to compiler writers** so they can use it to develop and test their
|
||||||
|
dependency scanning tool.
|
||||||
|
|
||||||
|
Some compilers already have support for module dependency scanning:
|
||||||
|
|
||||||
|
* MSVC 19.34 and newer (provided with Visual Studio 17.4 and newer)
|
||||||
|
* LLVM/Clang 16.0 and newer
|
||||||
|
|
||||||
|
For those, only the above variables need to be set by project code.
|
||||||
|
For compilers with in-development support, additional variables must
|
||||||
|
be set as follows.
|
||||||
|
|
||||||
|
``CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE``
|
||||||
|
Set this to tell CMake how to invoke the C++20 module dependency
|
||||||
|
scanning tool.
|
||||||
|
|
||||||
|
``CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FORMAT``
|
||||||
|
Set this for compilers that generate module maps. See below.
|
||||||
|
|
||||||
|
``CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FLAG``
|
||||||
|
Set this for compilers that generate module maps. See below.
|
||||||
|
|
||||||
For example, add code like the following to a test project:
|
For example, add code like the following to a test project:
|
||||||
|
|
||||||
|
@@ -29,3 +29,17 @@ if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC")
|
|||||||
set(CMAKE_CXX_DEPENDS_USE_COMPILER TRUE)
|
set(CMAKE_CXX_DEPENDS_USE_COMPILER TRUE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0)
|
||||||
|
string(CONCAT CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE
|
||||||
|
"${CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS}"
|
||||||
|
" -format=p1689"
|
||||||
|
" --"
|
||||||
|
" <CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS>"
|
||||||
|
" -x c++ <SOURCE> -c -o <OBJECT>"
|
||||||
|
" -MT <DYNDEP_FILE>"
|
||||||
|
" -MD -MF <DEP_FILE>"
|
||||||
|
" > <DYNDEP_FILE>")
|
||||||
|
set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FORMAT "clang")
|
||||||
|
set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FLAG "@<MODULE_MAP_FILE>")
|
||||||
|
endif ()
|
||||||
|
Reference in New Issue
Block a user