Skip to content

Commit b5d6795

Browse files
committed
Create vendor/template/frontend/MSVC.cmake, update profiles, respect CMAKE_<LANG>_COMPILER_FRONTEND_VARIANT, fix issues with /DELAYLOAD & debug info format for ClangCL, use MSVC-frontend checking logic, inherit default MSVC frontend options in Clang profile if using Windows' ClangCL; upgrade minimum CMake version to 3.31
1 parent 25e0120 commit b5d6795

File tree

6 files changed

+138
-127
lines changed

6 files changed

+138
-127
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is part of the "Nabla Engine".
33
# For conditions of distribution and use, see copyright notice in nabla.h.in or nabla.h
44

5-
cmake_minimum_required(VERSION 3.29)
5+
cmake_minimum_required(VERSION 3.31)
66
cmake_policy(SET CMP0112 NEW)
77
cmake_policy(SET CMP0141 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0141.html#policy:CMP0141
88
cmake_policy(SET CMP0118 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0118.html#policy:CMP0118

cmake/adjust/template/vendor/impl/Clang.cmake

+60-51
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,16 @@ if(NOT DEFINED LANG)
66
message(FATAL_ERROR "LANG must be defined!")
77
endif()
88

9-
if(NBL_REQUEST_SSE_4_2)
10-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
11-
-msse4.2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-msse4.2
12-
) # TODO: (****) optional but then adjust 3rdparty options on fail
13-
endif()
14-
15-
if(NBL_REQUEST_SSE_AVX2)
16-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
17-
-mavx2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mavx2
18-
) # TODO: (****)
9+
if(NBL_WITH_COMPILER_CRASH_DIAGNOSTICS)
10+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS
11+
# use it to make a repro and attach to an issue if you Clang crashes
12+
# - it outputs preprocessed cpp files with sh script for compilation
13+
-fcrash-diagnostics=compiler
14+
-fcrash-diagnostics-dir=${NBL_ROOT_PATH_BINARY}/.crash-report
15+
)
1916
endif()
2017

21-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
18+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS
2219
-Xclang=-fconstexpr-backtrace-limit=696969
2320
-Xclang=-fconstexpr-depth=696969
2421
-Xclang=-fconstexpr-steps=696969
@@ -28,21 +25,10 @@ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
2825
-Xclang=-fspell-checking-limit=0 # no limit
2926
-Xclang=-fcaret-diagnostics-max-lines=0 # no limit
3027

31-
# whenever clang frontend or backend crashes we put diagnostics into top build direcotry
32-
# use it to make a repro and attach to an issue - it outputs preprocessed cpp files with
33-
# sh script for compilation
34-
-fcrash-diagnostics=compiler
35-
"-fcrash-diagnostics-dir=${NBL_ROOT_PATH_BINARY}/.crash-report"
36-
)
37-
38-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
3928
# latest Clang(CL) 19.1.1 shipped with VS seems to require explicitly features to be listed (simdjson)
40-
# TODO: Yas, use with REQUEST_VAR, if the request fail then do not promote simdjson to build with
41-
# HASWELL implementation because those flags + avx2 compose subset it wants in this case
42-
43-
# also instead of enabling single options maybe we could consider requesting an
44-
# instruction implementation set instead, eg -march=haswel, though this approach
45-
# could add a few more flags then we actually need while building - to rethink
29+
# TODO: Yas, we should first do independent check if host has the flags, if the request fail then
30+
# do not promote simdjson to build with HASWELL implementation because those flags + avx2 compose
31+
# subset it wants in this case
4632

4733
################
4834
# TODO: (****) ->
@@ -73,31 +59,54 @@ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS
7359
-Wno-error=non-pod-varargs
7460
)
7561

76-
if(NBL_SANITIZE_ADDRESS)
77-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -fsanitize=address)
78-
endif()
79-
80-
if(NBL_SANITIZE_THREAD)
81-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -fsanitize=thread)
62+
if(NBL_REQUEST_SSE_4_2)
63+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS
64+
-msse4.2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-msse4.2
65+
) # TODO: (****) optional but then adjust 3rdparty options on fail
8266
endif()
8367

