Skip to content

Commit afc370e

Browse files
committed
Be explicit about not using C++ modules
Only files that CMake knows won't interact with C++ modules are eligible for becoming part of unity builds. Hence, being explicit about this can speed up builds. Additionally, this avoids the need for the actual module scanning steps as well as generation of module binary files.
1 parent 6ec7a6c commit afc370e

8 files changed

Lines changed: 20 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ include(compiler)
8686
macro(sequant_add_library _module)
8787
add_library(SeQuant-${_module} ${ARGN})
8888
set_target_properties(SeQuant-${_module} PROPERTIES EXPORT_NAME ${_module})
89+
set_target_properties(SeQuant-${_module} PROPERTIES CXX_SCAN_FOR_MODULES OFF)
8990
add_library(SeQuant::${_module} ALIAS SeQuant-${_module})
9091
get_target_property(_type SeQuant-${_module} TYPE)
9192
if (NOT _type STREQUAL "INTERFACE_LIBRARY")

benchmarks/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ add_executable(sequant_benchmarks
1111
"wick.cpp"
1212
)
1313

14+
set_target_properties(sequant_benchmarks PROPERTIES CXX_SCAN_FOR_MODULES OFF)
15+
1416
# The benchmark implementations contain a bunch of same-name symbol definition that
1517
# ought to be local to the individual translation unit. Hence, we must not combine
1618
# all of them into a single translation unit.

doc/examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ foreach(current IN LISTS EXAMPLE_CODES)
3434
endif()
3535

3636
target_link_libraries(${current_name} PRIVATE SeQuant)
37+
set_target_properties(${current_name} PROPERTIES CXX_SCAN_FOR_MODULES OFF)
3738

3839
# Make sure the user sees as little from these as possible
3940
set_target_properties(${current_name}

tests/integration/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ foreach(current IN LISTS TEST_CASES)
4242
string(REGEX REPLACE "\\.cpp$" "" test_name "${test_source}")
4343

4444
add_executable(${test_name} ${BUILD_BY_DEFAULT} ${test_source})
45+
set_target_properties(${test_name} PROPERTIES CXX_SCAN_FOR_MODULES OFF)
4546
target_link_libraries(${test_name} PRIVATE SeQuant)
4647

4748
if (SEQUANT_INTERNAL_SKIP_LONG_TESTS)

tests/integration/eval/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ add_library(eval_shared STATIC EXCLUDE_FROM_ALL
1111
"scf.hpp"
1212
"scf.cpp"
1313
)
14+
set_target_properties(eval_shared PROPERTIES CXX_SCAN_FOR_MODULES OFF)
1415
target_link_libraries(eval_shared PUBLIC SeQuant)
1516
target_include_directories(eval_shared PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
1617

@@ -20,6 +21,7 @@ if (SEQUANT_HAS_TILEDARRAY)
2021
"ta/scf_ta.hpp"
2122
"ta/main.cpp"
2223
)
24+
set_target_properties(eval_ta PROPERTIES CXX_SCAN_FOR_MODULES OFF)
2325
target_link_libraries(eval_ta PRIVATE eval_shared tiledarray)
2426

2527
set(test_name "sequant/integration/eval_ta")
@@ -38,6 +40,7 @@ if (SEQUANT_HAS_BTAS)
3840
"btas/scf_btas.hpp"
3941
"btas/main.cpp"
4042
)
43+
set_target_properties(eval_btas PROPERTIES CXX_SCAN_FOR_MODULES OFF)
4144
target_link_libraries(eval_btas PRIVATE eval_shared BTAS::BTAS)
4245

4346
set(test_name "sequant/integration/eval_btas")
@@ -56,6 +59,7 @@ if (SEQUANT_HAS_TAPP)
5659
"tapp/scf_tapp.hpp"
5760
"tapp/main.cpp"
5861
)
62+
set_target_properties(eval_tapp PROPERTIES CXX_SCAN_FOR_MODULES OFF)
5963
target_link_libraries(eval_tapp PRIVATE eval_shared tapp::reference)
6064

6165
set(test_name "sequant/integration/eval_tapp")

tests/unit/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ set(symb_test_sources
2828
)
2929

