Skip to content

Commit bc1477b

Browse files
authored
Merge branch 'master' into nsc_macro_def_fix
2 parents 15dc925 + f75557d commit bc1477b

58 files changed

Lines changed: 3008 additions & 2330 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3rdparty/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ if(CMAKE_TOOLCHAIN_FILE)
149149
list(APPEND NBL_JPEG_CMAKE_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
150150
endif()
151151

152+
nbl_append_sanitize_address_cmake_options(NBL_JPEG_CMAKE_OPTIONS)
153+
152154
# TODO: might find an alternative library which supports add_subdirectory, untill then we need to switch to a workaround just like
153155
# we do for DXC due to: https://github.com/libjpeg-turbo/libjpeg-turbo/blob/0b742742c873025e2a127918d4969238ace7ae5b/CMakeLists.txt#L69
154156
execute_process(COMMAND "${CMAKE_COMMAND}" -S "${CMAKE_CURRENT_SOURCE_DIR}/libjpeg-turbo" -B "${CMAKE_CURRENT_BINARY_DIR}/libjpeg-turbo" -G "${CMAKE_GENERATOR}" ${NBL_JPEG_CMAKE_OPTIONS}
@@ -492,10 +494,6 @@ endif()
492494
foreach(trgt IN LISTS NBL_3RDPARTY_TARGETS)
493495
set_property(TARGET ${trgt} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${NBL_COMPILER_DYNAMIC_RUNTIME}>:DLL>")
494496

495-
if(MSVC AND NBL_SANITIZE_ADDRESS)
496-
set_property(TARGET ${trgt} PROPERTY COMPILE_OPTIONS /fsanitize=address)
497-
endif()
498-
499497
get_target_property(NBL_TARGET_TYPE ${trgt} TYPE)
500498
if(NOT "${NBL_TARGET_TYPE}" STREQUAL "INTERFACE_LIBRARY")
501499
# maybe explicit global mapping would be better, to discuss

3rdparty/dxc/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ list(APPEND NBL_DXC_CMAKE_OPTIONS "-DDXC_SPIRV_TOOLS_DIR=${DXC_SPIRV_TOOLS_DIR}"
4343
list(APPEND NBL_DXC_CMAKE_OPTIONS "-DDXC_SPIRV_HEADERS_DIR=${DXC_SPIRV_HEADERS_DIR}")
4444
list(APPEND NBL_DXC_CMAKE_OPTIONS "-DDXC_ENABLE_ETW=OFF")
4545

46+
nbl_append_sanitize_address_cmake_options(NBL_DXC_CMAKE_OPTIONS)
47+
4648
if(NOT NBL_IS_MULTI_CONFIG)
4749
list(APPEND NBL_DXC_CMAKE_OPTIONS "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
4850
endif()
@@ -54,7 +56,9 @@ endif()
5456
#else()
5557
# NBL_EXT_P_APPEND_COMPILE_OPTIONS(NBL_DXC_CMAKE_OPTIONS Release RelWithDebInfo Debug)
5658
#endif()
57-
#list(TRANSFORM NBL_DXC_CMAKE_OPTIONS REPLACE "/fp:fast" "/fp:precise")
59+
if(MSVC AND NBL_SANITIZE_ADDRESS)
60+
list(TRANSFORM NBL_DXC_CMAKE_OPTIONS REPLACE "/fp:fast" "/fp:precise")
61+
endif()
5862

5963
if(WIN32)
6064
if(NOT DEFINED HLSL_AUTOCRLF)

3rdparty/openexr

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
# For conditions of distribution and use, see copyright notice in nabla.h.in or nabla.h
44
cmake_minimum_required(VERSION 3.31..4.2.0)
55

6+
if(NOT DEFINED CMAKE_POLICY_VERSION_MINIMUM)
7+
set(CMAKE_POLICY_VERSION_MINIMUM 3.31 CACHE STRING "Minimum policy version for third-party projects")
8+
endif()
9+
610
# TODO: Yas - once we deploy 4.x we will fire `cmake_policy(VERSION <min>[...<max>])` instead of manually picking policies
711
# https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html#policy-version
812
# also we should update deps which throw warnings about < 3.10 compatibility
@@ -46,6 +50,7 @@ option(NBL_STATIC_BUILD "" OFF) # ON for static builds, OFF for shared
4650

4751
option(NBL_COMPILER_DYNAMIC_RUNTIME "" ON)
4852
option(NBL_SANITIZE_ADDRESS OFF)
53+
option(NBL_DEBUG_RTC_ENABLED "Enable Runtime Checks for Debug builds" OFF)
4954

5055
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT $<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>) # ignored on non xMSVC-ABI targets
5156

cmake/adjust/flags.cmake

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ function(nbl_adjust_flags)
281281

282282
# global compile options
283283
list(APPEND _D_NBL_COMPILE_OPTIONS_ ${NBL_COMPILE_OPTIONS})
284+
list(APPEND _D_NBL_LINK_OPTIONS_ ${NBL_LINK_OPTIONS})
284285

285286
foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES})
286287
string(TOUPPER "${CONFIG}" CONFIG_U)
@@ -316,15 +317,21 @@ function(nbl_adjust_flags)
316317

317318
# global compile options
318319
list(APPEND _D_NBL_COMPILE_OPTIONS_ ${NBL_COMPILE_OPTIONS})
320+
list(APPEND _D_NBL_LINK_OPTIONS_ ${NBL_LINK_OPTIONS})
319321
foreach(_NBL_OPTION_IMPL_ ${_NBL_OPTIONS_IMPL_})
320322
string(REPLACE "NBL_MAP_" "" NBL_MAP_CONFIGURATION_FROM "NBL_${_NBL_OPTION_IMPL_}")
321323
string(TOUPPER "${NBL_${_NBL_OPTION_IMPL_}}" NBL_MAP_CONFIGURATION_TO)
322324
set(NBL_TO_CONFIG_COMPILE_OPTIONS ${NBL_${NBL_MAP_CONFIGURATION_TO}_COMPILE_OPTIONS})
325+
set(NBL_TO_CONFIG_LINK_OPTIONS ${NBL_${NBL_MAP_CONFIGURATION_TO}_LINK_OPTIONS})
323326

324327
# per configuration compile options with mapping
325328
list(APPEND _D_NBL_COMPILE_OPTIONS_ $<$<CONFIG:${NBL_MAP_CONFIGURATION_FROM}>:${NBL_TO_CONFIG_COMPILE_OPTIONS}>)
329+
list(APPEND _D_NBL_LINK_OPTIONS_ $<$<CONFIG:${NBL_MAP_CONFIGURATION_FROM}>:${NBL_TO_CONFIG_LINK_OPTIONS}>)
326330
endforeach()
327331

328-
set_directory_properties(PROPERTIES COMPILE_OPTIONS "${_D_NBL_COMPILE_OPTIONS_}")
332+
set_directory_properties(PROPERTIES
333+
COMPILE_OPTIONS "${_D_NBL_COMPILE_OPTIONS_}"
334+
LINK_OPTIONS "${_D_NBL_LINK_OPTIONS_}"
335+
)
329336
endif()
330-
endfunction()
337+
endfunction()

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ else()
7777
endif()
7878

7979
if(NBL_SANITIZE_ADDRESS)
80-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS -fsanitize=address)
80+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS -fsanitize=address LINK_OPTIONS -fsanitize=address)
8181
endif()
8282

