diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties-stderr.txt b/Tests/RunCMake/CXXModules/examples/scan_properties-stderr.txt index 7d79bad01c..2cb59579b1 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties-stderr.txt +++ b/Tests/RunCMake/CXXModules/examples/scan_properties-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning \(dev\) at CMakeLists.txt:20 \(target_sources\): +CMake Warning \(dev\) at CMakeLists.txt:25 \(target_sources\): CMake's C\+\+ module support is experimental. It is meant only for experimentation and feedback to CMake developers. This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt index 551c55c2f5..f2f1c38bf4 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt @@ -3,6 +3,11 @@ project(scan_properties CXX) include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") +set(scanning_control 1) +if (CMAKE_GENERATOR MATCHES "Visual Studio") + set(scanning_control 0) +endif () + # To detect that not-to-be scanned sources are not scanned, add a `-D` to the # scan flags so that the files can detect whether scanning happened and error # if not. @@ -31,6 +36,7 @@ target_sources(scans_everything module.cxx) target_compile_features(scans_everything PRIVATE cxx_std_20) target_compile_definitions(scans_everything PRIVATE SCAN_AT_TARGET_LEVEL=1) +target_compile_definitions(scans_everything PRIVATE "SCANNING_CONTROL=${scanning_control}") set(CMAKE_CXX_SCAN_FOR_MODULES 0) @@ -49,6 +55,7 @@ target_sources(no_scan_everything module.cxx) target_compile_features(no_scan_everything PRIVATE cxx_std_20) target_compile_definitions(no_scan_everything PRIVATE SCAN_AT_TARGET_LEVEL=0) +target_compile_definitions(no_scan_everything PRIVATE "SCANNING_CONTROL=${scanning_control}") add_test(NAME scanned COMMAND scans_everything) add_test(NAME unscanned COMMAND no_scan_everything) diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties/always_scan.cxx b/Tests/RunCMake/CXXModules/examples/scan_properties/always_scan.cxx index 27087d7b5c..c3d449e5b0 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties/always_scan.cxx +++ b/Tests/RunCMake/CXXModules/examples/scan_properties/always_scan.cxx @@ -1,5 +1,7 @@ -#ifndef CMAKE_SCANNED_THIS_SOURCE -# error "This file should have been scanned" +#if SCANNING_CONTROL +# ifndef CMAKE_SCANNED_THIS_SOURCE +# error "This file should have been scanned" +# endif #endif import M; diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties/join.cxx b/Tests/RunCMake/CXXModules/examples/scan_properties/join.cxx index 8184a403fb..4ba23a68c4 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties/join.cxx +++ b/Tests/RunCMake/CXXModules/examples/scan_properties/join.cxx @@ -1,10 +1,12 @@ -#if SCAN_AT_TARGET_LEVEL -# ifndef CMAKE_SCANNED_THIS_SOURCE -# error "This file should have been scanned" -# endif -#else -# ifdef CMAKE_SCANNED_THIS_SOURCE -# error "This file should not have been scanned" +#if SCANNING_CONTROL +# if SCAN_AT_TARGET_LEVEL +# ifndef CMAKE_SCANNED_THIS_SOURCE +# error "This file should have been scanned" +# endif +# else +# ifdef CMAKE_SCANNED_THIS_SOURCE +# error "This file should not have been scanned" +# endif # endif #endif diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties/main.cxx b/Tests/RunCMake/CXXModules/examples/scan_properties/main.cxx index 81e93f4793..2c7ec3e3c7 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties/main.cxx +++ b/Tests/RunCMake/CXXModules/examples/scan_properties/main.cxx @@ -1,10 +1,12 @@ -#if SCAN_AT_TARGET_LEVEL -# ifndef CMAKE_SCANNED_THIS_SOURCE -# error "This file should have been scanned" -# endif -#else -# ifdef CMAKE_SCANNED_THIS_SOURCE -# error "This file should not have been scanned" +#if SCANNING_CONTROL +# if SCAN_AT_TARGET_LEVEL +# ifndef CMAKE_SCANNED_THIS_SOURCE +# error "This file should have been scanned" +# endif +# else +# ifdef CMAKE_SCANNED_THIS_SOURCE +# error "This file should not have been scanned" +# endif # endif #endif diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties/module.cxx b/Tests/RunCMake/CXXModules/examples/scan_properties/module.cxx index ad1e04dece..fe84261d5f 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties/module.cxx +++ b/Tests/RunCMake/CXXModules/examples/scan_properties/module.cxx @@ -1,5 +1,7 @@ -#ifndef CMAKE_SCANNED_THIS_SOURCE -# error "This file should have been scanned" +#if SCANNING_CONTROL +# ifndef CMAKE_SCANNED_THIS_SOURCE +# error "This file should have been scanned" +# endif #endif export module M; diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.cxx b/Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.cxx index 8374110cee..b47510bfc9 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.cxx +++ b/Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.cxx @@ -1,5 +1,7 @@ -#ifdef CMAKE_SCANNED_THIS_SOURCE -# error "This file should not have been scanned" +#if SCANNING_CONTROL +# ifdef CMAKE_SCANNED_THIS_SOURCE +# error "This file should not have been scanned" +# endif #endif int never_scan()