mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
FILE_SET: Add CXX_SCAN_FOR_MODULES property for per-file-set scanning control
This is more specific than both the target property and the directory-wide source file property of the same name.
This commit is contained in:
@@ -50,8 +50,11 @@ scan or not is used.
|
||||
be scanned.
|
||||
- If the target does not use at least C++ 20, it will not be scanned.
|
||||
- If the source file is not the language ``CXX``, it will not be scanned.
|
||||
- If the :prop_sf:`CXX_SCAN_FOR_MODULES` source file property is set, its
|
||||
- If the source file belongs to a file set that is not of type ``CXX_MODULES``,
|
||||
and the :prop_fs:`CXX_SCAN_FOR_MODULES` file set property is set, its
|
||||
value will be used.
|
||||
- If the :prop_sf:`CXX_SCAN_FOR_MODULES` source file property is set in the
|
||||
target's directory, its value will be used.
|
||||
- If the :prop_tgt:`CXX_SCAN_FOR_MODULES` target property is set, its value
|
||||
will be used. Set the :variable:`CMAKE_CXX_SCAN_FOR_MODULES` variable
|
||||
to initialize this property on all targets as they are created.
|
||||
|
||||
@@ -543,6 +543,7 @@ Properties on File Sets
|
||||
/prop_fs/BASE_DIRS
|
||||
/prop_fs/COMPILE_DEFINITIONS
|
||||
/prop_fs/COMPILE_OPTIONS
|
||||
/prop_fs/CXX_SCAN_FOR_MODULES
|
||||
/prop_fs/INCLUDE_DIRECTORIES
|
||||
/prop_fs/INTERFACE_COMPILE_DEFINITIONS
|
||||
/prop_fs/INTERFACE_COMPILE_OPTIONS
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
CXX_SCAN_FOR_MODULES
|
||||
--------------------
|
||||
|
||||
.. versionadded:: 4.4
|
||||
|
||||
``CXX_SCAN_FOR_MODULES`` is a boolean specifying whether CMake will scan the
|
||||
file set's sources for C++ module dependencies. See also the
|
||||
:prop_sf:`CXX_SCAN_FOR_MODULES` source file property and the
|
||||
:prop_tgt:`CXX_SCAN_FOR_MODULES` target property settings.
|
||||
|
||||
When this property is set ``ON``, CMake will scan the file set's sources at
|
||||
build time and add module dependency information to the compile line as
|
||||
necessary. When this property is set ``OFF``, CMake will not scan the sources
|
||||
at build time. When this property is unset, the
|
||||
:prop_sf:`CXX_SCAN_FOR_MODULES` source file property and
|
||||
:prop_tgt:`CXX_SCAN_FOR_MODULES` target property are consulted, in that order.
|
||||
|
||||
Note that scanning is only performed if C++20 or higher is enabled for the
|
||||
target and the source uses the ``CXX`` language. Scanning for modules in
|
||||
sources belonging to file sets of type ``CXX_MODULES`` is always performed.
|
||||
@@ -5,12 +5,14 @@ CXX_SCAN_FOR_MODULES
|
||||
|
||||
``CXX_SCAN_FOR_MODULES`` is a boolean specifying whether CMake will scan the
|
||||
source for C++ module dependencies. See also the
|
||||
:prop_tgt:`CXX_SCAN_FOR_MODULES` for target-wide settings.
|
||||
:prop_fs:`CXX_SCAN_FOR_MODULES` file set property which, if set,
|
||||
overrides the per-source settings and the
|
||||
:prop_tgt:`CXX_SCAN_FOR_MODULES` target property.
|
||||
|
||||
When this property is set ``ON``, CMake will scan the source at build time and
|
||||
add module dependency information to the compile line as necessary. When this
|
||||
property is set ``OFF``, CMake will not scan the source at build time. When
|
||||
this property is unset, the :prop_tgt:`CXX_SCAN_FOR_MODULES` property is
|
||||
this property is unset, the :prop_tgt:`CXX_SCAN_FOR_MODULES` target property is
|
||||
consulted.
|
||||
|
||||
Note that scanning is only performed if C++20 or higher is enabled for the
|
||||
|
||||
@@ -5,7 +5,8 @@ CXX_SCAN_FOR_MODULES
|
||||
|
||||
``CXX_SCAN_FOR_MODULES`` is a boolean specifying whether CMake will scan C++
|
||||
sources in the target for module dependencies. See also the
|
||||
:prop_sf:`CXX_SCAN_FOR_MODULES` for per-source settings which, if set,
|
||||
:prop_sf:`CXX_SCAN_FOR_MODULES` for per-source settings and
|
||||
:prop_fs:`CXX_SCAN_FOR_MODULES` for file set settings. If either is set, it
|
||||
overrides the target-wide settings.
|
||||
|
||||
This property is initialized by the value of the
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
FILE_SET-CXX_SCAN_FOR_MODULES
|
||||
-----------------------------
|
||||
|
||||
* :ref:`File sets <file sets>` learned to support the
|
||||
:prop_fs:`CXX_SCAN_FOR_MODULES` property.
|
||||
@@ -6050,6 +6050,12 @@ bool cmGeneratorTarget::NeedDyndepForSource(std::string const& lang,
|
||||
if (targetDyndep == CxxModuleSupport::Unavailable) {
|
||||
return false;
|
||||
}
|
||||
if (fs) {
|
||||
auto const fsProp = fs->GetProperty("CXX_SCAN_FOR_MODULES");
|
||||
if (fsProp.IsSet()) {
|
||||
return fsProp.IsOn();
|
||||
}
|
||||
}
|
||||
auto const sfProp = sf->GetProperty("CXX_SCAN_FOR_MODULES");
|
||||
if (sfProp.IsSet()) {
|
||||
return sfProp.IsOn();
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,17 @@
|
||||
(CMake Error in CMakeLists\.txt:
|
||||
The target named "noscanning-fs-property" has C\+\+ sources that may use
|
||||
modules, but the compiler does not provide a way to discover the import
|
||||
graph dependencies\. See the cmake-cxxmodules\(7\) manual for details\. Use
|
||||
the CMAKE_CXX_SCAN_FOR_MODULES variable to enable or disable scanning\.
|
||||
|CMake Error in CMakeLists\.txt:
|
||||
The target named "noscanning-fs-property" has C\+\+ sources that may use
|
||||
modules, but modules are not supported by this generator:
|
||||
|
||||
[^
|
||||
]+
|
||||
|
||||
Modules are supported only by Ninja, Ninja Multi-Config, and Visual Studio
|
||||
generators for VS 17\.4 and newer\. See the cmake-cxxmodules\(7\) manual for
|
||||
details\. Use the CMAKE_CXX_SCAN_FOR_MODULES variable to enable or disable
|
||||
scanning\.
|
||||
)
|
||||
@@ -0,0 +1,16 @@
|
||||
enable_language(CXX)
|
||||
unset(CMAKE_CXX_SCANDEP_SOURCE)
|
||||
|
||||
add_executable(noscanning-fs-property)
|
||||
target_sources(noscanning-fs-property PRIVATE
|
||||
FILE_SET SOURCES FILES sources/module-use.cxx)
|
||||
set_target_properties(noscanning-fs-property
|
||||
PROPERTIES
|
||||
CXX_STANDARD 20
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
CXX_SCAN_FOR_MODULES 0)
|
||||
set_source_files_properties(sources/module-use.cxx
|
||||
PROPERTIES
|
||||
CXX_SCAN_FOR_MODULES 0)
|
||||
set_property(FILE_SET SOURCES TARGET noscanning-fs-property
|
||||
PROPERTY CXX_SCAN_FOR_MODULES 1)
|
||||
@@ -22,6 +22,7 @@ if ("cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
|
||||
endif ()
|
||||
|
||||
run_cmake(NoScanningSourceFileProperty)
|
||||
run_cmake(NoScanningFileSetProperty)
|
||||
run_cmake(NoScanningTargetProperty)
|
||||
run_cmake(NoScanningVariable)
|
||||
run_cmake(CMP0155-OLD)
|
||||
|
||||
Reference in New Issue
Block a user