From 7eb9b458618976181bb58f3077cb3170cdcb5fe6 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 28 Nov 2022 11:33:23 -0500 Subject: Tests/RunCMake/CXXModules: mask scanning checks without control In Visual Studio, there is no mechanism to tell scanning apart from non-scanning, so skip the sanity checks. --- .../CXXModules/examples/scan_properties-stderr.txt | 2 +- .../CXXModules/examples/scan_properties/CMakeLists.txt | 7 +++++++ .../CXXModules/examples/scan_properties/always_scan.cxx | 6 ++++-- .../CXXModules/examples/scan_properties/join.cxx | 16 +++++++++------- .../CXXModules/examples/scan_properties/main.cxx | 16 +++++++++------- .../CXXModules/examples/scan_properties/module.cxx | 6 ++++-- .../CXXModules/examples/scan_properties/never_scan.cxx | 6 ++++-- 7 files changed, 38 insertions(+), 21 deletions(-) diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties-stderr.txt b/Tests/RunCMake/CXXModules/examples/scan_properties-stderr.txt index 7d79bad..2cb5957 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 551c55c..f2f1c38 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 27087d7..c3d449e 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 8184a40..4ba23a6 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 81e93f4..2c7ec3e 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 ad1e04d..fe84261 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 8374110..b47510b 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() -- cgit v0.12