diff options
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 11 | ||||
-rw-r--r-- | Tests/RunCMake/CXXModules/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt | 8 | ||||
-rw-r--r-- | Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.ixx (renamed from Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.cxx) | 0 | ||||
-rw-r--r-- | Tests/RunCMake/CXXModules/examples/vs-without-flags/CMakeLists.txt | 22 | ||||
-rw-r--r-- | Tests/RunCMake/CXXModules/examples/vs-without-flags/main.cxx | 6 | ||||
-rw-r--r-- | Tests/RunCMake/CXXModules/examples/vs-without-flags/module.cxx | 6 |
7 files changed, 46 insertions, 8 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 4860d9a..708cbaf 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -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() diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake index cd7527a..abede44 100644 --- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake @@ -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) diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt index 47be1d9..110e411 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt @@ -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 diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.cxx b/Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.ixx index b47510b..b47510b 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.cxx +++ b/Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.ixx diff --git a/Tests/RunCMake/CXXModules/examples/vs-without-flags/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/vs-without-flags/CMakeLists.txt new file mode 100644 index 0000000..0d18a66 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/vs-without-flags/CMakeLists.txt @@ -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) diff --git a/Tests/RunCMake/CXXModules/examples/vs-without-flags/main.cxx b/Tests/RunCMake/CXXModules/examples/vs-without-flags/main.cxx new file mode 100644 index 0000000..239ab00 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/vs-without-flags/main.cxx @@ -0,0 +1,6 @@ +import mod; + +int main(int argc, char* argv[]) +{ + return f(); +} diff --git a/Tests/RunCMake/CXXModules/examples/vs-without-flags/module.cxx b/Tests/RunCMake/CXXModules/examples/vs-without-flags/module.cxx new file mode 100644 index 0000000..27a61a6 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/vs-without-flags/module.cxx @@ -0,0 +1,6 @@ +export module mod; + +export int f() +{ + return 0; +} |