Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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 "$<$<CONFIG:Debug,RelWithDebInfo>: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($<$<COMPILE_LANGUAGE:CXX>:-wd4005>)

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Loading