mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-13 01:29:02 -05:00
Merge topic 'vs-scan-for-modules' into release-3.28
405dc7d19cTests/CXXModules/scan_properties: use `ixx` extension029ddc3410cmVisualStudio10TargetGenerator: always specify scanning6c9614cbf4Tests/CXXModules: add a test case for VS generation without flags34f4423851cmVisualStudio10TargetGenerator: fix typo in flag name Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !9104
This commit is contained in:
@@ -2784,7 +2784,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
|
||||
isCppModule = true;
|
||||
if (shouldScanForModules &&
|
||||
this->GlobalGenerator->IsScanDependenciesSupported()) {
|
||||
// ScanSourceforModuleDependencies uses 'cl /scanDependencies' and
|
||||
// ScanSourceForModuleDependencies uses 'cl /scanDependencies' and
|
||||
// can distinguish module interface units and internal partitions.
|
||||
compileAsPerConfig = "CompileAsCpp";
|
||||
} else {
|
||||
@@ -2827,7 +2827,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
|
||||
// use them
|
||||
if (!flags.empty() || !options.empty() || !configDefines.empty() ||
|
||||
!includes.empty() || compileAsPerConfig || noWinRT ||
|
||||
!options.empty() || needsPCHFlags) {
|
||||
!options.empty() || needsPCHFlags || shouldScanForModules) {
|
||||
cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
|
||||
cmIDEFlagTable const* flagtable = nullptr;
|
||||
const std::string& srclang = source->GetLanguage();
|
||||
@@ -2856,9 +2856,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
|
||||
clOptions.AddFlag("CompileAs", compileAsPerConfig);
|
||||
}
|
||||
if (shouldScanForModules) {
|
||||
clOptions.AddFlag("ScanSourceforModuleDependencies", "true");
|
||||
} else {
|
||||
clOptions.AddFlag("ScanSourceforModuleDependencies", "false");
|
||||
clOptions.AddFlag("ScanSourceForModuleDependencies", "true");
|
||||
}
|
||||
if (noWinRT) {
|
||||
clOptions.AddFlag("CompileAsWinRT", "false");
|
||||
@@ -3564,6 +3562,9 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
|
||||
e2.Element("AdditionalUsingDirectories", dirs);
|
||||
}
|
||||
}
|
||||
|
||||
// Disable C++ source scanning by default.
|
||||
e2.Element("ScanSourceForModuleDependencies", "false");
|
||||
}
|
||||
|
||||
bool cmVisualStudio10TargetGenerator::ComputeRcOptions()
|
||||
|
||||
@@ -170,6 +170,7 @@ run_cxx_module_test(scan-with-pch)
|
||||
# Tests which use named modules.
|
||||
if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(simple)
|
||||
run_cxx_module_test(vs-without-flags)
|
||||
run_cxx_module_test(library library-static -DBUILD_SHARED_LIBS=OFF)
|
||||
run_cxx_module_test(unity-build)
|
||||
run_cxx_module_test(object-library)
|
||||
|
||||
@@ -18,8 +18,10 @@ string(REPLACE "<DEFINES>" "<DEFINES> -DCMAKE_SCANNED_THIS_SOURCE"
|
||||
|
||||
set_property(SOURCE always_scan.cxx
|
||||
PROPERTY CXX_SCAN_FOR_MODULES 1)
|
||||
set_property(SOURCE never_scan.cxx
|
||||
set_property(SOURCE never_scan.ixx
|
||||
PROPERTY CXX_SCAN_FOR_MODULES 0)
|
||||
set_property(SOURCE never_scan.ixx
|
||||
PROPERTY LANGUAGE CXX)
|
||||
|
||||
add_executable(scans_everything)
|
||||
target_sources(scans_everything
|
||||
@@ -27,7 +29,7 @@ target_sources(scans_everything
|
||||
main.cxx
|
||||
join.cxx
|
||||
always_scan.cxx
|
||||
never_scan.cxx
|
||||
never_scan.ixx
|
||||
PRIVATE
|
||||
FILE_SET CXX_MODULES
|
||||
BASE_DIRS
|
||||
@@ -46,7 +48,7 @@ target_sources(no_scan_everything
|
||||
main.cxx
|
||||
join.cxx
|
||||
always_scan.cxx
|
||||
never_scan.cxx
|
||||
never_scan.ixx
|
||||
PRIVATE
|
||||
FILE_SET CXX_MODULES
|
||||
BASE_DIRS
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
cmake_minimum_required(VERSION 3.28)
|
||||
project(cxx_modules_vs_without_flags CXX)
|
||||
|
||||
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
|
||||
|
||||
add_executable(vs_without_flags)
|
||||
target_sources(vs_without_flags
|
||||
PRIVATE
|
||||
main.cxx
|
||||
PRIVATE
|
||||
FILE_SET CXX_MODULES
|
||||
BASE_DIRS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
FILES
|
||||
module.cxx)
|
||||
|
||||
add_test(NAME vs_without_flags COMMAND vs_without_flags)
|
||||
@@ -0,0 +1,6 @@
|
||||
import mod;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
return f();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export module mod;
|
||||
|
||||
export int f()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user