diff --git a/CMakeLists.txt b/CMakeLists.txt index d9cccd0773..8bdc6065f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,9 @@ set(CMAKE_CUDA_STANDARD 20) set(CMAKE_CUDA_STANDARD_REQUIRED ON) set(CMAKE_CUDA_SEPARABLE_COMPILATION ON) -set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -g -lineinfo --use-local-env -use_fast_math") +set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --use-local-env -use_fast_math") +set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -g -lineinfo") +set(CMAKE_CUDA_FLAGS_RELWITHDEBINFO "${CMAKE_CUDA_FLAGS_RELWITHDEBINFO} -lineinfo") project(alien-project LANGUAGES C CXX CUDA) @@ -29,6 +31,33 @@ include_directories( external) if (MSVC) + option(ALIEN_MSVC_FAST_BUILD "Enable faster MSVC debug info generation and linking for local development builds" ON) + if (ALIEN_MSVC_FAST_BUILD) + # Prefer /Z7 over /Zi in Debug/RelWithDebInfo to reduce PDB writer contention with /MP. + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$:Embedded>") + # Reduce debug link time in Visual Studio builds for real linker invocations. + string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG " /DEBUG:FASTLINK") + string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG " /DEBUG:FASTLINK") + string(APPEND CMAKE_MODULE_LINKER_FLAGS_DEBUG " /DEBUG:FASTLINK") + string(APPEND CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO " /DEBUG:FASTLINK") + string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO " /DEBUG:FASTLINK") + string(APPEND CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO " /DEBUG:FASTLINK") + endif() + + option(ALIEN_MSVC_DISABLE_MODULE_SCAN "Disable MSVC C++ module scanning for faster non-module builds" ON) + if (ALIEN_MSVC_DISABLE_MODULE_SCAN) + # This project does not use C++ modules; dependency scanning adds avoidable overhead in Visual Studio builds. + set(CMAKE_CXX_SCAN_FOR_MODULES OFF) + endif() + + option(ALIEN_MSVC_FAST_RELEASE_BUILD "Enable faster MSVC release linking for local development builds" ON) + if (ALIEN_MSVC_FAST_RELEASE_BUILD) + # Improve /GL + /LTCG release link throughput for real linker invocations. + string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE " /LTCG:INCREMENTAL") + string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE " /LTCG:INCREMENTAL") + string(APPEND CMAKE_MODULE_LINKER_FLAGS_RELEASE " /LTCG:INCREMENTAL") + endif() + # Suppress `warning C4005: 'FOO': macro redefinition` add_compile_options($<$:-wd4005>) diff --git a/README.md b/README.md index 70a4afa893..f9dcbb70ef 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,11 @@ mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release cmake --build . --config Release -j8 ``` +On MSVC, CMake enables `ALIEN_MSVC_FAST_BUILD=ON` by default, which uses `/Z7` for Debug/RelWithDebInfo and applies `/DEBUG:FASTLINK` on executable/shared/module link steps to shorten local incremental build times. +Release builds no longer include CUDA debug info flags by default (`-g`, `-lineinfo`), which shortens release compile times (including MSVC toolchains). +For MSVC, `ALIEN_MSVC_DISABLE_MODULE_SCAN=ON` is enabled by default to skip C++ module dependency scanning in non-module builds and reduce compile overhead in Visual Studio. +`ALIEN_MSVC_FAST_RELEASE_BUILD=ON` is also enabled by default and applies `/LTCG:INCREMENTAL` on executable/shared/module link steps for faster local Release links without forcing `/INCREMENTAL`. + If everything goes well, the ALIEN executable can be found under the build directory in `./alien` or `.\Release\alien.exe` depending on the used toolchain and platform. It is important to start ALIEN directly from the build folder, otherwise it will not find the resource folder.