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.
This commit is contained in:
Ben Boeckel
2022-11-28 11:33:23 -05:00
parent f0899e46fb
commit 7eb9b45861
7 changed files with 38 additions and 21 deletions

View File

@@ -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.

View File

@@ -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)

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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()