8383
if(NBL_SANITIZE_THREAD)
84-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS -fsanitize=thread)
84+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS -fsanitize=thread LINK_OPTIONS -fsanitize=thread)
8585
endif()
8686

8787
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS
@@ -106,4 +106,4 @@ else()
106106
-mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible
107107
-DNDEBUG
108108
)
109-
endif()
109+
endif()

cmake/adjust/template/vendor/impl/frontend/MSVC.cmake

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,24 @@ if(NBL_SANITIZE_ADDRESS)
2323
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS
2424
/fsanitize=address # https://learn.microsoft.com/en-us/cpp/build/reference/fsanitize?view=msvc-170
2525
)
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-
)
3026
endif()
3127

32-
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS
28+
set(_NBL_MSVC_DEBUG_COMPILE_OPTIONS
3329
/Ob0 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170
3430
/Od # https://learn.microsoft.com/en-us/cpp/build/reference/od-disable-debug?view=msvc-170
3531
/Oy- # https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=msvc-170
32+
)
33+
if(NBL_DEBUG_RTC_ENABLED AND NOT NBL_SANITIZE_ADDRESS)
34+
list(APPEND _NBL_MSVC_DEBUG_COMPILE_OPTIONS /RTC1)
35+
endif()
36+
37+
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS
38+
${_NBL_MSVC_DEBUG_COMPILE_OPTIONS}
3639

3740
LINK_OPTIONS
3841
/INCREMENTAL # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170
3942
)
43+
unset(_NBL_MSVC_DEBUG_COMPILE_OPTIONS)
4044

4145
NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE COMPILE_OPTIONS
4246
/O2 # https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-size-maximize-speed?view=msvc-170
@@ -63,4 +67,4 @@ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO COMPILE_OP
6367

6468
LINK_OPTIONS
6569
/INCREMENTAL # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170
66-
)
70+
)

cmake/common.cmake

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,34 @@ include_guard(GLOBAL)
1616

1717
include(ProcessorCount)
1818

19+
# tmp for external projects, to be removed later when I get rid of them (dxc + jpeg currently)
20+
function(nbl_append_sanitize_address_cmake_options out_list)
21+
if(NOT NBL_SANITIZE_ADDRESS)
22+
return()
23+
endif()
24+
25+
if(MSVC)
26+
set(_NBL_ASAN_FLAG "/fsanitize=address")
27+
else()
28+
set(_NBL_ASAN_FLAG "-fsanitize=address")
29+
set(_NBL_ASAN_LINK_SUFFIX " ${_NBL_ASAN_FLAG}")
30+
endif()
31+
32+
list(APPEND ${out_list}
33+
"-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS} ${_NBL_ASAN_FLAG}"
34+
"-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} ${_NBL_ASAN_FLAG}"
35+
)
36+
if(DEFINED _NBL_ASAN_LINK_SUFFIX)
37+
list(APPEND ${out_list}
38+
"-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}${_NBL_ASAN_LINK_SUFFIX}"
39+
"-DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS}${_NBL_ASAN_LINK_SUFFIX}"
40+
)
41+
endif()
42+
unset(_NBL_ASAN_FLAG)
43+
unset(_NBL_ASAN_LINK_SUFFIX)
44+
set(${out_list} "${${out_list}}" PARENT_SCOPE)
45+
endfunction()
46+
1947
# Macro creating project for an executable
2048
# Project and target get its name from directory when this macro gets executed (truncating number in the beginning of the name and making all lower case)
2149
# Created because of common cmake code for examples and tools

0 commit comments

Comments
 (0)