84-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG OPTIONS
85-
-g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g
86-
-mincremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible
87-
-Wall # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning
88-
-gline-tables-only # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gline-tables-only
89-
-Xclang=-fno-inline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
90-
)
91-
92-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE OPTIONS
93-
-O2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg
94-
-Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
95-
-mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible
96-
)
97-
98-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO OPTIONS
99-
-g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g
100-
-O1 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg
101-
-Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
102-
-mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible
103-
)
68+
if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES MSVC)
69+
# ClangCL with MSVC frontend (most of the options are compatible but eg /arch:SSE4.2 seems to be not)
70+
include("${CMAKE_CURRENT_LIST_DIR}/frontend/MSVC.cmake")
71+
72+
# https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_DEBUG_INFORMATION_FORMAT.html
73+
# should be set with CMAKE_MSVC_DEBUG_INFORMATION_FORMAT but for some reason it doesn't respect with ClangCL even though its MSVC frontend
74+
# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_FRONTEND_VARIANT.html#variable:CMAKE_%3CLANG%3E_COMPILER_FRONTEND_VARIANT
75+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG RELWITHDEBINFO COMPILE_OPTIONS /Zi)
76+
return()
77+
else()
78+
if(NBL_REQUEST_SSE_AVX2)
79+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS
80+
-mavx2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mavx2
81+
) # TODO: (****)
82+
endif()
83+
84+
if(NBL_SANITIZE_ADDRESS)
85+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS -fsanitize=address)
86+
endif()
87+
88+
if(NBL_SANITIZE_THREAD)
89+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS -fsanitize=thread)
90+
endif()
91+
92+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS
93+
-g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g
94+
-mincremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible
95+
-Wall # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning
96+
-gline-tables-only # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gline-tables-only
97+
-Xclang=-fno-inline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
98+
)
99+
100+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE COMPILE_OPTIONS
101+
-O2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg
102+
-Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
103+
-mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible
104+
)
105+
106+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO COMPILE_OPTIONS
107+
-g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g
108+
-O1 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg
109+
-Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions
110+
-mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible
111+
)
112+
endif()
+2-67
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,10 @@
11
include("${CMAKE_CURRENT_LIST_DIR}/reset.cmake")
2+
include("${CMAKE_CURRENT_LIST_DIR}/frontend/MSVC.cmake")
23

34
# vendor template with options fitting for both C and CXX LANGs
45

5-
if(NOT DEFINED LANG)
6-
message(FATAL_ERROR "LANG must be defined!")
7-
endif()
8-
96
if(NBL_REQUEST_SSE_4_2)
107
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS
118
/arch:SSE4.2 # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170
129
) # TODO: (****) should be (?) optional but then adjust 3rdparty options on fail
13-
endif()
14-
15-
if(NBL_REQUEST_SSE_AVX2)
16-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS
17-
/arch:AVX2 # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170
18-
) # TODO: (****) should be (?) optional but then adjust 3rdparty options on fail
19-
endif()
20-
21-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS
22-
/Zc:preprocessor # https://learn.microsoft.com/en-us/cpp/build/reference/zc-preprocessor?view=msvc-170
23-
/Zc:__cplusplus # https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170
24-
/Zc:wchar_t # https://learn.microsoft.com/en-us/cpp/build/reference/zc-wchar-t-wchar-t-is-native-type?view=msvc-170
25-
/fp:fast # https://learn.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior?view=msvc-170
26-
/MP${_NBL_JOBS_AMOUNT_} # https://learn.microsoft.com/en-us/cpp/build/reference/mp-build-with-multiple-processes?view=msvc-170
27-
)
28-
29-
if(NBL_SANITIZE_ADDRESS)
30-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS
31-
/fsanitize=address # https://learn.microsoft.com/en-us/cpp/build/reference/fsanitize?view=msvc-170
32-
)
33-
34-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS
35-
/RTC1 # https://learn.microsoft.com/en-us/cpp/build/reference/rtc-run-time-error-checks?view=msvc-170
36-
)
37-
endif()
38-
39-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS
40-
/Ob0 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170
41-
/Od # https://learn.microsoft.com/en-us/cpp/build/reference/od-disable-debug?view=msvc-170
42-
/Oy- # https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=msvc-170
43-
44-
LINK_OPTIONS
45-
/INCREMENTAL # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170
46-
)
47-
48-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE COMPILE_OPTIONS
49-
/O2 # https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-size-maximize-speed?view=msvc-170
50-
/Ob2 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170
51-
/DNDEBUG # https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert?view=msvc-170
52-
/GL # https://learn.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization?view=msvc-170
53-
/Gy- # https://learn.microsoft.com/en-us/cpp/build/reference/gy-enable-function-level-linking?view=msvc-170
54-
/sdl- # https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170
55-
/GF # https://learn.microsoft.com/en-us/cpp/build/reference/gf-eliminate-duplicate-strings?view=msvc-170
56-
/GS- # https://learn.microsoft.com/en-us/cpp/build/reference/gs-buffer-security-check?view=msvc-170
57-
58-
LINK_OPTIONS
59-
/INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170
60-
/LTCG # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170 (note: /GL implies fallback with LTCG)
61-
)
62-
63-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO COMPILE_OPTIONS
64-
/O2 # https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-size-maximize-speed?view=msvc-170
65-
/Ob1 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170
66-
/Oy- # https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=msvc-170
67-
/DNDEBUG # https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert?view=msvc-170
68-
/GL # https://learn.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization?view=msvc-170
69-
/Gy # https://learn.microsoft.com/en-us/cpp/build/reference/gy-enable-function-level-linking?view=msvc-170
70-
/sdl- # https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170
71-
72-
LINK_OPTIONS
73-
/INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 (note: cannot use /INCREMENTAL with /LTCG:incremental, would cause fallback)
74-
/LTCG:incremental # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170
75-
)
10+
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_FRONTEND_VARIANT.html#variable:CMAKE_%3CLANG%3E_COMPILER_FRONTEND_VARIANT
2+
# vendor frontend template with options fitting for both C and CXX LANGs
3+
4+
if(NOT DEFINED LANG)
5+
message(FATAL_ERROR "LANG must be defined!")
6+
endif()
7+
8+
if(NBL_REQUEST_SSE_AVX2)
9+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS
10+
/arch:AVX2 # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170
11+
) # TODO: (****) should be (?) optional but then adjust 3rdparty options on fail
12+
endif()
13+
14+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS
15+
/Zc:preprocessor # https://learn.microsoft.com/en-us/cpp/build/reference/zc-preprocessor?view=msvc-170
16+
/Zc:__cplusplus # https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170
17+
/Zc:wchar_t # https://learn.microsoft.com/en-us/cpp/build/reference/zc-wchar-t-wchar-t-is-native-type?view=msvc-170
18+
/fp:fast # https://learn.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior?view=msvc-170
19+
/MP${_NBL_JOBS_AMOUNT_} # https://learn.microsoft.com/en-us/cpp/build/reference/mp-build-with-multiple-processes?view=msvc-170
20+
)
21+
22+
if(NBL_SANITIZE_ADDRESS)
23+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS
24+
/fsanitize=address # https://learn.microsoft.com/en-us/cpp/build/reference/fsanitize?view=msvc-170
25+
)
26+
27+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS
28+
/RTC1 # https://learn.microsoft.com/en-us/cpp/build/reference/rtc-run-time-error-checks?view=msvc-170
29+
)
30+
endif()
31+
32+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS
33+
/Ob0 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170
34+
/Od # https://learn.microsoft.com/en-us/cpp/build/reference/od-disable-debug?view=msvc-170
35+
/Oy- # https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=msvc-170
36+
37+
LINK_OPTIONS
38+
/INCREMENTAL # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170
39+
)
40+
41+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE COMPILE_OPTIONS
42+
/O2 # https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-size-maximize-speed?view=msvc-170
43+
/Ob2 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170
44+
/DNDEBUG # https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert?view=msvc-170
45+
/GL # https://learn.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization?view=msvc-170
46+
/Gy- # https://learn.microsoft.com/en-us/cpp/build/reference/gy-enable-function-level-linking?view=msvc-170
47+
/sdl- # https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170
48+
/GF # https://learn.microsoft.com/en-us/cpp/build/reference/gf-eliminate-duplicate-strings?view=msvc-170
49+
/GS- # https://learn.microsoft.com/en-us/cpp/build/reference/gs-buffer-security-check?view=msvc-170
50+
51+
LINK_OPTIONS
52+
/INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170
53+
/LTCG # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170 (note: /GL implies fallback with LTCG)
54+
)
55+
56+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO COMPILE_OPTIONS
57+
/O2 # https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-size-maximize-speed?view=msvc-170
58+
/Ob1 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170
59+
/Oy- # https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=msvc-170
60+
/DNDEBUG # https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert?view=msvc-170
61+
/GL # https://learn.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization?view=msvc-170
62+
/Gy # https://learn.microsoft.com/en-us/cpp/build/reference/gy-enable-function-level-linking?view=msvc-170
63+
/sdl- # https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170
64+
65+
LINK_OPTIONS
66+
/INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 (note: cannot use /INCREMENTAL with /LTCG:incremental, would cause fallback)
67+
/LTCG:incremental # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170
68+
)

