@@ -10,11 +10,20 @@ project(
1010
1111set (AUTHOR "Jonas Heinle" )
1212
13+ include (cmake/BuildTypeHelpers.cmake )
14+
15+ # Resolve symlinks before comparing so aliased source/build paths are still rejected.
16+ get_filename_component (_myproject_source_dir "${CMAKE_SOURCE_DIR } " REALPATH )
17+ get_filename_component (_myproject_binary_dir "${CMAKE_BINARY_DIR } " REALPATH )
18+ if ("${_myproject_source_dir } " STREQUAL "${_myproject_binary_dir } " )
19+ message (
20+ FATAL_ERROR "In-source builds are disabled. Please create a separate build directory and run CMake from there." )
21+ endif ()
22+
1323set (MYPROJECT_GCC_TOOLCHAIN_PATH
1424 ""
1525 CACHE PATH "Optional GCC toolchain root used by Clang and Rust tooling on Linux (for example /opt/gcc-15.2.0)" )
1626
17- include (cmake/PreventInSourceBuilds.cmake )
1827include (cmake/ProjectOptions.cmake )
1928include (cmake/MSVCRuntimeConfig.cmake )
2029include (cmake/RustOptions.cmake )
@@ -57,7 +66,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
5766 # If a profile path is supplied, use it for profile-guided optimizations.
5867 target_compile_options (myproject_options INTERFACE -fprofile-instr-use=${myproject_PGO_PROFILE} )
5968 target_link_options (myproject_options INTERFACE -fprofile-instr-use=${myproject_PGO_PROFILE} )
60- elseif (myproject_ENABLE_PGO AND (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" OR CMAKE_BUILD_TYPE STREQUAL "Release" ))
69+ elseif (myproject_ENABLE_PGO AND (MYPROJECT_BUILD_IS_RELWITHDEBINFO OR MYPROJECT_BUILD_IS_RELEASE ))
6170 # Instrument the build to generate runtime profiles (.profraw).
6271 target_compile_options (myproject_options INTERFACE -fprofile-instr-generate )
6372 target_link_options (myproject_options INTERFACE -fprofile-instr-generate )
@@ -75,6 +84,18 @@ myproject_configure_msvc_runtime()
7584
7685add_subdirectory (ExternalLib )
7786
87+ # FUZZTEST pulls antlr4-cpp transitively on Windows clang-cl debug builds.
88+ # antlr4-cpp 4.13.2's ProfilingATNSimulator.cpp uses std::chrono without
89+ # including <chrono>, so fix that at the target level instead of patching the
90+ # vendored source tree.
91+ if (MSVC AND CMAKE_CXX_COMPILER_ID MATCHES ".*Clang" )
92+ foreach (_myproject_antlr_target antlr4_static antlr4_shared)
93+ if (TARGET ${_myproject_antlr_target} )
94+ target_compile_options (${_myproject_antlr_target} PRIVATE /FIchrono )
95+ endif ()
96+ endforeach ()
97+ endif ()
98+
7899# If the nlohmann.json module target was created, expose a compile-time macro
79100# so consumer module units can conditionally import the module. This lets
80101# translation units fall back to the header-only include if the module BMI
@@ -96,7 +117,7 @@ if(BUILD_TESTING)
96117 include (CTest )
97118 enable_testing ()
98119
99- if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
120+ if (MYPROJECT_BUILD_IS_DEBUG )
100121 add_subdirectory (Test /commit )
101122 add_subdirectory (Test /compile )
102123 if (NOT USE_THREAD_SANITIZER)
@@ -105,7 +126,7 @@ if(BUILD_TESTING)
105126 endif ()
106127endif ()
107128
108- if (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" )
129+ if (MYPROJECT_BUILD_IS_RELWITHDEBINFO )
109130 add_subdirectory (Test /perf )
110131endif ()
111132
0 commit comments