3030
add_library(unit_tests-sequant-symb-obj OBJECT ${symb_test_sources})
31+
set_target_properties(unit_tests-sequant-symb-obj PROPERTIES CXX_SCAN_FOR_MODULES OFF)
3132
target_link_libraries(unit_tests-sequant-symb-obj
3233
PUBLIC SeQuant::symb SeQuant::bliss
3334
PRIVATE Catch2::Catch2 dtl::dtl)
@@ -42,6 +43,7 @@ set(eval_test_sources
4243
"test_eval_node.cpp"
4344
)
4445
add_library(unit_tests-sequant-eval-obj OBJECT ${eval_test_sources})
46+
set_target_properties(unit_tests-sequant-eval-obj PROPERTIES CXX_SCAN_FOR_MODULES OFF)
4547
target_link_libraries(unit_tests-sequant-eval-obj
4648
PUBLIC SeQuant::eval
4749
PRIVATE Catch2::Catch2 dtl::dtl)
@@ -56,6 +58,7 @@ set(optimize_test_sources
5658
"test_optimize.cpp"
5759
)
5860
add_library(unit_tests-sequant-optimize-obj OBJECT ${optimize_test_sources})
61+
set_target_properties(unit_tests-sequant-optimize-obj PROPERTIES CXX_SCAN_FOR_MODULES OFF)
5962
target_link_libraries(unit_tests-sequant-optimize-obj
6063
PUBLIC SeQuant::optimize SeQuant::bliss
6164
PRIVATE Catch2::Catch2 dtl::dtl)
@@ -71,6 +74,7 @@ set(export_test_sources
7174
"test_export_python.cpp"
7275
)
7376
add_library(unit_tests-sequant-export-obj OBJECT ${export_test_sources})
77+
set_target_properties(unit_tests-sequant-export-obj PROPERTIES CXX_SCAN_FOR_MODULES OFF)
7478
target_link_libraries(unit_tests-sequant-export-obj
7579
PUBLIC SeQuant::export SeQuant::optimize
7680
PRIVATE Catch2::Catch2 dtl::dtl Eigen3::Eigen)
@@ -88,6 +92,7 @@ set(mbpt_test_sources
8892
)
8993

9094
add_library(unit_tests-sequant-mbpt-obj OBJECT ${mbpt_test_sources})
95+
set_target_properties(unit_tests-sequant-mbpt-obj PROPERTIES CXX_SCAN_FOR_MODULES OFF)
9196
target_link_libraries(unit_tests-sequant-mbpt-obj
9297
PUBLIC SeQuant::mbpt
9398
PRIVATE Catch2::Catch2 dtl::dtl)
@@ -103,6 +108,7 @@ if (SEQUANT_HAS_TILEDARRAY)
103108
"test_cache_manager.cpp"
104109
)
105110
add_library(unit_tests-sequant-eval-ta-obj OBJECT ${eval_ta_test_sources})
111+
set_target_properties(unit_tests-sequant-eval-ta-obj PROPERTIES CXX_SCAN_FOR_MODULES OFF)
106112
target_link_libraries(unit_tests-sequant-eval-ta-obj
107113
PUBLIC SeQuant::eval::ta SeQuant::mbpt
108114
PRIVATE Catch2::Catch2 dtl::dtl)
@@ -122,6 +128,7 @@ if (SEQUANT_HAS_BTAS)
122128
list(APPEND eval_btas_test_sources "test_cache_manager.cpp")
123129
endif()
124130
add_library(unit_tests-sequant-eval-btas-obj OBJECT ${eval_btas_test_sources})
131+
set_target_properties(unit_tests-sequant-eval-btas-obj PROPERTIES CXX_SCAN_FOR_MODULES OFF)
125132
target_link_libraries(unit_tests-sequant-eval-btas-obj
126133
PUBLIC SeQuant::eval::btas SeQuant::mbpt
127134
PRIVATE Catch2::Catch2 dtl::dtl)
@@ -137,6 +144,7 @@ endif()
137144
if (SEQUANT_HAS_TAPP)
138145
set(eval_tapp_test_sources "test_eval_tapp.cpp")
139146
add_library(unit_tests-sequant-eval-tapp-obj OBJECT ${eval_tapp_test_sources})
147+
set_target_properties(unit_tests-sequant-eval-tapp-obj PROPERTIES CXX_SCAN_FOR_MODULES OFF)
140148
target_link_libraries(unit_tests-sequant-eval-tapp-obj
141149
PUBLIC SeQuant::eval::tapp SeQuant::mbpt
142150
PRIVATE Catch2::Catch2 dtl::dtl)
@@ -155,6 +163,7 @@ endif()
155163
add_executable(unit_tests-sequant ${BUILD_BY_DEFAULT}
156164
"test_main.cpp"
157165
)
166+
set_target_properties(unit_tests-sequant PROPERTIES CXX_SCAN_FOR_MODULES OFF)
158167
target_link_libraries(unit_tests-sequant PRIVATE
159168
unit_tests-sequant-symb-obj
160169
unit_tests-sequant-eval-obj

utilities/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set(EXECUTABLE_SOURCES
55
foreach(current IN LISTS EXECUTABLE_SOURCES)
66
string(REGEX REPLACE "\\.cpp$" "" name "${current}")
77
add_executable(${name} ${current})
8+
set_target_properties(${name} PROPERTIES CXX_SCAN_FOR_MODULES OFF)
89
target_link_libraries(${name} SeQuant)
910

1011
target_set_warning_flags("${name}")

utilities/external-interface/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ add_executable(external_interface
99
processing.cpp
1010
utils.cpp
1111
)
12+
set_target_properties(external_interface PROPERTIES CXX_SCAN_FOR_MODULES OFF)
1213

1314
target_link_libraries(external_interface
1415
PRIVATE

0 commit comments

Comments
 (0)