blob: f2f1c38bf43325d8278edf23c703d14f197e06d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
cmake_minimum_required(VERSION 3.24)
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.
string(APPEND CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FLAG
" -DCMAKE_SCANNED_THIS_SOURCE")
string(APPEND CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE
" -DCMAKE_SCANNED_THIS_SOURCE")
set_property(SOURCE always_scan.cxx
PROPERTY CXX_SCAN_FOR_MODULES 1)
set_property(SOURCE never_scan.cxx
PROPERTY CXX_SCAN_FOR_MODULES 0)
add_executable(scans_everything)
target_sources(scans_everything
PRIVATE
main.cxx
join.cxx
always_scan.cxx
never_scan.cxx
PRIVATE
FILE_SET CXX_MODULES
BASE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}"
FILES
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)
add_executable(no_scan_everything)
target_sources(no_scan_everything
PRIVATE
main.cxx
join.cxx
always_scan.cxx
never_scan.cxx
PRIVATE
FILE_SET CXX_MODULES
BASE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}"
FILES
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)
|