cmake/common.cmake

-8
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,6 @@ macro(nbl_create_executable_project _EXTRA_SOURCES _EXTRA_OPTIONS _EXTRA_INCLUDE
6969

7070
add_executable(${EXECUTABLE_NAME} ${NBL_EXECUTABLE_SOURCES})
7171
nbl_handle_runtime_lib_properties(${EXECUTABLE_NAME})
72-
73-
if(WIN32 AND MSVC)
74-
if(NBL_COMPILER_DYNAMIC_RUNTIME)
75-
target_link_options(${EXECUTABLE_NAME} PUBLIC "/DELAYLOAD:$<TARGET_FILE_NAME:Nabla>")
76-
endif()
77-
78-
target_link_options(${EXECUTABLE_NAME} PUBLIC "/DELAYLOAD:dxcompiler.dll")
79-
endif()
8072
endif()
8173

8274
nbl_handle_dll_definitions(${EXECUTABLE_NAME} PUBLIC)

src/nbl/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,13 @@ endif()
358358

359359
target_compile_definitions(Nabla PRIVATE __NBL_BUILDING_NABLA__)
360360

361+
target_link_options(Nabla INTERFACE # proxy to downstream targets
362+
$<$<CXX_COMPILER_FRONTEND_VARIANT:MSVC>:
363+
$<$<BOOL:${NBL_COMPILER_DYNAMIC_RUNTIME}>:/DELAYLOAD:$<TARGET_FILE_NAME:Nabla>>
364+
/DELAYLOAD:dxcompiler.dll
365+
>
366+
)
367+
361368
if (ANDROID)
362369
add_library(android_native_app_glue STATIC
363370
${ANDROID_NDK_ROOT_PATH}/sources/android/native_app_glue/android_native_app_glue.c

0 commit comments

Comments
 (0)