From 60e1e5b99aa0aa919b7615662527847a564bf226 Mon Sep 17 00:00:00 2001 From: Ali Cheraghi Date: Thu, 21 Nov 2024 17:41:35 +0330 Subject: [PATCH 01/22] build: Add ClangCL profiles Also fix some compilation errors catched by clang Signed-off-by: Ali Cheraghi --- 3rdparty/CMakeLists.txt | 2 +- 3rdparty/dxc/CMakeLists.txt | 2 +- CMakeLists.txt | 8 +-- CMakePresets.json | 24 +++++-- cmake/adjust/flags.cmake | 64 +++++++++++++++---- cmake/adjust/template/vendor/CXX_Clang.cmake | 45 +++++++++++++ cmake/adjust/template/vendor/CXX_MSVC.cmake | 46 +++++++++++++ cmake/adjust/template/vendor/C_Clang.cmake | 46 +++++++++++++ .../msvc.cmake => vendor/C_MSVC.cmake} | 31 --------- cmake/common.cmake | 6 +- include/nbl/asset/IFramebuffer.h | 2 +- include/nbl/asset/IRenderpass.h | 2 +- include/nbl/macros.h | 2 +- include/nbl/video/CVulkanDeviceMemoryBacked.h | 4 +- include/nbl/video/ISwapchain.h | 6 +- include/nbl/video/TimelineEventHandlers.h | 2 +- src/nbl/CMakeLists.txt | 2 +- src/nbl/builtin/utils.cmake | 4 +- 18 files changed, 231 insertions(+), 67 deletions(-) create mode 100644 cmake/adjust/template/vendor/CXX_Clang.cmake create mode 100644 cmake/adjust/template/vendor/CXX_MSVC.cmake create mode 100644 cmake/adjust/template/vendor/C_Clang.cmake rename cmake/adjust/template/{windows/msvc.cmake => vendor/C_MSVC.cmake} (58%) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 7b9b6da784..d8ac2a0d25 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -493,7 +493,7 @@ if(ENABLE_HLSL) endif() foreach(trgt IN LISTS NBL_3RDPARTY_TARGETS) - if(NBL_DYNAMIC_MSVC_RUNTIME) + if(NBL_COMPILER_DYNAMIC_RUNTIME) set_property(TARGET ${trgt} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") else() set_property(TARGET ${trgt} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") diff --git a/3rdparty/dxc/CMakeLists.txt b/3rdparty/dxc/CMakeLists.txt index 8b34c76f88..b6e3e21e16 100644 --- a/3rdparty/dxc/CMakeLists.txt +++ b/3rdparty/dxc/CMakeLists.txt @@ -62,7 +62,7 @@ if(WIN32) endif() endif() -if(NBL_DYNAMIC_MSVC_RUNTIME) +if(NBL_COMPILER_DYNAMIC_RUNTIME) list(APPEND NBL_DXC_CMAKE_OPTIONS "-DCMAKE_MSVC_RUNTIME_LIBRARY:STATIC=MultiThreaded$<$:Debug>DLL") else() list(APPEND NBL_DXC_CMAKE_OPTIONS "-DCMAKE_MSVC_RUNTIME_LIBRARY:STATIC=MultiThreaded$<$:Debug>") diff --git a/CMakeLists.txt b/CMakeLists.txt index 339a89d27d..a8c9013eaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,10 +20,10 @@ if(MSVC) endif() option(NBL_STATIC_BUILD "" OFF) # ON for static builds, OFF for shared -option(NBL_DYNAMIC_MSVC_RUNTIME "" ON) +option(NBL_COMPILER_DYNAMIC_RUNTIME "" ON) option(NBL_SANITIZE_ADDRESS OFF) -if(MSVC) +if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL MSVC) if(NBL_SANITIZE_ADDRESS) set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$:ProgramDatabase>") else() @@ -35,10 +35,10 @@ if(NBL_STATIC_BUILD) message(STATUS "Static Nabla build enabled!") else() if(MSVC) - if(NBL_DYNAMIC_MSVC_RUNTIME) + if(NBL_COMPILER_DYNAMIC_RUNTIME) message(STATUS "Shared Nabla build enabled!") else() - message(FATAL_ERROR "Turn NBL_DYNAMIC_MSVC_RUNTIME on! For dynamic Nabla builds dynamic MSVC runtime is mandatory!") + message(FATAL_ERROR "Turn NBL_COMPILER_DYNAMIC_RUNTIME on! For dynamic Nabla builds dynamic MSVC runtime is mandatory!") endif() else() message(FATAL_ERROR "Nabla can't be built with shared libraries! Please make sure you are targetting Windows OS and MSVC compiler!") diff --git a/CMakePresets.json b/CMakePresets.json index 8d0b62367a..da28fc1aff 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -46,7 +46,7 @@ "hidden": true, "inherits": "ci-configure-static-base", "cacheVariables": { - "NBL_DYNAMIC_MSVC_RUNTIME": "OFF" + "NBL_COMPILER_DYNAMIC_RUNTIME": "OFF" }, "condition": { "type": "allOf", @@ -69,7 +69,7 @@ "hidden": true, "inherits": "ci-configure-dynamic-base", "cacheVariables": { - "NBL_DYNAMIC_MSVC_RUNTIME": "ON" + "NBL_COMPILER_DYNAMIC_RUNTIME": "ON" }, "condition": { "type": "allOf", @@ -156,7 +156,7 @@ "hidden": true, "inherits": "user-configure-static-base", "cacheVariables": { - "NBL_DYNAMIC_MSVC_RUNTIME": "OFF" + "NBL_COMPILER_DYNAMIC_RUNTIME": "OFF" }, "condition": { "type": "equals", @@ -169,7 +169,7 @@ "hidden": true, "inherits": "user-configure-dynamic-base", "cacheVariables": { - "NBL_DYNAMIC_MSVC_RUNTIME": "ON" + "NBL_COMPILER_DYNAMIC_RUNTIME": "ON" }, "condition": { "type": "equals", @@ -193,6 +193,22 @@ "generator": "Visual Studio 17 2022", "toolset": "v143" }, + { + "name": "user-configure-static-clangcl", + "inherits": "user-configure-static-windows-base", + "displayName": "[USER]: Static library target, Visual Studio 17 2022 generator, ClangCL toolset", + "description": "Configure as static library with Visual Studio 17 2022 generator and ClangCL toolset", + "generator": "Visual Studio 17 2022", + "toolset": "ClangCL" + }, + { + "name": "user-configure-dynamic-clangcl", + "inherits": "user-configure-dynamic-windows-base", + "displayName": "[USER]: Dynamic library target, Visual Studio 17 2022 generator, ClangCL toolset", + "description": "Configure as dynamic library with Visual Studio 17 2022 generator and ClangCL toolset", + "generator": "Visual Studio 17 2022", + "toolset": "ClangCL" + }, { "name": "user-configure-static-ninja-multi", "inherits": "user-configure-static-windows-base", diff --git a/cmake/adjust/flags.cmake b/cmake/adjust/flags.cmake index 59764cb02d..430d507c93 100644 --- a/cmake/adjust/flags.cmake +++ b/cmake/adjust/flags.cmake @@ -40,17 +40,57 @@ option(NBL_REQUEST_SSE_4_2 "Request compilation with SSE 4.2 instruction set ena option(NBL_REQUEST_SSE_AXV2 "Request compilation with SSE Intel Advanced Vector Extensions 2 for Nabla projects" ON) # profiles -if(MSVC) - include("${CMAKE_CURRENT_LIST_DIR}/template/windows/msvc.cmake") -elseif(ANDROID) - include("${CMAKE_CURRENT_LIST_DIR}/template/unix/android.cmake") -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - include("${CMAKE_CURRENT_LIST_DIR}/template/unix/gnu.cmake") -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - include("${CMAKE_CURRENT_LIST_DIR}/template/unix/clang.cmake") -else() - message(WARNING "UNTESTED COMPILER DETECTED, EXPECT WRONG OPTIMIZATION FLAGS! SUBMIT ISSUE ON GITHUB https://github.com/Devsh-Graphics-Programming/Nabla/issues") -endif() +foreach(NBL_COMPILER_LANGUAGE IN ITEMS C CXX) + # all list of all known by CMake vendors: + # https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html + set(NBL_COMPILER_VENDOR "${CMAKE_${NBL_COMPILER_LANGUAGE}_COMPILER_ID}") + set(NBL_PROFILE_NAME "${NBL_COMPILER_LANGUAGE}_${NBL_COMPILER_VENDOR}") # eg. "cxx_MSVC.cmake" + set(NBL_PROFILE_PATH "${CMAKE_CURRENT_LIST_DIR}/template/vendor/${NBL_PROFILE_NAME}.cmake") + + include("${NBL_PROFILE_PATH}" RESULT_VARIABLE _NBL_FOUND_) + + if(NOT _NBL_FOUND_) + message(WARNING "UNSUPPORTED \"${NBL_COMPILER_LANGUAGE}\" COMPILER LANGUAGE FOR \"${NBL_COMPILER_VENDOR}\" DETECTED, CMAKE CONFIGURATION OR BUILD MAY FAIL AND COMPILE OPTIONS FLAGS WILL NOT BE SET! SUBMIT ISSUE ON GITHUB https://github.com/Devsh-Graphics-Programming/Nabla/issues") + continue() + endif() + + # a profile MUST define + # - "NBL_${NBL_COMPILER_LANGUAGE}_${CONFIGURATION}_COMPILE_OPTIONS" (configuration dependent) + # - "NBL_${NBL_COMPILER_LANGUAGE}_COMPILE_OPTIONS" (global) + + # a profile MUST NOT define + # - NBL_COMPILE_OPTIONS + + set(NBL_COMPILE_OPTIONS_VAR_NAME NBL_${NBL_COMPILER_LANGUAGE}_COMPILE_OPTIONS) + set(NBL_COMPILE_OPTIONS_VAR_VALUE ${${NBL_COMPILE_OPTIONS_VAR_NAME}}) + + if(NOT DEFINED ${NBL_COMPILE_OPTIONS_VAR_NAME}) + message(FATAL_ERROR "\"${NBL_PROFILE_PATH}\" did not define \"${NBL_COMPILE_OPTIONS_VAR_NAME}\"!") + endif() + + # update map with configuration dependent compile options + foreach(CONFIGURATION IN ITEMS RELEASE RELWITHDEBINFO DEBUG) + set(NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_NAME NBL_${NBL_COMPILER_LANGUAGE}_${CONFIGURATION}_COMPILE_OPTIONS) + set(NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_VALUE ${${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_NAME}}) + + if(NOT DEFINED ${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_NAME}) + message(FATAL_ERROR "\"${NBL_PROFILE_PATH}\" did not define \"${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_NAME}\"!") + endif() + + list(APPEND NBL_${CONFIGURATION}_COMPILE_OPTIONS + # note that "${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_VALUE}" MUST NOT contain ANY + # $<$> generator expression in order to support our configuration mapping features + $<$:${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_VALUE}> + ) + + set(NBL_${CONFIGURATION}_COMPILE_OPTIONS ${NBL_${CONFIGURATION}_COMPILE_OPTIONS}) + endforeach() + + # update map with global compile options + list(APPEND NBL_COMPILE_OPTIONS $<$:${NBL_${NBL_COMPILER_LANGUAGE}_COMPILE_OPTIONS}>) + + set(NBL_COMPILE_OPTIONS ${NBL_COMPILE_OPTIONS}) +endforeach() function(NBL_EXT_P_APPEND_COMPILE_OPTIONS NBL_LIST_NAME MAP_RELEASE MAP_RELWITHDEBINFO MAP_DEBUG) macro(NBL_MAP_CONFIGURATION NBL_CONFIG_FROM NBL_CONFIG_TO) @@ -173,7 +213,7 @@ function(nbl_adjust_flags) set(MAPPED_CONFIG $>) - if(MSVC) + if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL MSVC) if(NBL_SANITIZE_ADDRESS) set(NBL_TARGET_MSVC_DEBUG_INFORMATION_FORMAT "$<$,$>:ProgramDatabase>") else() diff --git a/cmake/adjust/template/vendor/CXX_Clang.cmake b/cmake/adjust/template/vendor/CXX_Clang.cmake new file mode 100644 index 0000000000..4ab7d4ae83 --- /dev/null +++ b/cmake/adjust/template/vendor/CXX_Clang.cmake @@ -0,0 +1,45 @@ +include_guard(GLOBAL) + +# Debug +set(NBL_CXX_DEBUG_COMPILE_OPTIONS + -ggdb3 -Wall -fno-omit-frame-pointer -fstack-protector-strong +) + +# Release +set(NBL_CXX_RELEASE_COMPILE_OPTIONS + -fexpensive-optimizations +) + +# RelWithDebInfo +set(NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS "") + +# Global +list(APPEND NBL_CXX_COMPILE_OPTIONS + -Wextra + -fno-strict-aliasing + -msse4.2 + -mfpmath=sse + -Wextra + -Wno-sequence-point + -Wno-unused-parameter + -Wno-unused-but-set-parameter + -Wno-error=ignored-attributes + -Wno-error=unused-function + -Wno-error=unused-variable + -Wno-error=unused-parameter + -Wno-error=ignored-attributes + -Wno-error=non-pod-varargs + -fno-exceptions +) + +if(NBL_SANITIZE_ADDRESS) + list(APPEND NBL_CXX_COMPILE_OPTIONS -fsanitize=address) +endif() + +if(NBL_SANITIZE_THREAD) + list(APPEND NBL_CXX_COMPILE_OPTIONS -fsanitize=thread) +endif() + +# our pervious flags-set function called this, does not affect flags nor configs so I will keep it here temporary +# TODO: move it out from the profile +link_libraries(-fuse-ld=gold) \ No newline at end of file diff --git a/cmake/adjust/template/vendor/CXX_MSVC.cmake b/cmake/adjust/template/vendor/CXX_MSVC.cmake new file mode 100644 index 0000000000..8b07390ed6 --- /dev/null +++ b/cmake/adjust/template/vendor/CXX_MSVC.cmake @@ -0,0 +1,46 @@ +include_guard(GLOBAL) + +# https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 + +# The default instruction set is SSE2 if no /arch option is specified. +if(NBL_REQUEST_SSE_4_2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT("/arch:SSE4.2") +endif() + +# Enables Intel Advanced Vector Extensions 2. +if(NBL_REQUEST_SSE_AXV2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT("/arch:AVX2") +endif() + +# Debug +set(NBL_CXX_DEBUG_COMPILE_OPTIONS + /Zc:__cplusplus /Ob0 /Od /MP${_NBL_JOBS_AMOUNT_} /fp:fast /Zc:wchar_t /INCREMENTAL +) + +if(NBL_SANITIZE_ADDRESS) + list(APPEND NBL_CXX_DEBUG_COMPILE_OPTIONS /RTC1) +endif() + +set(NBL_DEBUG_CXX_COMPILE_OPTIONS + $<$:${NBL_CXX_DEBUG_COMPILE_OPTIONS}> +) + +# Release +set(NBL_CXX_RELEASE_COMPILE_OPTIONS + /Zc:__cplusplus /O2 /Ob2 /DNDEBUG /GL /MP${_NBL_JOBS_AMOUNT_} /Gy- /Zc:wchar_t /sdl- /GF /GS- /fp:fast +) + +# RelWithDebInfo +set(NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS + /Zc:__cplusplus /O2 /Ob1 /DNDEBUG /GL /Zc:wchar_t /MP${_NBL_JOBS_AMOUNT_} /Gy /sdl- /Oy- /fp:fast +) + +if(NBL_SANITIZE_ADDRESS) + list(APPEND NBL_CXX_COMPILE_OPTIONS /fsanitize=address) +endif() + +# this should also be not part of profile, pasting from old flags-set function temporary +# TODO: use profile + +#reason for INCREMENTAL:NO: https://docs.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=vs-2019 /LTCG is not valid for use with /INCREMENTAL. +set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /INCREMENTAL:NO /LTCG:incremental") diff --git a/cmake/adjust/template/vendor/C_Clang.cmake b/cmake/adjust/template/vendor/C_Clang.cmake new file mode 100644 index 0000000000..e4eb0d6ad9 --- /dev/null +++ b/cmake/adjust/template/vendor/C_Clang.cmake @@ -0,0 +1,46 @@ +include_guard(GLOBAL) + +# Debug +set(NBL_C_DEBUG_COMPILE_OPTIONS + -ggdb3 -Wall -fno-omit-frame-pointer -fstack-protector-strong +) + +# Release +set(NBL_C_RELEASE_COMPILE_OPTIONS + -fexpensive-optimizations +) + +# RelWithDebInfo +set(NBL_C_RELWITHDEBINFO_COMPILE_OPTIONS "") + +# Global +list(APPEND NBL_C_COMPILE_OPTIONS + -Wextra + -fno-strict-aliasing + -msse4.2 + -mfpmath=sse + -maes + -Wextra + -Wno-sequence-point + -Wno-unused-parameter + -Wno-unused-but-set-parameter + -Wno-error=ignored-attributes + -Wno-error=unused-function + -Wno-error=unused-variable + -Wno-error=unused-parameter + -Wno-error=ignored-attributes + -Wno-error=non-pod-varargs + -fno-exceptions +) + +if(NBL_SANITIZE_ADDRESS) + list(APPEND NBL_C_COMPILE_OPTIONS -fsanitize=address) +endif() + +if(NBL_SANITIZE_THREAD) + list(APPEND NBL_C_COMPILE_OPTIONS -fsanitize=thread) +endif() + +# our pervious flags-set function called this, does not affect flags nor configs so I will keep it here temporary +# TODO: move it out from the profile +link_libraries(-fuse-ld=gold) \ No newline at end of file diff --git a/cmake/adjust/template/windows/msvc.cmake b/cmake/adjust/template/vendor/C_MSVC.cmake similarity index 58% rename from cmake/adjust/template/windows/msvc.cmake rename to cmake/adjust/template/vendor/C_MSVC.cmake index e0eaa82e80..76bace680f 100644 --- a/cmake/adjust/template/windows/msvc.cmake +++ b/cmake/adjust/template/vendor/C_MSVC.cmake @@ -21,51 +21,20 @@ if(NBL_SANITIZE_ADDRESS) list(APPEND NBL_C_DEBUG_COMPILE_OPTIONS /RTC1) endif() -set(NBL_CXX_DEBUG_COMPILE_OPTIONS - /Zc:__cplusplus ${NBL_C_DEBUG_COMPILE_OPTIONS} -) - -set(NBL_DEBUG_COMPILE_OPTIONS - $<$:${NBL_CXX_DEBUG_COMPILE_OPTIONS}> - $<$:${NBL_C_DEBUG_COMPILE_OPTIONS}> -) - # Release set(NBL_C_RELEASE_COMPILE_OPTIONS /O2 /Ob2 /DNDEBUG /GL /MP${_NBL_JOBS_AMOUNT_} /Gy- /Zc:wchar_t /sdl- /GF /GS- /fp:fast ) -set(NBL_CXX_RELEASE_COMPILE_OPTIONS - /Zc:__cplusplus ${NBL_C_RELEASE_COMPILE_OPTIONS} -) - -set(NBL_RELEASE_COMPILE_OPTIONS - $<$:${NBL_CXX_RELEASE_COMPILE_OPTIONS}> - $<$:${NBL_C_RELEASE_COMPILE_OPTIONS}> -) # RelWithDebInfo set(NBL_C_RELWITHDEBINFO_COMPILE_OPTIONS /O2 /Ob1 /DNDEBUG /GL /Zc:wchar_t /MP${_NBL_JOBS_AMOUNT_} /Gy /sdl- /Oy- /fp:fast ) -set(NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS - /Zc:__cplusplus ${NBL_C_RELWITHDEBINFO_COMPILE_OPTIONS} -) - -set(NBL_RELWITHDEBINFO_COMPILE_OPTIONS - $<$:${NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS}> - $<$:${NBL_C_RELWITHDEBINFO_COMPILE_OPTIONS}> -) if(NBL_SANITIZE_ADDRESS) list(APPEND NBL_C_COMPILE_OPTIONS /fsanitize=address) - list(APPEND NBL_CXX_COMPILE_OPTIONS ${NBL_C_COMPILE_OPTIONS}) endif() -set(NBL_COMPILE_OPTIONS - $<$:${NBL_CXX_COMPILE_OPTIONS}> - $<$:${NBL_C_COMPILE_OPTIONS}> -) - # this should also be not part of profile, pasting from old flags-set function temporary # TODO: use profile diff --git a/cmake/common.cmake b/cmake/common.cmake index 86b1856ed3..d89c1ae071 100755 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -25,7 +25,7 @@ function(nbl_handle_dll_definitions _TARGET_ _SCOPE_) message(FATAL_ERROR "Internal error, requsted \"${_TARGET_}\" is not defined!") endif() - if(NBL_DYNAMIC_MSVC_RUNTIME) + if(NBL_COMPILER_DYNAMIC_RUNTIME) set(_NABLA_OUTPUT_DIR_ "${NBL_ROOT_PATH_BINARY}/src/nbl/$/devshgraphicsprogramming.nabla") target_compile_definitions(${_TARGET_} ${_SCOPE_} @@ -43,7 +43,7 @@ function(nbl_handle_runtime_lib_properties _TARGET_) message(FATAL_ERROR "Internal error, requsted \"${_TARGET_}\" is not defined!") endif() - if(NBL_DYNAMIC_MSVC_RUNTIME) + if(MSVC) set_target_properties(${_TARGET_} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") else() set_target_properties(${_TARGET_} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") @@ -75,7 +75,7 @@ macro(nbl_create_executable_project _EXTRA_SOURCES _EXTRA_OPTIONS _EXTRA_INCLUDE nbl_handle_runtime_lib_properties(${EXECUTABLE_NAME}) if(WIN32 AND MSVC) - if(NBL_DYNAMIC_MSVC_RUNTIME) + if(NBL_COMPILER_DYNAMIC_RUNTIME) target_link_options(${EXECUTABLE_NAME} PUBLIC "/DELAYLOAD:$") endif() diff --git a/include/nbl/asset/IFramebuffer.h b/include/nbl/asset/IFramebuffer.h index 9c78fe1e42..4f4abb89da 100644 --- a/include/nbl/asset/IFramebuffer.h +++ b/include/nbl/asset/IFramebuffer.h @@ -121,7 +121,7 @@ class IFramebuffer return true; // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkFramebufferCreateInfo.html#VUID-VkFramebufferCreateInfo-pAttachments-00884 - if (viewParams.components!=ImageViewType::SComponentMapping()) + if (viewParams.components!=typename ImageViewType::SComponentMapping()) return true; // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkFramebufferCreateInfo.html#VUID-VkFramebufferCreateInfo-flags-04533 diff --git a/include/nbl/asset/IRenderpass.h b/include/nbl/asset/IRenderpass.h index 7595911716..1e44d8b526 100644 --- a/include/nbl/asset/IRenderpass.h +++ b/include/nbl/asset/IRenderpass.h @@ -707,7 +707,7 @@ inline bool IRenderpass::SCreationParams::SSubpassDescription::SDepthStencilAtta template inline bool IRenderpass::SCreationParams::SSubpassDescription::SRenderAttachmentsRef::valid(const typename attachment_ref_t::description_t* descs, const uint32_t attachmentCount) const { - if (!render.valid(descs,attachmentCount) || !resolve.valid(descs,attachmentCount)) + if (!render.template valid(descs,attachmentCount) || !resolve.template valid(descs,attachmentCount)) return false; const bool renderUsed = render.used(); if (resolve.used()) diff --git a/include/nbl/macros.h b/include/nbl/macros.h index 4927f21899..fe93201a11 100644 --- a/include/nbl/macros.h +++ b/include/nbl/macros.h @@ -81,7 +81,7 @@ //! Workarounds for compiler specific bugs // MSVC 2019 is a special snowflake -#if defined(_MSC_VER) && _MSC_VER>=1920 +#if defined(_MSC_VER) && !defined(__clang__) && _MSC_VER>=1920 #define NBL_TYPENAME_4_STTC_MBR typename #else #define NBL_TYPENAME_4_STTC_MBR diff --git a/include/nbl/video/CVulkanDeviceMemoryBacked.h b/include/nbl/video/CVulkanDeviceMemoryBacked.h index c996000e04..e6d17ddf3e 100644 --- a/include/nbl/video/CVulkanDeviceMemoryBacked.h +++ b/include/nbl/video/CVulkanDeviceMemoryBacked.h @@ -47,8 +47,8 @@ class CVulkanDeviceMemoryBacked : public Interface }; #ifndef _NBL_VIDEO_C_VULKAN_DEVICE_MEMORY_BACKED_CPP_ -extern template CVulkanDeviceMemoryBacked; -extern template CVulkanDeviceMemoryBacked; +extern template class CVulkanDeviceMemoryBacked; +extern template class CVulkanDeviceMemoryBacked; #endif } // end namespace nbl::video diff --git a/include/nbl/video/ISwapchain.h b/include/nbl/video/ISwapchain.h index d052a819bd..99ba2e7975 100644 --- a/include/nbl/video/ISwapchain.h +++ b/include/nbl/video/ISwapchain.h @@ -21,6 +21,8 @@ class ISwapchain : public IBackendObject struct SSharedCreationParams { + SSharedCreationParams() {} + inline bool valid(const IPhysicalDevice* physDev, const ISurface* surface) const { ISurface::SCapabilities caps; @@ -465,10 +467,10 @@ class ISwapchain : public IBackendObject virtual const void* getNativeHandle() const = 0; // returns the maximum number of time acquires with infinite timeout which can be called before releasing the image index through present. - virtual uint8_t getMaxBlockingAcquiresBeforePresent() const = 0u; + virtual uint8_t getMaxBlockingAcquiresBeforePresent() const = 0; // returns the maximum number of acquires you can request without waiting for previous acquire semaphores to signal. - virtual uint8_t getMaxAcquiresInFlight() const = 0u; + virtual uint8_t getMaxAcquiresInFlight() const = 0; // only public because MultiTimelineEventHandlerST needs to know about it class DeferredFrameSemaphoreDrop final diff --git a/include/nbl/video/TimelineEventHandlers.h b/include/nbl/video/TimelineEventHandlers.h index 9405accf78..a3d6aa4c8b 100644 --- a/include/nbl/video/TimelineEventHandlers.h +++ b/include/nbl/video/TimelineEventHandlers.h @@ -410,7 +410,7 @@ class MultiTimelineEventHandlerST final : core::Unmovable, core::Uncopyable sum += handler->count(); else { - const auto local = handler->poll_impl(std::forward(args)...); + const auto local = handler->template poll_impl(std::forward(args)...); bailed = local.bailed; // if don't have any events left, remove the timeline if (local.eventsLeft) diff --git a/src/nbl/CMakeLists.txt b/src/nbl/CMakeLists.txt index 83845b9c84..f96e031fca 100755 --- a/src/nbl/CMakeLists.txt +++ b/src/nbl/CMakeLists.txt @@ -350,7 +350,7 @@ if(NBL_CPACK_NO_BUILD_DIRECTORY_MODULES) target_compile_definitions(Nabla PUBLIC NBL_CPACK_NO_BUILD_DIRECTORY_MODULES) endif() -if(NBL_DYNAMIC_MSVC_RUNTIME) +if(NBL_COMPILER_DYNAMIC_RUNTIME) set_property(TARGET Nabla PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") else() set_property(TARGET Nabla PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") diff --git a/src/nbl/builtin/utils.cmake b/src/nbl/builtin/utils.cmake index 0a76d1c67e..04c15de86d 100644 --- a/src/nbl/builtin/utils.cmake +++ b/src/nbl/builtin/utils.cmake @@ -39,7 +39,7 @@ endmacro() # _NAMESPACE_ is a C++ namespace builtin resources will be wrapped into # _OUTPUT_INCLUDE_SEARCH_DIRECTORY_ is an absolute path to output directory for builtin resources header files which will be a search directory for generated headers outputed to ${_OUTPUT_HEADER_DIRECTORY_}/${_NAMESPACE_PREFIX_} where namespace prefix is the namespace turned into a path # _OUTPUT_SOURCE_DIRECTORY_ is an absolute path to output directory for builtin resources source files -# _STATIC_ optional last argument is a bool, if true then add_library will use STATIC, SHARED otherwise. Pay attention that MSVC runtime is controlled by NBL_DYNAMIC_MSVC_RUNTIME which is not an argument of this function +# _STATIC_ optional last argument is a bool, if true then add_library will use STATIC, SHARED otherwise. Pay attention that MSVC runtime is controlled by NBL_COMPILER_DYNAMIC_RUNTIME which is not an argument of this function # # As an example one could list a resource as following # LIST_BUILTIN_RESOURCE(SOME_RESOURCES_TO_EMBED "glsl/blit/default_compute_normalization.comp") @@ -207,7 +207,7 @@ function(ADD_CUSTOM_BUILTIN_RESOURCES _TARGET_NAME_ _BUNDLE_NAME_ _BUNDLE_SEARCH ) set_target_properties(${_TARGET_NAME_} PROPERTIES CXX_STANDARD 20) - if(NBL_DYNAMIC_MSVC_RUNTIME) + if(NBL_COMPILER_DYNAMIC_RUNTIME) set_property(TARGET ${_TARGET_NAME_} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") else() set_property(TARGET ${_TARGET_NAME_} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") From 114c549f13f9d8e1de7b7ea6eb53daeacc2d78a5 Mon Sep 17 00:00:00 2001 From: Ali Cheraghi Date: Thu, 21 Nov 2024 20:21:22 +0330 Subject: [PATCH 02/22] build: one liner ifs and some fixes Signed-off-by: Ali Cheraghi --- 3rdparty/CMakeLists.txt | 6 +----- 3rdparty/dxc/CMakeLists.txt | 6 +----- CMakeLists.txt | 12 +++--------- cmake/adjust/template/vendor/CXX_MSVC.cmake | 4 ---- cmake/common.cmake | 6 +----- src/nbl/builtin/utils.cmake | 8 ++------ 6 files changed, 8 insertions(+), 34 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index d8ac2a0d25..b27ea0437c 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -493,11 +493,7 @@ if(ENABLE_HLSL) endif() foreach(trgt IN LISTS NBL_3RDPARTY_TARGETS) - if(NBL_COMPILER_DYNAMIC_RUNTIME) - set_property(TARGET ${trgt} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") - else() - set_property(TARGET ${trgt} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - endif() + set_property(TARGET ${trgt} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>$<$:DLL>") if(MSVC AND NBL_SANITIZE_ADDRESS) set_property(TARGET ${trgt} PROPERTY COMPILE_OPTIONS /fsanitize=address) diff --git a/3rdparty/dxc/CMakeLists.txt b/3rdparty/dxc/CMakeLists.txt index b6e3e21e16..2142a574ec 100644 --- a/3rdparty/dxc/CMakeLists.txt +++ b/3rdparty/dxc/CMakeLists.txt @@ -62,11 +62,7 @@ if(WIN32) endif() endif() -if(NBL_COMPILER_DYNAMIC_RUNTIME) - list(APPEND NBL_DXC_CMAKE_OPTIONS "-DCMAKE_MSVC_RUNTIME_LIBRARY:STATIC=MultiThreaded$<$:Debug>DLL") -else() - list(APPEND NBL_DXC_CMAKE_OPTIONS "-DCMAKE_MSVC_RUNTIME_LIBRARY:STATIC=MultiThreaded$<$:Debug>") -endif() +list(APPEND NBL_DXC_CMAKE_OPTIONS "-DCMAKE_MSVC_RUNTIME_LIBRARY:STATIC=MultiThreaded$<$:Debug>$<$:DLL>") # perform DXC compile standard requirement test set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/CMakeLists.txt b/CMakeLists.txt index a8c9013eaa..68e913770c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ option(NBL_STATIC_BUILD "" OFF) # ON for static builds, OFF for shared option(NBL_COMPILER_DYNAMIC_RUNTIME "" ON) option(NBL_SANITIZE_ADDRESS OFF) -if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL MSVC) +if(CMAKE_CXX_COMPILER_ID STREQUAL MSVC) if(NBL_SANITIZE_ADDRESS) set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$:ProgramDatabase>") else() @@ -34,14 +34,8 @@ endif() if(NBL_STATIC_BUILD) message(STATUS "Static Nabla build enabled!") else() - if(MSVC) - if(NBL_COMPILER_DYNAMIC_RUNTIME) - message(STATUS "Shared Nabla build enabled!") - else() - message(FATAL_ERROR "Turn NBL_COMPILER_DYNAMIC_RUNTIME on! For dynamic Nabla builds dynamic MSVC runtime is mandatory!") - endif() - else() - message(FATAL_ERROR "Nabla can't be built with shared libraries! Please make sure you are targetting Windows OS and MSVC compiler!") + if(NOT NBL_COMPILER_DYNAMIC_RUNTIME) + message(FATAL_ERROR "Turn NBL_COMPILER_DYNAMIC_RUNTIME on! For dynamic Nabla builds dynamic runtime is mandatory!") endif() endif() diff --git a/cmake/adjust/template/vendor/CXX_MSVC.cmake b/cmake/adjust/template/vendor/CXX_MSVC.cmake index 8b07390ed6..1abb66c9da 100644 --- a/cmake/adjust/template/vendor/CXX_MSVC.cmake +++ b/cmake/adjust/template/vendor/CXX_MSVC.cmake @@ -21,10 +21,6 @@ if(NBL_SANITIZE_ADDRESS) list(APPEND NBL_CXX_DEBUG_COMPILE_OPTIONS /RTC1) endif() -set(NBL_DEBUG_CXX_COMPILE_OPTIONS - $<$:${NBL_CXX_DEBUG_COMPILE_OPTIONS}> -) - # Release set(NBL_CXX_RELEASE_COMPILE_OPTIONS /Zc:__cplusplus /O2 /Ob2 /DNDEBUG /GL /MP${_NBL_JOBS_AMOUNT_} /Gy- /Zc:wchar_t /sdl- /GF /GS- /fp:fast diff --git a/cmake/common.cmake b/cmake/common.cmake index d89c1ae071..c663a98443 100755 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -43,11 +43,7 @@ function(nbl_handle_runtime_lib_properties _TARGET_) message(FATAL_ERROR "Internal error, requsted \"${_TARGET_}\" is not defined!") endif() - if(MSVC) - set_target_properties(${_TARGET_} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") - else() - set_target_properties(${_TARGET_} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - endif() + set_target_properties(${_TARGET_} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>$<$:DLL>") endfunction() # Macro creating project for an executable diff --git a/src/nbl/builtin/utils.cmake b/src/nbl/builtin/utils.cmake index 04c15de86d..e5b1741a95 100644 --- a/src/nbl/builtin/utils.cmake +++ b/src/nbl/builtin/utils.cmake @@ -206,12 +206,8 @@ function(ADD_CUSTOM_BUILTIN_RESOURCES _TARGET_NAME_ _BUNDLE_NAME_ _BUNDLE_SEARCH "${_OUTPUT_HEADER_DIRECTORY_}" ) set_target_properties(${_TARGET_NAME_} PROPERTIES CXX_STANDARD 20) - - if(NBL_COMPILER_DYNAMIC_RUNTIME) - set_property(TARGET ${_TARGET_NAME_} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") - else() - set_property(TARGET ${_TARGET_NAME_} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - endif() + + set_property(TARGET ${_TARGET_NAME_} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>$<$:DLL>") set(NBL_BUILTIN_RESOURCES ${NBL_BUILTIN_RESOURCES}) # turn builtin resources paths list into variable From ff5513b33e434f8ce21f06d3e71c85b59f905c99 Mon Sep 17 00:00:00 2001 From: Ali Cheraghi Date: Thu, 21 Nov 2024 21:43:55 +0330 Subject: [PATCH 03/22] update dxc submodule Signed-off-by: Ali Cheraghi --- 3rdparty/dxc/dxc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/dxc/dxc b/3rdparty/dxc/dxc index 5adc27f9e4..b8e1df19be 160000 --- a/3rdparty/dxc/dxc +++ b/3rdparty/dxc/dxc @@ -1 +1 @@ -Subproject commit 5adc27f9e42de7681d65a98873048af661b9b367 +Subproject commit b8e1df19bebaf18ff1d6b9b90d7d020cf86f3205 From 44acfcfbbe0034946307f39cebaef809de386a47 Mon Sep 17 00:00:00 2001 From: Ali Cheraghi Date: Fri, 22 Nov 2024 20:21:29 +0330 Subject: [PATCH 04/22] build: simplify if Signed-off-by: Ali Cheraghi --- cmake/adjust/flags.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/adjust/flags.cmake b/cmake/adjust/flags.cmake index 430d507c93..bec887ef1a 100644 --- a/cmake/adjust/flags.cmake +++ b/cmake/adjust/flags.cmake @@ -213,7 +213,7 @@ function(nbl_adjust_flags) set(MAPPED_CONFIG $>) - if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL MSVC) + if(CMAKE_CXX_COMPILER_ID STREQUAL MSVC) if(NBL_SANITIZE_ADDRESS) set(NBL_TARGET_MSVC_DEBUG_INFORMATION_FORMAT "$<$,$>:ProgramDatabase>") else() From 616f7d7b210b95c079da20659f8762b7f1a743ae Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Tue, 8 Apr 2025 11:01:50 +0200 Subject: [PATCH 05/22] fixing CLang build, save work --- cmake/adjust/template/vendor/CXX_Clang.cmake | 7 +++++++ cmake/adjust/template/vendor/C_Clang.cmake | 10 ++++++++-- include/nbl/asset/IDescriptorSetLayout.h | 4 ++-- include/nbl/asset/IRenderpass.h | 1 + include/nbl/asset/utils/CSPIRVIntrospector.h | 8 ++++---- .../builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl | 2 +- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/cmake/adjust/template/vendor/CXX_Clang.cmake b/cmake/adjust/template/vendor/CXX_Clang.cmake index 4ab7d4ae83..258fef3d8a 100644 --- a/cmake/adjust/template/vendor/CXX_Clang.cmake +++ b/cmake/adjust/template/vendor/CXX_Clang.cmake @@ -15,14 +15,21 @@ set(NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS "") # Global list(APPEND NBL_CXX_COMPILE_OPTIONS + -Wno-everything # TMP -Wextra -fno-strict-aliasing -msse4.2 + -maes -mfpmath=sse -Wextra -Wno-sequence-point -Wno-unused-parameter -Wno-unused-but-set-parameter + -Wno-c++98-compat + -Wno-c++98-compat-pedantic + -Wno-padded + -Wno-unsafe-buffer-usage + -Wno-switch-enum -Wno-error=ignored-attributes -Wno-error=unused-function -Wno-error=unused-variable diff --git a/cmake/adjust/template/vendor/C_Clang.cmake b/cmake/adjust/template/vendor/C_Clang.cmake index e4eb0d6ad9..3dc21dec15 100644 --- a/cmake/adjust/template/vendor/C_Clang.cmake +++ b/cmake/adjust/template/vendor/C_Clang.cmake @@ -15,15 +15,21 @@ set(NBL_C_RELWITHDEBINFO_COMPILE_OPTIONS "") # Global list(APPEND NBL_C_COMPILE_OPTIONS + -Wno-everything # TMP -Wextra -fno-strict-aliasing -msse4.2 - -mfpmath=sse - -maes + -maes + -mfpmath=sse -Wextra -Wno-sequence-point -Wno-unused-parameter -Wno-unused-but-set-parameter + -Wno-c++98-compat + -Wno-c++98-compat-pedantic + -Wno-padded + -Wno-unsafe-buffer-usage + -Wno-switch-enum -Wno-error=ignored-attributes -Wno-error=unused-function -Wno-error=unused-variable diff --git a/include/nbl/asset/IDescriptorSetLayout.h b/include/nbl/asset/IDescriptorSetLayout.h index 44e8be71ea..ec3c182fdc 100644 --- a/include/nbl/asset/IDescriptorSetLayout.h +++ b/include/nbl/asset/IDescriptorSetLayout.h @@ -330,7 +330,7 @@ class IDescriptorSetLayout : public IDescriptorSetLayoutBase bindings[i].binding = i; bindings[i].type = type; bindings[i].createFlags = SBinding::E_CREATE_FLAGS::ECF_NONE; - bindings[i].stageFlags = stageAccessFlags ? stageAccessFlags[i]:asset::IShader::ESS_ALL_OR_LIBRARY; + bindings[i].stageFlags = stageAccessFlags ? stageAccessFlags[i]:asset::IShader::E_SHADER_STAGE::ESS_ALL_OR_LIBRARY; bindings[i].count = counts ? counts[i]:1u; bindings[i].samplers = nullptr; } @@ -354,7 +354,7 @@ class IDescriptorSetLayout : public IDescriptorSetLayoutBase for (uint32_t b = 0u; b < bindingCnt; ++b) { auto bindingNumber = m_descriptorRedirects[t].m_bindingNumbers[b]; - CBindingRedirect::template binding_number_t otherBindingNumber(CBindingRedirect::Invalid); + CBindingRedirect::binding_number_t otherBindingNumber(CBindingRedirect::Invalid); // TODO: std::find instead? for (uint32_t ob = 0u; ob < otherBindingCnt; ++ob) { diff --git a/include/nbl/asset/IRenderpass.h b/include/nbl/asset/IRenderpass.h index 657b0fcaff..b9554fc2a6 100644 --- a/include/nbl/asset/IRenderpass.h +++ b/include/nbl/asset/IRenderpass.h @@ -81,6 +81,7 @@ class NBL_API2 IRenderpass { bool valid() const; }; + // The arrays pointed to by this array must be terminated by `DepthStencilAttachmentsEnd` value, which implicitly satisfies a few VUIDs constexpr static inline SDepthStencilAttachmentDescription DepthStencilAttachmentsEnd = {}; const SDepthStencilAttachmentDescription* depthStencilAttachments = &DepthStencilAttachmentsEnd; diff --git a/include/nbl/asset/utils/CSPIRVIntrospector.h b/include/nbl/asset/utils/CSPIRVIntrospector.h index f756a58a42..7a2310a62e 100644 --- a/include/nbl/asset/utils/CSPIRVIntrospector.h +++ b/include/nbl/asset/utils/CSPIRVIntrospector.h @@ -326,8 +326,8 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable template inline std::enable_if_t isLastMemberRuntimeSized() const { - if (type->memberCount) - return type->memberTypes()[type->memberCount-1].count.front().isRuntimeSized(); + if (this->type->memberCount) + return this->type->memberTypes()[this->type->memberCount-1].count.front().isRuntimeSized(); return false; } template @@ -335,9 +335,9 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable { if (isLastMemberRuntimeSized()) { - const auto& lastMember = type->memberTypes()[type->memberCount-1]; + const auto& lastMember = this->type->memberTypes()[this->type->memberCount-1]; assert(!lastMember.count.front().isSpecConstantID); - return sizeWithoutLastMember+lastMemberElementCount*type->memberStrides()[type->memberCount-1]; + return sizeWithoutLastMember+lastMemberElementCount* this->type->memberStrides()[this->type->memberCount-1]; } return sizeWithoutLastMember; } diff --git a/include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl b/include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl index 0309b78e0d..94da595ef2 100644 --- a/include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl +++ b/include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl @@ -598,7 +598,7 @@ struct nClamp_helper using return_t = T; static inline return_t __call(const T x, const T _min, const T _max) { - return nMin_helper::_call(nMax_helper::_call(x, _min), _max); + return nMin_helper::_call(nMin_helper::_call(x, _min), _max); } }; From aad8bb1445ffece46681f11c73bf5372421ea5d0 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Tue, 8 Apr 2025 14:23:40 +0200 Subject: [PATCH 06/22] make Nabla Clang build work --- cmake/adjust/template/vendor/CXX_Clang.cmake | 1 - cmake/adjust/template/vendor/C_Clang.cmake | 3 +-- include/nbl/asset/IRenderpass.h | 16 +++++++++++----- include/nbl/asset/filters/CBlitImageFilter.h | 2 +- .../nbl/asset/filters/kernels/WeightFunctions.h | 4 ++-- include/nbl/asset/utils/CSPIRVIntrospector.h | 8 +++++++- include/nbl/video/ILogicalDevice.h | 2 +- include/nbl/video/utilities/CSubpassKiln.h | 2 +- src/nbl/video/CVulkanCommandBuffer.cpp | 2 +- src/nbl/video/CVulkanDeviceMemoryBacked.cpp | 4 ++-- src/nbl/video/IGPUAccelerationStructure.cpp | 8 ++++---- src/nbl/video/utilities/CAssetConverter.cpp | 14 +++++++------- 12 files changed, 38 insertions(+), 28 deletions(-) diff --git a/cmake/adjust/template/vendor/CXX_Clang.cmake b/cmake/adjust/template/vendor/CXX_Clang.cmake index 258fef3d8a..62c12075d1 100644 --- a/cmake/adjust/template/vendor/CXX_Clang.cmake +++ b/cmake/adjust/template/vendor/CXX_Clang.cmake @@ -15,7 +15,6 @@ set(NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS "") # Global list(APPEND NBL_CXX_COMPILE_OPTIONS - -Wno-everything # TMP -Wextra -fno-strict-aliasing -msse4.2 diff --git a/cmake/adjust/template/vendor/C_Clang.cmake b/cmake/adjust/template/vendor/C_Clang.cmake index 3dc21dec15..1c00f78e84 100644 --- a/cmake/adjust/template/vendor/C_Clang.cmake +++ b/cmake/adjust/template/vendor/C_Clang.cmake @@ -14,8 +14,7 @@ set(NBL_C_RELEASE_COMPILE_OPTIONS set(NBL_C_RELWITHDEBINFO_COMPILE_OPTIONS "") # Global -list(APPEND NBL_C_COMPILE_OPTIONS - -Wno-everything # TMP +list(APPEND NBL_C_COMPILE_OPTIONS -Wextra -fno-strict-aliasing -msse4.2 diff --git a/include/nbl/asset/IRenderpass.h b/include/nbl/asset/IRenderpass.h index b9554fc2a6..ce41e35573 100644 --- a/include/nbl/asset/IRenderpass.h +++ b/include/nbl/asset/IRenderpass.h @@ -83,10 +83,10 @@ class NBL_API2 IRenderpass }; // The arrays pointed to by this array must be terminated by `DepthStencilAttachmentsEnd` value, which implicitly satisfies a few VUIDs - constexpr static inline SDepthStencilAttachmentDescription DepthStencilAttachmentsEnd = {}; + static const SDepthStencilAttachmentDescription DepthStencilAttachmentsEnd; // have to initialize out of line because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88165 const SDepthStencilAttachmentDescription* depthStencilAttachments = &DepthStencilAttachmentsEnd; // The arrays pointed to by this array must be terminated by `ColorAttachmentsEnd` value, which implicitly satisfies a few VUIDs - constexpr static inline SColorAttachmentDescription ColorAttachmentsEnd = {}; + static const SColorAttachmentDescription ColorAttachmentsEnd; // have to initialize out of line because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88165 const SColorAttachmentDescription* colorAttachments = &ColorAttachmentsEnd; struct SSubpassDescription final @@ -200,7 +200,7 @@ class NBL_API2 IRenderpass SColorAttachmentsRef colorAttachments[MaxColorAttachments] = {}; // The arrays pointed to by this array must be terminated by `InputAttachmentsEnd` value - constexpr static inline SInputAttachmentRef InputAttachmentsEnd = {}; + static const SInputAttachmentRef InputAttachmentsEnd; const SInputAttachmentRef* inputAttachments = &InputAttachmentsEnd; struct SPreserveAttachmentRef @@ -233,7 +233,7 @@ class NBL_API2 IRenderpass // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSubpassDescription2.html#VUID-VkSubpassDescription2-pipelineBindPoint-04953 //E_PIPELINE_BIND_POINT pipelineBindPoint : 2 = EPBP_GRAPHICS; }; - constexpr static inline SSubpassDescription SubpassesEnd = {}; + static const SSubpassDescription SubpassesEnd; const SSubpassDescription* subpasses = &SubpassesEnd; struct SSubpassDependency final @@ -259,7 +259,7 @@ class NBL_API2 IRenderpass bool valid() const; }; // The arrays pointed to by this array must be terminated by `DependenciesEnd` value - constexpr static inline SSubpassDependency DependenciesEnd = {}; + static const SSubpassDependency DependenciesEnd; const SSubpassDependency* dependencies = &DependenciesEnd; @@ -380,6 +380,12 @@ class NBL_API2 IRenderpass uint32_t m_loadOpColorAttachmentEnd = ~0u; }; +constexpr inline IRenderpass::SCreationParams::SDepthStencilAttachmentDescription IRenderpass::SCreationParams::DepthStencilAttachmentsEnd = {}; +constexpr inline IRenderpass::SCreationParams::SColorAttachmentDescription IRenderpass::SCreationParams::ColorAttachmentsEnd = {}; +constexpr inline IRenderpass::SCreationParams::SSubpassDescription::SInputAttachmentRef IRenderpass::SCreationParams::SSubpassDescription::InputAttachmentsEnd = {}; +constexpr inline IRenderpass::SCreationParams::SSubpassDescription IRenderpass::SCreationParams::SubpassesEnd = {}; +constexpr inline IRenderpass::SCreationParams::SSubpassDependency IRenderpass::SCreationParams::DependenciesEnd = {}; + inline bool IRenderpass::compatible(const IRenderpass* other) const { // If you find yourself spending a lot of time here in your profile, go ahead and implement a precomputed hash and store it in the renderpass diff --git a/include/nbl/asset/filters/CBlitImageFilter.h b/include/nbl/asset/filters/CBlitImageFilter.h index 1dbc7809ba..f228fea325 100644 --- a/include/nbl/asset/filters/CBlitImageFilter.h +++ b/include/nbl/asset/filters/CBlitImageFilter.h @@ -464,7 +464,7 @@ class CBlitImageFilter : auto phaseCount = IBlitUtilities::getPhaseCount(inExtentLayerCount.xyz, outExtentLayerCount.xyz, inImageType); phaseCount = hlsl::max(phaseCount,hlsl::uint32_t3(1,1,1)); - const auto axisOffsets = blit_utils_t::template getScaledKernelPhasedLUTAxisOffsets(phaseCount,real_window_size); + const auto axisOffsets = blit_utils_t::getScaledKernelPhasedLUTAxisOffsets(phaseCount,real_window_size); constexpr auto MaxAxisCount = 3; lut_value_t* scaledKernelPhasedLUTPixel[MaxAxisCount]; for (auto i = 0; i < MaxAxisCount; ++i) diff --git a/include/nbl/asset/filters/kernels/WeightFunctions.h b/include/nbl/asset/filters/kernels/WeightFunctions.h index bb0b8fb9b4..af2782dfac 100644 --- a/include/nbl/asset/filters/kernels/WeightFunctions.h +++ b/include/nbl/asset/filters/kernels/WeightFunctions.h @@ -337,12 +337,12 @@ class CWeightFunction1D final : public impl::IWeightFunction1Dscale(base_t::value_t(1)/stretchFactor); + this->scale(typename base_t::value_t(1)/stretchFactor); } inline base_t::value_t weight(const float x) const { - return static_cast(this->getTotalScale()*function_t::weight(x*this->getInvStretch())); + return static_cast(this->getTotalScale()*function_t::template weight(x*this->getInvStretch())); } // Integral of `weight(x) dx` from -INF to +INF diff --git a/include/nbl/asset/utils/CSPIRVIntrospector.h b/include/nbl/asset/utils/CSPIRVIntrospector.h index 7a2310a62e..45fcb0e3a7 100644 --- a/include/nbl/asset/utils/CSPIRVIntrospector.h +++ b/include/nbl/asset/utils/CSPIRVIntrospector.h @@ -208,7 +208,13 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable // `memberStrides[i]` only relevant if `memberTypes[i]->isArray()` inline ptr_t memberStrides() const {return memberOffsets()+memberCount;} using member_matrix_info_t = MatrixInfo; - inline ptr_t memberMatrixInfos() const {return reinterpret_cast&>(memberStrides()+memberCount); } + inline ptr_t memberMatrixInfos() const + { + auto t = memberStrides() + memberCount; + + return reinterpret_cast&>(t); + + } constexpr static inline size_t StoragePerMember = sizeof(member_type_t)+sizeof(member_name_t)+sizeof(member_size_t)+sizeof(member_offset_t)+sizeof(member_stride_t)+sizeof(member_matrix_info_t); diff --git a/include/nbl/video/ILogicalDevice.h b/include/nbl/video/ILogicalDevice.h index 0cc6608b16..46f7dc1ce7 100644 --- a/include/nbl/video/ILogicalDevice.h +++ b/include/nbl/video/ILogicalDevice.h @@ -1502,7 +1502,7 @@ inline bool ILogicalDevice::validateMemoryBarrier(const uint32_t queueFamilyInde return false; }; // CANNOT CHECK: https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkImageMemoryBarrier2-oldLayout-01197 - if (mismatchedLayout.operator()(barrier.oldLayout) || mismatchedLayout.operator()(barrier.newLayout)) + if (mismatchedLayout.template operator()(barrier.oldLayout) || mismatchedLayout.template operator()(barrier.newLayout)) return false; } diff --git a/include/nbl/video/utilities/CSubpassKiln.h b/include/nbl/video/utilities/CSubpassKiln.h index 7df6cc0caa..c41ec3dd7e 100644 --- a/include/nbl/video/utilities/CSubpassKiln.h +++ b/include/nbl/video/utilities/CSubpassKiln.h @@ -198,7 +198,7 @@ class CSubpassKiln if (begin==end) return; - bake_impl(cmdbuf->getOriginDevice()->getPhysicalDevice()->getLimits().indirectDrawCount, drawIndirectBuffer, drawCountBuffer)(cmdbuf, begin, end); + bake_impl(cmdbuf->getOriginDevice()->getPhysicalDevice()->getLimits().drawIndirectCount, drawIndirectBuffer, drawCountBuffer)(cmdbuf, begin, end); } protected: diff --git a/src/nbl/video/CVulkanCommandBuffer.cpp b/src/nbl/video/CVulkanCommandBuffer.cpp index b569a5fde2..9f0b0a83e1 100644 --- a/src/nbl/video/CVulkanCommandBuffer.cpp +++ b/src/nbl/video/CVulkanCommandBuffer.cpp @@ -661,7 +661,7 @@ bool CVulkanCommandBuffer::beginRenderPass_impl(const SRenderpassBeginInfo& info .renderArea = info.renderArea, // Implicitly but could be optimizedif needed // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkRenderPassBeginInfo.html#VUID-VkRenderPassBeginInfo-clearValueCount-00902 - .clearValueCount = vk_clearValues.size()/sizeof(VkClearValue), + .clearValueCount = static_cast(vk_clearValues.size()/sizeof(VkClearValue)), // Implicit // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkRenderPassBeginInfo.html#VUID-VkRenderPassBeginInfo-clearValueCount-04962 .pClearValues = vk_clearValues.data() diff --git a/src/nbl/video/CVulkanDeviceMemoryBacked.cpp b/src/nbl/video/CVulkanDeviceMemoryBacked.cpp index 2bec9e9d06..90b2993cb3 100644 --- a/src/nbl/video/CVulkanDeviceMemoryBacked.cpp +++ b/src/nbl/video/CVulkanDeviceMemoryBacked.cpp @@ -40,7 +40,7 @@ CVulkanDeviceMemoryBacked::CVulkanDeviceMemoryBacked( assert(vkHandle!=VK_NULL_HANDLE); } -template CVulkanDeviceMemoryBacked; -template CVulkanDeviceMemoryBacked; +template class CVulkanDeviceMemoryBacked; +template class CVulkanDeviceMemoryBacked; } \ No newline at end of file diff --git a/src/nbl/video/IGPUAccelerationStructure.cpp b/src/nbl/video/IGPUAccelerationStructure.cpp index eafbe08d6f..ae78754b1e 100644 --- a/src/nbl/video/IGPUAccelerationStructure.cpp +++ b/src/nbl/video/IGPUAccelerationStructure.cpp @@ -140,11 +140,11 @@ uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::valid(cons retval += geometryCount*MaxBuffersPerGeometry; return retval; } -template uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::template valid(const uint32_t* const) const; -template uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::template valid(const uint32_t* const) const; +template uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::valid(const uint32_t* const) const; +template uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::valid(const uint32_t* const) const; using BuildRangeInfo = hlsl::acceleration_structures::bottom_level::BuildRangeInfo; -template uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::template valid(const BuildRangeInfo* const) const; -template uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::template valid(const BuildRangeInfo* const) const; +template uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::valid(const BuildRangeInfo* const) const; +template uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::valid(const BuildRangeInfo* const) const; bool IGPUBottomLevelAccelerationStructure::validVertexFormat(const asset::E_FORMAT format) const { diff --git a/src/nbl/video/utilities/CAssetConverter.cpp b/src/nbl/video/utilities/CAssetConverter.cpp index 796f3dcaec..fdb5c61ca8 100644 --- a/src/nbl/video/utilities/CAssetConverter.cpp +++ b/src/nbl/video/utilities/CAssetConverter.cpp @@ -2142,7 +2142,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult { for (auto& entry : conversionRequests) for (auto i=0ull; i(entry.first,entry.second.firstCopyIx,i,device->createSampler(entry.second.canonicalAsset->getParams())); + assign.template operator()(entry.first,entry.second.firstCopyIx,i,device->createSampler(entry.second.canonicalAsset->getParams())); } if constexpr (std::is_same_v) { @@ -2461,7 +2461,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult { // since we don't have dependants we don't care about our group ID // we create threadsafe pipeline caches, because we have no idea how they may be used - assign.operator()(entry.first,entry.second.firstCopyIx,i,device->createPipelineCache(asset,false)); + assign.template operator()(entry.first,entry.second.firstCopyIx,i,device->createPipelineCache(asset,false)); } } } @@ -2506,7 +2506,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult { // since we don't have dependants we don't care about our group ID // we create threadsafe pipeline caches, because we have no idea how they may be used - assign.operator()(entry.first,entry.second.firstCopyIx,i,device->createRenderpass(asset->getCreationParameters())); + assign.template operator()(entry.first,entry.second.firstCopyIx,i,device->createRenderpass(asset->getCreationParameters())); } } } @@ -2653,7 +2653,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult gpuObj.get()->setObjectDebugName(debugName.str().c_str()); } // insert into staging cache - stagingCache.emplace(gpuObj.get(),CCache::key_t(contentHash,uniqueCopyGroupID)); + stagingCache.emplace(gpuObj.get(),typename CCache::key_t(contentHash,uniqueCopyGroupID)); // propagate back to dfsCache created.gpuObj = std::move(gpuObj); // record if a device memory allocation will be needed @@ -2668,11 +2668,11 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult // this is super annoying, was hoping metaprogramming with `has_type` would actually work auto getConversionRequests = [&]()->auto&{return std::get>(retval.m_conversionRequests);}; if constexpr (std::is_same_v) - getConversionRequests.operator()().emplace_back(core::smart_refctd_ptr(instance.asset),created.gpuObj.get());; + getConversionRequests.template operator()().emplace_back(core::smart_refctd_ptr(instance.asset),created.gpuObj.get());; if constexpr (std::is_same_v) { const uint16_t recomputeMips = created.patch.recomputeMips; - getConversionRequests.operator()().emplace_back(core::smart_refctd_ptr(instance.asset),created.gpuObj.get(),recomputeMips); + getConversionRequests.template operator()().emplace_back(core::smart_refctd_ptr(instance.asset),created.gpuObj.get(),recomputeMips); } // TODO: BLAS and TLAS requests } @@ -2939,7 +2939,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult // if something with this content hash is in the stagingCache, then it must match the `found->gpuObj` if (auto finalCacheIt=stagingCache.find(gpuObj.get()); finalCacheIt!=stagingCache.end()) { - const bool matches = finalCacheIt->second==CCache::key_t(found.contentHash,uniqueCopyGroupID); + const bool matches = finalCacheIt->second==typename CCache::key_t(found.contentHash,uniqueCopyGroupID); assert(matches); } } From 7b8cb61f0cbd56580a216e02c87a3627a28d7a5d Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Tue, 8 Apr 2025 15:05:51 +0200 Subject: [PATCH 07/22] bad typo --- include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl b/include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl index 94da595ef2..0d95c032b0 100644 --- a/include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl +++ b/include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl @@ -598,7 +598,7 @@ struct nClamp_helper using return_t = T; static inline return_t __call(const T x, const T _min, const T _max) { - return nMin_helper::_call(nMin_helper::_call(x, _min), _max); + return nMin_helper::_call(nMax_helper::_call(x, _min), _max); } }; From 062b5baa4ae3af2284f39b9b6d983b8a55c354a7 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 11 Apr 2025 12:00:42 +0200 Subject: [PATCH 08/22] update profiles & flags check handle, take care of Clang profile; enter new compile errors after upgrading VS and toolsets (coming from DXC source files) --- cmake/adjust/flags.cmake | 59 ++++++++++----- cmake/adjust/template/vendor/CXX_Clang.cmake | 52 +------------ cmake/adjust/template/vendor/CXX_MSVC.cmake | 43 +---------- cmake/adjust/template/vendor/C_Clang.cmake | 52 +------------ cmake/adjust/template/vendor/C_MSVC.cmake | 45 +---------- cmake/adjust/template/vendor/impl/Clang.cmake | 75 +++++++++++++++++++ cmake/adjust/template/vendor/impl/MSVC.cmake | 71 ++++++++++++++++++ cmake/adjust/template/vendor/impl/reset.cmake | 8 ++ 8 files changed, 208 insertions(+), 197 deletions(-) create mode 100644 cmake/adjust/template/vendor/impl/Clang.cmake create mode 100644 cmake/adjust/template/vendor/impl/MSVC.cmake create mode 100644 cmake/adjust/template/vendor/impl/reset.cmake diff --git a/cmake/adjust/flags.cmake b/cmake/adjust/flags.cmake index eb16a95791..ead5a086e6 100644 --- a/cmake/adjust/flags.cmake +++ b/cmake/adjust/flags.cmake @@ -12,32 +12,57 @@ define_property(TARGET PROPERTY NBL_CONFIGURATION_MAP BRIEF_DOCS "Stores configuration map for a target, it will evaluate to the configuration it's mapped to" ) -function(NBL_REQUEST_COMPILE_OPTION_SUPPORT _NBL_COMPILE_OPTION_) - set(NBL_COMPILE_OPTION "${_NBL_COMPILE_OPTION_}") +# Usage: NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG CONFIG OPTIONS ) +# LANG, CONFIG - optional, OPTIONS - required +function(NBL_REQUEST_COMPILE_OPTION_SUPPORT) + cmake_parse_arguments(IMPL "" "" "LANG;CONFIG;OPTIONS" ${ARGN}) - foreach(COMPILER IN ITEMS c cxx) + set(DEFAULT_COMPILERS c cxx) + + if(NOT IMPL_LANG) + list(APPEND IMPL_LANG ${DEFAULT_COMPILERS}) + endif() + + if(NOT IMPL_OPTIONS) + message(FATAL_ERROR "NBL_REQUEST_COMPILE_OPTION_SUPPORT's OPTIONS empty!") + endif() + + foreach(COMPILER IN ITEMS ${IMPL_LANG}) string(TOUPPER "${COMPILER}" COMPILER_UPPER) - string(REGEX REPLACE "[-=:;/.]" "_" flag_signature "${NBL_COMPILE_OPTION}") - set(flag_var "__${COMPILER_UPPER}_Flag_${flag_signature}") + if(COMPILER_UPPER STREQUAL C) + macro(VALIDATE_FLAG) + check_c_compiler_flag(${ARGV}) + endmacro() + elseif(COMPILER_UPPER STREQUAL CXX) + macro(VALIDATE_FLAG) + check_cxx_compiler_flag(${ARGV}) + endmacro() + endif() + + foreach(COMPILE_OPTION ${IMPL_OPTIONS}) + string(REGEX REPLACE "[-=:;/.]" "_" FLAG_SIGNATURE "${COMPILE_OPTION}") + set(FLAG_VAR "NBL_${COMPILER_UPPER}_COMPILER_HAS_${FLAG_SIGNATURE}_FLAG") - if(COMPILER STREQUAL "c") - check_c_compiler_flag("${NBL_COMPILE_OPTION}" ${flag_var}) - elseif(COMPILER STREQUAL "cxx") - check_cxx_compiler_flag("${NBL_COMPILE_OPTION}" ${flag_var}) - endif() + VALIDATE_FLAG("${COMPILE_OPTION}" "${FLAG_VAR}") - if(${flag_var}) - message(STATUS "Enabled \"${NBL_COMPILE_OPTION}\" ${COMPILER_UPPER} compile option for Nabla projects!") - set(NBL_${COMPILER_UPPER}_COMPILE_OPTIONS "${NBL_${COMPILER_UPPER}_COMPILE_OPTIONS};${NBL_COMPILE_OPTION}" PARENT_SCOPE) - else() - message(STATUS "Disabled \"${NBL_COMPILE_OPTION}\" ${COMPILER_UPPER} compile option for Nabla projects! (no support)") - endif() + if(${FLAG_VAR}) + if(IMPL_CONFIG) + foreach(CONFIG ${IMPL_CONFIG}) + # TODO: validate (${CONFIG} \in ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER "${CONFIG}" CONFIG_UPPER) + set(NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_COMPILE_OPTIONS "${NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_COMPILE_OPTIONS};${COMPILE_OPTION}" PARENT_SCOPE) + endforeach() + else() + set(NBL_${COMPILER_UPPER}_COMPILE_OPTIONS "${NBL_${COMPILER_UPPER}_COMPILE_OPTIONS};${COMPILE_OPTION}" PARENT_SCOPE) + endif() + endif() + endforeach() endforeach() endfunction() option(NBL_REQUEST_SSE_4_2 "Request compilation with SSE 4.2 instruction set enabled for Nabla projects" ON) -option(NBL_REQUEST_SSE_AXV2 "Request compilation with SSE Intel Advanced Vector Extensions 2 for Nabla projects" ON) +option(NBL_REQUEST_SSE_AVX2 "Request compilation with SSE Intel Advanced Vector Extensions 2 for Nabla projects" ON) # profiles foreach(NBL_COMPILER_LANGUAGE IN ITEMS C CXX) diff --git a/cmake/adjust/template/vendor/CXX_Clang.cmake b/cmake/adjust/template/vendor/CXX_Clang.cmake index 62c12075d1..2cc877c028 100644 --- a/cmake/adjust/template/vendor/CXX_Clang.cmake +++ b/cmake/adjust/template/vendor/CXX_Clang.cmake @@ -1,51 +1,5 @@ include_guard(GLOBAL) -# Debug -set(NBL_CXX_DEBUG_COMPILE_OPTIONS - -ggdb3 -Wall -fno-omit-frame-pointer -fstack-protector-strong -) - -# Release -set(NBL_CXX_RELEASE_COMPILE_OPTIONS - -fexpensive-optimizations -) - -# RelWithDebInfo -set(NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS "") - -# Global -list(APPEND NBL_CXX_COMPILE_OPTIONS - -Wextra - -fno-strict-aliasing - -msse4.2 - -maes - -mfpmath=sse - -Wextra - -Wno-sequence-point - -Wno-unused-parameter - -Wno-unused-but-set-parameter - -Wno-c++98-compat - -Wno-c++98-compat-pedantic - -Wno-padded - -Wno-unsafe-buffer-usage - -Wno-switch-enum - -Wno-error=ignored-attributes - -Wno-error=unused-function - -Wno-error=unused-variable - -Wno-error=unused-parameter - -Wno-error=ignored-attributes - -Wno-error=non-pod-varargs - -fno-exceptions -) - -if(NBL_SANITIZE_ADDRESS) - list(APPEND NBL_CXX_COMPILE_OPTIONS -fsanitize=address) -endif() - -if(NBL_SANITIZE_THREAD) - list(APPEND NBL_CXX_COMPILE_OPTIONS -fsanitize=thread) -endif() - -# our pervious flags-set function called this, does not affect flags nor configs so I will keep it here temporary -# TODO: move it out from the profile -link_libraries(-fuse-ld=gold) \ No newline at end of file +set(LANG CXX) +include("${CMAKE_CURRENT_LIST_DIR}/impl/Clang.cmake") +# append unique CXX options here \ No newline at end of file diff --git a/cmake/adjust/template/vendor/CXX_MSVC.cmake b/cmake/adjust/template/vendor/CXX_MSVC.cmake index 1abb66c9da..59f4e59cdd 100644 --- a/cmake/adjust/template/vendor/CXX_MSVC.cmake +++ b/cmake/adjust/template/vendor/CXX_MSVC.cmake @@ -1,42 +1,5 @@ include_guard(GLOBAL) -# https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 - -# The default instruction set is SSE2 if no /arch option is specified. -if(NBL_REQUEST_SSE_4_2) - NBL_REQUEST_COMPILE_OPTION_SUPPORT("/arch:SSE4.2") -endif() - -# Enables Intel Advanced Vector Extensions 2. -if(NBL_REQUEST_SSE_AXV2) - NBL_REQUEST_COMPILE_OPTION_SUPPORT("/arch:AVX2") -endif() - -# Debug -set(NBL_CXX_DEBUG_COMPILE_OPTIONS - /Zc:__cplusplus /Ob0 /Od /MP${_NBL_JOBS_AMOUNT_} /fp:fast /Zc:wchar_t /INCREMENTAL -) - -if(NBL_SANITIZE_ADDRESS) - list(APPEND NBL_CXX_DEBUG_COMPILE_OPTIONS /RTC1) -endif() - -# Release -set(NBL_CXX_RELEASE_COMPILE_OPTIONS - /Zc:__cplusplus /O2 /Ob2 /DNDEBUG /GL /MP${_NBL_JOBS_AMOUNT_} /Gy- /Zc:wchar_t /sdl- /GF /GS- /fp:fast -) - -# RelWithDebInfo -set(NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS - /Zc:__cplusplus /O2 /Ob1 /DNDEBUG /GL /Zc:wchar_t /MP${_NBL_JOBS_AMOUNT_} /Gy /sdl- /Oy- /fp:fast -) - -if(NBL_SANITIZE_ADDRESS) - list(APPEND NBL_CXX_COMPILE_OPTIONS /fsanitize=address) -endif() - -# this should also be not part of profile, pasting from old flags-set function temporary -# TODO: use profile - -#reason for INCREMENTAL:NO: https://docs.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=vs-2019 /LTCG is not valid for use with /INCREMENTAL. -set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /INCREMENTAL:NO /LTCG:incremental") +set(LANG CXX) +include("${CMAKE_CURRENT_LIST_DIR}/impl/MSVC.cmake") +# append unique CXX options here \ No newline at end of file diff --git a/cmake/adjust/template/vendor/C_Clang.cmake b/cmake/adjust/template/vendor/C_Clang.cmake index 1c00f78e84..046ccaa902 100644 --- a/cmake/adjust/template/vendor/C_Clang.cmake +++ b/cmake/adjust/template/vendor/C_Clang.cmake @@ -1,51 +1,5 @@ include_guard(GLOBAL) -# Debug -set(NBL_C_DEBUG_COMPILE_OPTIONS - -ggdb3 -Wall -fno-omit-frame-pointer -fstack-protector-strong -) - -# Release -set(NBL_C_RELEASE_COMPILE_OPTIONS - -fexpensive-optimizations -) - -# RelWithDebInfo -set(NBL_C_RELWITHDEBINFO_COMPILE_OPTIONS "") - -# Global -list(APPEND NBL_C_COMPILE_OPTIONS - -Wextra - -fno-strict-aliasing - -msse4.2 - -maes - -mfpmath=sse - -Wextra - -Wno-sequence-point - -Wno-unused-parameter - -Wno-unused-but-set-parameter - -Wno-c++98-compat - -Wno-c++98-compat-pedantic - -Wno-padded - -Wno-unsafe-buffer-usage - -Wno-switch-enum - -Wno-error=ignored-attributes - -Wno-error=unused-function - -Wno-error=unused-variable - -Wno-error=unused-parameter - -Wno-error=ignored-attributes - -Wno-error=non-pod-varargs - -fno-exceptions -) - -if(NBL_SANITIZE_ADDRESS) - list(APPEND NBL_C_COMPILE_OPTIONS -fsanitize=address) -endif() - -if(NBL_SANITIZE_THREAD) - list(APPEND NBL_C_COMPILE_OPTIONS -fsanitize=thread) -endif() - -# our pervious flags-set function called this, does not affect flags nor configs so I will keep it here temporary -# TODO: move it out from the profile -link_libraries(-fuse-ld=gold) \ No newline at end of file +set(LANG C) +include("${CMAKE_CURRENT_LIST_DIR}/impl/Clang.cmake") +# append unique C options here \ No newline at end of file diff --git a/cmake/adjust/template/vendor/C_MSVC.cmake b/cmake/adjust/template/vendor/C_MSVC.cmake index ddc0007bb5..f9aca4a5b7 100644 --- a/cmake/adjust/template/vendor/C_MSVC.cmake +++ b/cmake/adjust/template/vendor/C_MSVC.cmake @@ -1,44 +1,5 @@ include_guard(GLOBAL) -# https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 - -# The default instruction set is SSE2 if no /arch option is specified. -if(NBL_REQUEST_SSE_4_2) - NBL_REQUEST_COMPILE_OPTION_SUPPORT("/arch:SSE4.2") -endif() - -# Enables Intel Advanced Vector Extensions 2. -if(NBL_REQUEST_SSE_AXV2) - NBL_REQUEST_COMPILE_OPTION_SUPPORT("/arch:AVX2") -endif() - -NBL_REQUEST_COMPILE_OPTION_SUPPORT(/Zc:preprocessor) - -# Debug -set(NBL_C_DEBUG_COMPILE_OPTIONS - /Ob0 /Od /MP${_NBL_JOBS_AMOUNT_} /fp:fast /Zc:wchar_t /INCREMENTAL -) - -if(NBL_SANITIZE_ADDRESS) - list(APPEND NBL_C_DEBUG_COMPILE_OPTIONS /RTC1) -endif() - -# Release -set(NBL_C_RELEASE_COMPILE_OPTIONS - /O2 /Ob2 /DNDEBUG /GL /MP${_NBL_JOBS_AMOUNT_} /Gy- /Zc:wchar_t /sdl- /GF /GS- /fp:fast -) - -# RelWithDebInfo -set(NBL_C_RELWITHDEBINFO_COMPILE_OPTIONS - /O2 /Ob1 /DNDEBUG /GL /Zc:wchar_t /MP${_NBL_JOBS_AMOUNT_} /Gy /sdl- /Oy- /fp:fast -) - -if(NBL_SANITIZE_ADDRESS) - list(APPEND NBL_C_COMPILE_OPTIONS /fsanitize=address) -endif() - -# this should also be not part of profile, pasting from old flags-set function temporary -# TODO: use profile - -#reason for INCREMENTAL:NO: https://docs.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=vs-2019 /LTCG is not valid for use with /INCREMENTAL. -set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /INCREMENTAL:NO /LTCG:incremental") \ No newline at end of file +set(LANG C) +include("${CMAKE_CURRENT_LIST_DIR}/impl/MSVC.cmake") +# append unique C options here \ No newline at end of file diff --git a/cmake/adjust/template/vendor/impl/Clang.cmake b/cmake/adjust/template/vendor/impl/Clang.cmake new file mode 100644 index 0000000000..868309f828 --- /dev/null +++ b/cmake/adjust/template/vendor/impl/Clang.cmake @@ -0,0 +1,75 @@ +include("${CMAKE_CURRENT_LIST_DIR}/reset.cmake") + +# vendor template with options fitting for both C and CXX LANGs + +if(NOT DEFINED LANG) + message(FATAL_ERROR "LANG must be defined!") +endif() + +if(NBL_REQUEST_SSE_4_2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS + -msse4.2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-msse4.2 + ) +endif() + +if(NBL_REQUEST_SSE_AVX2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS + -mavx2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mavx2 + ) +endif() + +list(APPEND NBL_${LANG}_COMPILE_OPTIONS + -Wextra # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning + -maes # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-maes + -mfpmath=sse # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mfpmath + + # TODO: Yas, eliminate all below + -fno-strict-aliasing + -Wno-sequence-point + -Wno-c++98-compat + -Wno-c++98-compat-pedantic + -Wno-padded + -Wno-unsafe-buffer-usage + -Wno-switch-enum + -Wno-error=ignored-attributes + -Wno-unused-parameter + -Wno-unused-but-set-parameter + -Wno-error=unused-function + -Wno-error=unused-variable + -Wno-error=unused-parameter + -Wno-error=ignored-attributes + -Wno-error=non-pod-varargs +) + +if(NBL_SANITIZE_ADDRESS) + list(APPEND NBL_${LANG}_COMPILE_OPTIONS -fsanitize=address) +endif() + +if(NBL_SANITIZE_THREAD) + list(APPEND NBL_${LANG}_COMPILE_OPTIONS -fsanitize=thread) +endif() + +set(NBL_${LANG}_DEBUG_COMPILE_OPTIONS + -g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g + -mincremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible + -fincremental-extensions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fincremental-extensions + -Wall # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning + -fstack-protector-strong # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fstack-protector-strong + -gline-tables-only # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gline-tables-only + -fno-omit-frame-pointer # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fomit-frame-pointer + -fno-inline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions +) + +set(NBL_${LANG}_RELEASE_COMPILE_OPTIONS + -O2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg + -finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions + -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible +) + +set(NBL_${LANG}_RELWITHDEBINFO_COMPILE_OPTIONS + -g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g + -O1 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg + -finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions + -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible + -fno-omit-frame-pointer # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fomit-frame-pointer +) \ No newline at end of file diff --git a/cmake/adjust/template/vendor/impl/MSVC.cmake b/cmake/adjust/template/vendor/impl/MSVC.cmake new file mode 100644 index 0000000000..5b73b9073e --- /dev/null +++ b/cmake/adjust/template/vendor/impl/MSVC.cmake @@ -0,0 +1,71 @@ +include("${CMAKE_CURRENT_LIST_DIR}/reset.cmake") + +# vendor template with options fitting for both C and CXX LANGs + +if(NOT DEFINED LANG) + message(FATAL_ERROR "LANG must be defined!") +endif() + +if(NBL_REQUEST_SSE_4_2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS + /arch:SSE4.2 # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 + ) +endif() + +if(NBL_REQUEST_SSE_AVX2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS + /arch:AVX2 # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 + ) +endif() + +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS + /Zc:preprocessor # https://learn.microsoft.com/en-us/cpp/build/reference/zc-preprocessor?view=msvc-170 +) + +list(APPEND NBL_${LANG}_COMPILE_OPTIONS + /Zc:__cplusplus # https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170 + /Zc:wchar_t # https://learn.microsoft.com/en-us/cpp/build/reference/zc-wchar-t-wchar-t-is-native-type?view=msvc-170 + /fp:fast # https://learn.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior?view=msvc-170 + /MP${_NBL_JOBS_AMOUNT_} # https://learn.microsoft.com/en-us/cpp/build/reference/mp-build-with-multiple-processes?view=msvc-170 +) + +if(NBL_SANITIZE_ADDRESS) + list(APPEND NBL_${LANG}_COMPILE_OPTIONS + /fsanitize=address # https://learn.microsoft.com/en-us/cpp/build/reference/fsanitize?view=msvc-170 + ) + + list(APPEND NBL_${LANG}_DEBUG_COMPILE_OPTIONS + /RTC1 # https://learn.microsoft.com/en-us/cpp/build/reference/rtc-run-time-error-checks?view=msvc-170 + ) +endif() + +list(APPEND NBL_${LANG}_DEBUG_COMPILE_OPTIONS + /Ob0 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170 + /Od # https://learn.microsoft.com/en-us/cpp/build/reference/od-disable-debug?view=msvc-170 + /INCREMENTAL # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 + /Oy- # https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=msvc-170 +) + +list(APPEND NBL_${LANG}_RELEASE_COMPILE_OPTIONS + /O2 # https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-size-maximize-speed?view=msvc-170 + /Ob2 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170 + /INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 + /DNDEBUG # https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert?view=msvc-170 + /GL # https://learn.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization?view=msvc-170 + /Gy- # https://learn.microsoft.com/en-us/cpp/build/reference/gy-enable-function-level-linking?view=msvc-170 + /sdl- # https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170 + /GF # https://learn.microsoft.com/en-us/cpp/build/reference/gf-eliminate-duplicate-strings?view=msvc-170 + /GS- # https://learn.microsoft.com/en-us/cpp/build/reference/gs-buffer-security-check?view=msvc-170 +) + +list(APPEND NBL_${LANG}_RELWITHDEBINFO_COMPILE_OPTIONS + /O2 # https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-size-maximize-speed?view=msvc-170 + /Ob1 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170 + /INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 + /LTCG:incremental # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170 + /Oy- # https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=msvc-170 + /DNDEBUG # https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert?view=msvc-170 + /GL # https://learn.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization?view=msvc-170 + /Gy # https://learn.microsoft.com/en-us/cpp/build/reference/gy-enable-function-level-linking?view=msvc-170 + /sdl- # https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170 +) \ No newline at end of file diff --git a/cmake/adjust/template/vendor/impl/reset.cmake b/cmake/adjust/template/vendor/impl/reset.cmake new file mode 100644 index 0000000000..6eb95b6cfd --- /dev/null +++ b/cmake/adjust/template/vendor/impl/reset.cmake @@ -0,0 +1,8 @@ +# reset profile vars, for sanity + +foreach(LANG CXX C) + unset(NBL_${LANG}_COMPILE_OPTIONS) + unset(NBL_${LANG}_RELEASE_COMPILE_OPTIONS) + unset(NBL_${LANG}_RELWITHDEBINFO_COMPILE_OPTIONS) + unset(NBL_${LANG}_DEBUG_COMPILE_OPTIONS) +endforeach() \ No newline at end of file From 39bb3e1ba6d46710f8d6a4e98741737da6a2f02f Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 11 Apr 2025 15:40:30 +0200 Subject: [PATCH 09/22] update dxc submodule with fixed clang 19.1.1 build, upgrade & correct NBL_REQUEST_COMPILE_OPTION_SUPPORT, add required instruction set features for simdjson explicitly; now I hit GLI errors due to bad templates --- 3rdparty/dxc/dxc | 2 +- cmake/adjust/flags.cmake | 26 ++++++++++++++++--- cmake/adjust/template/vendor/impl/Clang.cmake | 14 ++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/3rdparty/dxc/dxc b/3rdparty/dxc/dxc index b2e75826b7..49b89ae671 160000 --- a/3rdparty/dxc/dxc +++ b/3rdparty/dxc/dxc @@ -1 +1 @@ -Subproject commit b2e75826b70d85d03686dd8a755ef477b4fa3807 +Subproject commit 49b89ae6712f74fba2352e099f024724bcc32673 diff --git a/cmake/adjust/flags.cmake b/cmake/adjust/flags.cmake index ead5a086e6..6982e0593d 100644 --- a/cmake/adjust/flags.cmake +++ b/cmake/adjust/flags.cmake @@ -15,9 +15,10 @@ define_property(TARGET PROPERTY NBL_CONFIGURATION_MAP # Usage: NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG CONFIG OPTIONS ) # LANG, CONFIG - optional, OPTIONS - required function(NBL_REQUEST_COMPILE_OPTION_SUPPORT) - cmake_parse_arguments(IMPL "" "" "LANG;CONFIG;OPTIONS" ${ARGN}) + cmake_parse_arguments(IMPL "" "REQUEST_VAR;REQUIRED" "LANG;CONFIG;OPTIONS" ${ARGN}) set(DEFAULT_COMPILERS c cxx) + set(REQUEST_ALL_OPTIONS_PRESENT True) if(NOT IMPL_LANG) list(APPEND IMPL_LANG ${DEFAULT_COMPILERS}) @@ -51,14 +52,33 @@ function(NBL_REQUEST_COMPILE_OPTION_SUPPORT) foreach(CONFIG ${IMPL_CONFIG}) # TODO: validate (${CONFIG} \in ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER "${CONFIG}" CONFIG_UPPER) - set(NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_COMPILE_OPTIONS "${NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_COMPILE_OPTIONS};${COMPILE_OPTION}" PARENT_SCOPE) + set(NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_COMPILE_OPTIONS "${NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_COMPILE_OPTIONS};${COMPILE_OPTION}") endforeach() else() - set(NBL_${COMPILER_UPPER}_COMPILE_OPTIONS "${NBL_${COMPILER_UPPER}_COMPILE_OPTIONS};${COMPILE_OPTION}" PARENT_SCOPE) + set(NBL_${COMPILER_UPPER}_COMPILE_OPTIONS "${NBL_${COMPILER_UPPER}_COMPILE_OPTIONS};${COMPILE_OPTION}") endif() + else() + if(IMPL_REQUIRED) + message(FATAL_ERROR "Terminating, NBL_REQUEST_COMPILE_OPTION_SUPPORT was invoked with REQUIRED qualifier!") + endif() + + set(REQUEST_ALL_OPTIONS_PRESENT False) endif() endforeach() + + if(IMPL_CONFIG) + foreach(CONFIG ${IMPL_CONFIG}) + string(TOUPPER "${CONFIG}" CONFIG_UPPER) + set(NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_COMPILE_OPTIONS ${NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_COMPILE_OPTIONS} PARENT_SCOPE) + endforeach() + else() + set(NBL_${COMPILER_UPPER}_COMPILE_OPTIONS ${NBL_${COMPILER_UPPER}_COMPILE_OPTIONS} PARENT_SCOPE) + endif() endforeach() + + if(IMPL_REQUEST_VAR) + set(${IMPL_REQUEST_VAR} ${REQUEST_ALL_OPTIONS_PRESENT} PARENT_SCOPE) + endif() endfunction() option(NBL_REQUEST_SSE_4_2 "Request compilation with SSE 4.2 instruction set enabled for Nabla projects" ON) diff --git a/cmake/adjust/template/vendor/impl/Clang.cmake b/cmake/adjust/template/vendor/impl/Clang.cmake index 868309f828..63549974c6 100644 --- a/cmake/adjust/template/vendor/impl/Clang.cmake +++ b/cmake/adjust/template/vendor/impl/Clang.cmake @@ -18,6 +18,20 @@ if(NBL_REQUEST_SSE_AVX2) ) endif() +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS + # latest Clang(CL) 19.1.1 shipped with VS seems to require explicitly features to be listed (simdjson) + # TODO: Yas, use with REQUEST_VAR, if the request fail then do not promote simdjson to build with + # HASWELL implementation because those flags + avx2 compose subset it wants in this case + + # also instead of enabling single options maybe we could consider requesting an + # instruction implementation set instead, eg -march=haswel, though this approach + # could add a few more flags then we actually need while building - to rethink + + -mbmi # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mbmi + -mlzcnt # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mlzcnt + -mpclmul # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mpclmul +) + list(APPEND NBL_${LANG}_COMPILE_OPTIONS -Wextra # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning -maes # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-maes From cbb4db1c448e9e03972ad20bb23d880db4408361 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 11 Apr 2025 18:42:25 +0200 Subject: [PATCH 10/22] update GLI (use custom location for GLM + fix with templates) and GLM (to latest and our own fork not mine, this one was 6 years old) submodules --- .gitmodules | 6 +++--- 3rdparty/CMakeLists.txt | 9 ++------- 3rdparty/gli | 2 +- 3rdparty/glm | 2 +- src/nbl/CMakeLists.txt | 2 +- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.gitmodules b/.gitmodules index 8edc1cead9..caca5b69a1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -27,9 +27,6 @@ path = 3rdparty/libexpat url = git@github.com:Devsh-Graphics-Programming/libexpat.git branch = master -[submodule "3rdparty/glm"] - path = 3rdparty/glm - url = git@github.com:AnastaZIuk/glm.git [submodule "3rdparty/freetype2"] path = 3rdparty/freetype2 url = git@github.com:Devsh-Graphics-Programming/freetype.git @@ -117,3 +114,6 @@ [submodule "docker/compiler-explorer"] path = docker/compiler-explorer url = git@github.com:Devsh-Graphics-Programming/Compiler-Explorer-Docker.git +[submodule "3rdparty/glm"] + path = 3rdparty/glm + url = git@github.com:Devsh-Graphics-Programming/glm.git diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index d838f92127..0335baf7e5 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -231,7 +231,7 @@ if(_NBL_COMPILE_WITH_OPEN_EXR_) endif() -#gli +# gli option(_NBL_COMPILE_WITH_GLI_ "Build with GLI library" ON) if(_NBL_COMPILE_WITH_GLI_) set(_OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) @@ -240,6 +240,7 @@ if(_NBL_COMPILE_WITH_GLI_) set(BUILD_SHARED_LIBS OFF) set(BUILD_STATIC_LIBS OFF) set(BUILD_TESTING OFF) + set(GLI_GLM_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/glm") add_subdirectory(gli gli EXCLUDE_FROM_ALL) set(BUILD_SHARED_LIBS ${_OLD_BUILD_SHARED_LIBS}) set(BUILD_STATIC_LIBS ${_OLD_BUILD_STATIC_LIBS}) @@ -419,12 +420,6 @@ add_library(aesGladman OBJECT add_subdirectory(argparse argparse EXCLUDE_FROM_ALL) -option(GLM_TEST_ENABLE_SIMD_SSE4_2 "Enable SSE 4.2 optimizations" ON) -option(GLM_TEST_ENABLE "Build unit tests" OFF) -#add_subdirectory(glm EXCLUDE_FROM_ALL) -set(BUILD_SHARED_LIBS ${_OLD_BUILD_SHARED_LIBS}) -set(BUILD_STATIC_LIBS ${_OLD_BUILD_STATIC_LIBS}) - if (NBL_BUILD_MITSUBA_LOADER) option(BUILD_tools "EXPAT: build the xmlwf tool for expat library" OFF) option(BUILD_examples "EXPAT: build the examples for expat library" OFF) diff --git a/3rdparty/gli b/3rdparty/gli index 559cbe1ec3..c4e6446d3b 160000 --- a/3rdparty/gli +++ b/3rdparty/gli @@ -1 +1 @@ -Subproject commit 559cbe1ec38878e182507d331e0780fbae5baf15 +Subproject commit c4e6446d3b646538026fd5a95533daed952878d4 diff --git a/3rdparty/glm b/3rdparty/glm index d162eee1e6..2d4c4b4dd3 160000 --- a/3rdparty/glm +++ b/3rdparty/glm @@ -1 +1 @@ -Subproject commit d162eee1e6f7c317a09229fe6ceab8ec6ab9a4b4 +Subproject commit 2d4c4b4dd31fde06cfffad7915c2b3006402322f diff --git a/src/nbl/CMakeLists.txt b/src/nbl/CMakeLists.txt index 26acb8de10..bde7182ebd 100755 --- a/src/nbl/CMakeLists.txt +++ b/src/nbl/CMakeLists.txt @@ -308,7 +308,7 @@ endif() set(COMMON_INCLUDE_DIRS ${THIRD_PARTY_SOURCE_DIR}/glm - ${THIRD_PARTY_SOURCE_DIR}/renderdoc # for renderdoc api header + ${THIRD_PARTY_SOURCE_DIR}/renderdoc # for renderdoc api header ${CMAKE_BINARY_DIR}/3rdparty/zlib #for dynamically generated zconf.h $ #for dynamically generated pnglibconf.h $ #for dynamically generated jconfig.h From c1cc48b0454b2f5f3d58e6be59fa4ce20fb86717 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sun, 13 Apr 2025 12:39:20 +0200 Subject: [PATCH 11/22] explicitly set limits for Clang toolset, correct some of backend options which must be passed with proxy XClang arg (they were ignored before), use NBL_REQUEST_COMPILE_OPTION_SUPPORT for Clang profile hence enforce flags validation at configure time (TODO: do the same for MSVC). It still crashes at JIT loader's cpp with -1073741819 - windooze access violation, I need to attach diagnostic outputs for LLVM team --- cmake/adjust/flags.cmake | 8 ++- cmake/adjust/template/vendor/impl/Clang.cmake | 55 ++++++++++++------- 2 files changed, 40 insertions(+), 23 deletions(-) diff --git a/cmake/adjust/flags.cmake b/cmake/adjust/flags.cmake index 6982e0593d..1718ac0520 100644 --- a/cmake/adjust/flags.cmake +++ b/cmake/adjust/flags.cmake @@ -15,7 +15,7 @@ define_property(TARGET PROPERTY NBL_CONFIGURATION_MAP # Usage: NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG CONFIG OPTIONS ) # LANG, CONFIG - optional, OPTIONS - required function(NBL_REQUEST_COMPILE_OPTION_SUPPORT) - cmake_parse_arguments(IMPL "" "REQUEST_VAR;REQUIRED" "LANG;CONFIG;OPTIONS" ${ARGN}) + cmake_parse_arguments(IMPL "REQUIRED" "REQUEST_VAR" "LANG;CONFIG;OPTIONS" ${ARGN}) set(DEFAULT_COMPILERS c cxx) set(REQUEST_ALL_OPTIONS_PRESENT True) @@ -43,7 +43,9 @@ function(NBL_REQUEST_COMPILE_OPTION_SUPPORT) foreach(COMPILE_OPTION ${IMPL_OPTIONS}) string(REGEX REPLACE "[-=:;/.]" "_" FLAG_SIGNATURE "${COMPILE_OPTION}") - set(FLAG_VAR "NBL_${COMPILER_UPPER}_COMPILER_HAS_${FLAG_SIGNATURE}_FLAG") + + set(TEST_NAME "NBL_${COMPILER_UPPER}_COMPILER_HAS_${FLAG_SIGNATURE}_FLAG") + set(FLAG_VAR ${TEST_NAME}) VALIDATE_FLAG("${COMPILE_OPTION}" "${FLAG_VAR}") @@ -59,7 +61,7 @@ function(NBL_REQUEST_COMPILE_OPTION_SUPPORT) endif() else() if(IMPL_REQUIRED) - message(FATAL_ERROR "Terminating, NBL_REQUEST_COMPILE_OPTION_SUPPORT was invoked with REQUIRED qualifier!") + message(FATAL_ERROR "${TEST_NAME} (a.k.a \"${COMPILE_OPTION}\") failed because its marked as REQUIRED!") endif() set(REQUEST_ALL_OPTIONS_PRESENT False) diff --git a/cmake/adjust/template/vendor/impl/Clang.cmake b/cmake/adjust/template/vendor/impl/Clang.cmake index 63549974c6..62c1c2568b 100644 --- a/cmake/adjust/template/vendor/impl/Clang.cmake +++ b/cmake/adjust/template/vendor/impl/Clang.cmake @@ -9,15 +9,32 @@ endif() if(NBL_REQUEST_SSE_4_2) NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -msse4.2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-msse4.2 - ) + REQUIRED) # TODO: (****) optional but then adjust 3rdparty options on fail endif() if(NBL_REQUEST_SSE_AVX2) NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -mavx2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mavx2 - ) + REQUIRED) # TODO: (****) endif() +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS + -Xclang=-fconstexpr-backtrace-limit=696969 + -Xclang=-fconstexpr-depth=696969 + -Xclang=-fconstexpr-steps=696969 + -Xclang=-ftemplate-backtrace-limit=0 # no limit + -Xclang=-ftemplate-depth=696969 + -Xclang=-fmacro-backtrace-limit=0 # no limit + -Xclang=-fspell-checking-limit=0 # no limit + -Xclang=-fcaret-diagnostics-max-lines=0 # no limit + + # whenever clang frontend or backend crashes we put diagnostics into top build direcotry + # use it to make a repro and attach to an issue - it outputs preprocessed cpp files with + # sh script for compilation + -fcrash-diagnostics=compiler + "-fcrash-diagnostics-dir=${NBL_ROOT_PATH_BINARY}/.crash-report" +REQUIRED) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS # latest Clang(CL) 19.1.1 shipped with VS seems to require explicitly features to be listed (simdjson) # TODO: Yas, use with REQUEST_VAR, if the request fail then do not promote simdjson to build with @@ -27,12 +44,13 @@ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS # instruction implementation set instead, eg -march=haswel, though this approach # could add a few more flags then we actually need while building - to rethink + ################ + # TODO: (****) -> -mbmi # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mbmi -mlzcnt # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mlzcnt -mpclmul # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mpclmul -) + ################ <- -list(APPEND NBL_${LANG}_COMPILE_OPTIONS -Wextra # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning -maes # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-maes -mfpmath=sse # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mfpmath @@ -53,37 +71,34 @@ list(APPEND NBL_${LANG}_COMPILE_OPTIONS -Wno-error=unused-parameter -Wno-error=ignored-attributes -Wno-error=non-pod-varargs -) +REQUIRED) if(NBL_SANITIZE_ADDRESS) - list(APPEND NBL_${LANG}_COMPILE_OPTIONS -fsanitize=address) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -fsanitize=address REQUIRED) endif() if(NBL_SANITIZE_THREAD) - list(APPEND NBL_${LANG}_COMPILE_OPTIONS -fsanitize=thread) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -fsanitize=thread) endif() -set(NBL_${LANG}_DEBUG_COMPILE_OPTIONS +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG OPTIONS -g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g -mincremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible - -fincremental-extensions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fincremental-extensions + -Xclang=-fincremental-extensions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fincremental-extensions -Wall # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning - -fstack-protector-strong # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fstack-protector-strong -gline-tables-only # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gline-tables-only - -fno-omit-frame-pointer # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fomit-frame-pointer - -fno-inline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions -) + -Xclang=-fno-inline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions +REQUIRED) -set(NBL_${LANG}_RELEASE_COMPILE_OPTIONS +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE OPTIONS -O2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg - -finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions + -Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible -) +REQUIRED) -set(NBL_${LANG}_RELWITHDEBINFO_COMPILE_OPTIONS +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO OPTIONS -g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g -O1 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg - -finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions + -Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible - -fno-omit-frame-pointer # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fomit-frame-pointer -) \ No newline at end of file +REQUIRED) \ No newline at end of file From 16088b980f69b9c13c973b98e28459a48a10abf2 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 14 Apr 2025 10:31:47 +0200 Subject: [PATCH 12/22] Reduce device_capabilities_traits_jit.h instructions & use std::ostringstream for generated line, make it build with Clang(CL) 19.1.1 --- src/nbl/device/DeviceGen.py | 4 ++-- src/nbl/device/gen.py | 2 +- src/nbl/video/CJITIncludeLoader.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nbl/device/DeviceGen.py b/src/nbl/device/DeviceGen.py index 288732de9b..9ad485fc84 100644 --- a/src/nbl/device/DeviceGen.py +++ b/src/nbl/device/DeviceGen.py @@ -562,7 +562,7 @@ def buildTraitsHeader(**params): res.append(emptyline) if 'enable_jit' in params and params['enable_jit']: - res.append("std::string jit_traits = R\"===(") + res.append("std::ostringstream oss;") buildTraitsHeaderHelper( res, @@ -582,7 +582,7 @@ def buildTraitsHeader(**params): ) if 'enable_jit' in params and params['enable_jit']: - res.append(")===\";") + res.append("std::string jit_traits = oss.str();") return res diff --git a/src/nbl/device/gen.py b/src/nbl/device/gen.py index b910d1aa8f..253d529b3d 100644 --- a/src/nbl/device/gen.py +++ b/src/nbl/device/gen.py @@ -120,7 +120,7 @@ args.jit_traits_output_path, buildTraitsHeader, type="JIT Members", - template="NBL_CONSTEXPR_STATIC_INLINE {} {} = )===\" + std::string(\"({})\") + CJITIncludeLoader::to_string({}.{}) + R\"===(;", + template="oss << \"NBL_CONSTEXPR_STATIC_INLINE {} {} = ({})\" + CJITIncludeLoader::to_string({}.{});", limits_json=limits, features_json=features, format_params=["type", "name", "type", "json_type", "cpp_name"], diff --git a/src/nbl/video/CJITIncludeLoader.cpp b/src/nbl/video/CJITIncludeLoader.cpp index edab1c046a..a9f27e5afd 100644 --- a/src/nbl/video/CJITIncludeLoader.cpp +++ b/src/nbl/video/CJITIncludeLoader.cpp @@ -49,4 +49,4 @@ std::string CJITIncludeLoader::collectDeviceCaps(const SPhysicalDeviceLimits& li return start + jit_traits + end; } -} \ No newline at end of file +} From 8f454a98a6b037b6e06f715248d03a2c84de5af5 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 14 Apr 2025 14:47:34 +0200 Subject: [PATCH 13/22] update bzip2 submodule to latest *official* revision, adjust build system + apply workaround for CLang(CL) 19.1.1 due to error : use of undeclared label "errhandler"; for some reason if in single translation unit we have identical label names (goto) in separate function bodies we hit this error --- 3rdparty/CMakeLists.txt | 23 +++++++++++------------ 3rdparty/bzip2 | 2 +- src/nbl/CMakeLists.txt | 8 +++++++- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 0335baf7e5..ffbf8e4cbd 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -247,6 +247,16 @@ if(_NBL_COMPILE_WITH_GLI_) set(BUILD_TESTING ${_OLD_BUILD_TESTING}) endif() +set(ENABLE_STATIC_LIB ON) +set(ENABLE_SHARED_LIB OFF) +set(ENABLE_EXAMPLES OFF) +set(ENABLE_DOCS OFF) +set(ENABLE_APP OFF) +set(ENABLE_LIB_ONLY ON) +set(ENABLE_TESTS OFF) +set(ENABLE_SUMMARY OFF) +add_subdirectory(bzip2 bzip2 EXCLUDE_FROM_ALL) + add_library(lzma OBJECT lzma/C/Alloc.c lzma/C/LzFind.c @@ -263,17 +273,6 @@ add_library(lz4 OBJECT lz4/lib/xxhash.c ) - -add_library(bzip2 OBJECT - bzip2/blocksort.c - bzip2/bzlib.c - bzip2/compress.c - bzip2/crctable.c - bzip2/decompress.c - bzip2/huffman.c - bzip2/randtable.c -) - add_library(spirv_cross OBJECT nbl_spirv_cross/spirv_cfg.cpp nbl_spirv_cross/spirv_cross.cpp @@ -460,7 +459,7 @@ set(NBL_3RDPARTY_TARGETS shaderc_util shaderc jpeg-static - bzip2 + bz2_static simdjson nlohmann_json glslang diff --git a/3rdparty/bzip2 b/3rdparty/bzip2 index c4a14bb87e..f4301b0eac 160000 --- a/3rdparty/bzip2 +++ b/3rdparty/bzip2 @@ -1 +1 @@ -Subproject commit c4a14bb87ee395fb2c69ef5dbb50762fe862517e +Subproject commit f4301b0eac69eb109c5419813102be6f82d2b73a diff --git a/src/nbl/CMakeLists.txt b/src/nbl/CMakeLists.txt index bde7182ebd..0f0e4867b5 100755 --- a/src/nbl/CMakeLists.txt +++ b/src/nbl/CMakeLists.txt @@ -324,7 +324,6 @@ set(NBL_LIBRARY_CREATION_SOURCES ${NABLA_SRCS_COMMON} ${NABLA_HEADERS} $ - $ $ $ $ @@ -391,6 +390,13 @@ if(_NBL_BUILD_DPL_) target_link_libraries(Nabla INTERFACE tbb tbbmalloc tbbmalloc_proxy) endif() +# bzip2 +if(NBL_STATIC_BUILD) + target_link_libraries(Nabla INTERFACE bz2_static) +else() + target_link_libraries(Nabla PRIVATE bz2_static) +endif() + # boost target_include_directories(Nabla PUBLIC "${BOOST_PREPROCESSOR_INCLUDE}") From b4e722a4709af985b1f18ec1d3a35b90663bba46 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 14 Apr 2025 16:14:14 +0200 Subject: [PATCH 14/22] remove `-Xclang=-fincremental-extensions` which causes funny compile errors with goto statements (https://github.com/Devsh-Graphics-Programming/Nabla/commit/8f454a98a6b037b6e06f715248d03a2c84de5af5) --- cmake/adjust/template/vendor/impl/Clang.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/adjust/template/vendor/impl/Clang.cmake b/cmake/adjust/template/vendor/impl/Clang.cmake index 62c1c2568b..1c3581d425 100644 --- a/cmake/adjust/template/vendor/impl/Clang.cmake +++ b/cmake/adjust/template/vendor/impl/Clang.cmake @@ -84,7 +84,6 @@ endif() NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG OPTIONS -g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g -mincremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible - -Xclang=-fincremental-extensions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fincremental-extensions -Wall # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning -gline-tables-only # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gline-tables-only -Xclang=-fno-inline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions From eda05ee269c7be25c8cadfc1c82d459a86e2f692 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Tue, 15 Apr 2025 19:54:26 +0200 Subject: [PATCH 15/22] adjust MSVC profile + correct incremental link options, update NBL_REQUEST_COMPILE_OPTION_SUPPORT & build system to correctly handle compile & link options, validate build options at configure time --- cmake/adjust/flags.cmake | 207 +++++++++++------- cmake/adjust/template/vendor/impl/Clang.cmake | 16 +- cmake/adjust/template/vendor/impl/MSVC.cmake | 37 ++-- cmake/adjust/template/vendor/impl/reset.cmake | 12 +- src/nbl/CMakeLists.txt | 1 + 5 files changed, 162 insertions(+), 111 deletions(-) diff --git a/cmake/adjust/flags.cmake b/cmake/adjust/flags.cmake index 1718ac0520..d8519aea07 100644 --- a/cmake/adjust/flags.cmake +++ b/cmake/adjust/flags.cmake @@ -12,10 +12,13 @@ define_property(TARGET PROPERTY NBL_CONFIGURATION_MAP BRIEF_DOCS "Stores configuration map for a target, it will evaluate to the configuration it's mapped to" ) -# Usage: NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG CONFIG OPTIONS ) -# LANG, CONFIG - optional, OPTIONS - required +# https://github.com/Kitware/CMake/blob/05e77b8a27033e6fd086456bd6cef28338ff1474/Modules/Internal/CheckCompilerFlag.cmake#L26C7-L26C42 +# must be cached because parse utility clears locals in the CheckCompilerFlag module +set(CHECK_COMPILER_FLAG_OUTPUT_VARIABLE NBL_COMPILER_FLAG_OUTPUT CACHE INTERNAL "") + +# Usage: NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG CONFIG COMPILE_OPTIONS LINK_OPTIONS ) function(NBL_REQUEST_COMPILE_OPTION_SUPPORT) - cmake_parse_arguments(IMPL "REQUIRED" "REQUEST_VAR" "LANG;CONFIG;OPTIONS" ${ARGN}) + cmake_parse_arguments(IMPL "REQUIRED" "REQUEST_VAR" "LANG;CONFIG;COMPILE_OPTIONS;LINK_OPTIONS" ${ARGN}) set(DEFAULT_COMPILERS c cxx) set(REQUEST_ALL_OPTIONS_PRESENT True) @@ -24,63 +27,39 @@ function(NBL_REQUEST_COMPILE_OPTION_SUPPORT) list(APPEND IMPL_LANG ${DEFAULT_COMPILERS}) endif() - if(NOT IMPL_OPTIONS) - message(FATAL_ERROR "NBL_REQUEST_COMPILE_OPTION_SUPPORT's OPTIONS empty!") - endif() - foreach(COMPILER IN ITEMS ${IMPL_LANG}) string(TOUPPER "${COMPILER}" COMPILER_UPPER) - if(COMPILER_UPPER STREQUAL C) - macro(VALIDATE_FLAG) - check_c_compiler_flag(${ARGV}) - endmacro() - elseif(COMPILER_UPPER STREQUAL CXX) - macro(VALIDATE_FLAG) - check_cxx_compiler_flag(${ARGV}) - endmacro() - endif() - - foreach(COMPILE_OPTION ${IMPL_OPTIONS}) - string(REGEX REPLACE "[-=:;/.]" "_" FLAG_SIGNATURE "${COMPILE_OPTION}") - - set(TEST_NAME "NBL_${COMPILER_UPPER}_COMPILER_HAS_${FLAG_SIGNATURE}_FLAG") - set(FLAG_VAR ${TEST_NAME}) + foreach(WHAT_OPTIONS IN ITEMS IMPL_COMPILE_OPTIONS IMPL_LINK_OPTIONS) + if(NOT ${WHAT_OPTIONS}) + continue() + endif() - VALIDATE_FLAG("${COMPILE_OPTION}" "${FLAG_VAR}") + set(IMPL_OPTIONS ${${WHAT_OPTIONS}}) + string(REPLACE IMPL_ "" WHAT_OPTIONS "${WHAT_OPTIONS}") - if(${FLAG_VAR}) + foreach(COMPILE_OPTION ${IMPL_OPTIONS}) if(IMPL_CONFIG) foreach(CONFIG ${IMPL_CONFIG}) # TODO: validate (${CONFIG} \in ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER "${CONFIG}" CONFIG_UPPER) - set(NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_COMPILE_OPTIONS "${NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_COMPILE_OPTIONS};${COMPILE_OPTION}") + set(NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_${WHAT_OPTIONS} "${NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_${WHAT_OPTIONS}};${COMPILE_OPTION}") endforeach() else() - set(NBL_${COMPILER_UPPER}_COMPILE_OPTIONS "${NBL_${COMPILER_UPPER}_COMPILE_OPTIONS};${COMPILE_OPTION}") - endif() - else() - if(IMPL_REQUIRED) - message(FATAL_ERROR "${TEST_NAME} (a.k.a \"${COMPILE_OPTION}\") failed because its marked as REQUIRED!") + set(NBL_${COMPILER_UPPER}_${WHAT_OPTIONS} "${NBL_${COMPILER_UPPER}_${WHAT_OPTIONS}};${COMPILE_OPTION}") endif() + endforeach() - set(REQUEST_ALL_OPTIONS_PRESENT False) + if(IMPL_CONFIG) + foreach(CONFIG ${IMPL_CONFIG}) + string(TOUPPER "${CONFIG}" CONFIG_UPPER) + set(NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_${WHAT_OPTIONS} ${NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_${WHAT_OPTIONS}} PARENT_SCOPE) + endforeach() + else() + set(NBL_${COMPILER_UPPER}_${WHAT_OPTIONS} ${NBL_${COMPILER_UPPER}_${WHAT_OPTIONS}} PARENT_SCOPE) endif() endforeach() - - if(IMPL_CONFIG) - foreach(CONFIG ${IMPL_CONFIG}) - string(TOUPPER "${CONFIG}" CONFIG_UPPER) - set(NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_COMPILE_OPTIONS ${NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_COMPILE_OPTIONS} PARENT_SCOPE) - endforeach() - else() - set(NBL_${COMPILER_UPPER}_COMPILE_OPTIONS ${NBL_${COMPILER_UPPER}_COMPILE_OPTIONS} PARENT_SCOPE) - endif() endforeach() - - if(IMPL_REQUEST_VAR) - set(${IMPL_REQUEST_VAR} ${REQUEST_ALL_OPTIONS_PRESENT} PARENT_SCOPE) - endif() endfunction() option(NBL_REQUEST_SSE_4_2 "Request compilation with SSE 4.2 instruction set enabled for Nabla projects" ON) @@ -101,42 +80,104 @@ foreach(NBL_COMPILER_LANGUAGE IN ITEMS C CXX) continue() endif() - # a profile MUST define - # - "NBL_${NBL_COMPILER_LANGUAGE}_${CONFIGURATION}_COMPILE_OPTIONS" (configuration dependent) - # - "NBL_${NBL_COMPILER_LANGUAGE}_COMPILE_OPTIONS" (global) + # a profile MUST define - # a profile MUST NOT define - # - NBL_COMPILE_OPTIONS + # - "NBL_${NBL_COMPILER_LANGUAGE}_${CONFIGURATION}_${WHAT}_OPTIONS" (configuration dependent) + # - "NBL_${NBL_COMPILER_LANGUAGE}_${WHAT}_OPTIONS" (global) - set(NBL_COMPILE_OPTIONS_VAR_NAME NBL_${NBL_COMPILER_LANGUAGE}_COMPILE_OPTIONS) - set(NBL_COMPILE_OPTIONS_VAR_VALUE ${${NBL_COMPILE_OPTIONS_VAR_NAME}}) + # a profile MUST NOT define + # - NBL_${WHAT}_OPTIONS + + # note: + # - use NBL_REQUEST_COMPILE_OPTION_SUPPORT in profile to creates those vars + # - include reset utility in profiles to init vars with empty lists - if(NOT DEFINED ${NBL_COMPILE_OPTIONS_VAR_NAME}) - message(FATAL_ERROR "\"${NBL_PROFILE_PATH}\" did not define \"${NBL_COMPILE_OPTIONS_VAR_NAME}\"!") - endif() + # TODO: DEFINITIONS for WHAT to unify the API - # update map with configuration dependent compile options - foreach(CONFIGURATION IN ITEMS RELEASE RELWITHDEBINFO DEBUG) - set(NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_NAME NBL_${NBL_COMPILER_LANGUAGE}_${CONFIGURATION}_COMPILE_OPTIONS) - set(NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_VALUE ${${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_NAME}}) + foreach(WHAT COMPILE LINK) + set(NBL_OPTIONS_VAR_NAME NBL_${NBL_COMPILER_LANGUAGE}_${WHAT}_OPTIONS) + set(NBL_OPTIONS_VAR_VALUE ${${NBL_OPTIONS_VAR_NAME}}) - if(NOT DEFINED ${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_NAME}) - message(FATAL_ERROR "\"${NBL_PROFILE_PATH}\" did not define \"${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_NAME}\"!") - endif() + if(NOT DEFINED ${NBL_OPTIONS_VAR_NAME}) + message(FATAL_ERROR "\"${NBL_PROFILE_PATH}\" did not define \"${NBL_OPTIONS_VAR_NAME}\"!") + endif() - list(APPEND NBL_${CONFIGURATION}_COMPILE_OPTIONS - # note that "${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_VALUE}" MUST NOT contain ANY - # $<$> generator expression in order to support our configuration mapping features - $<$:${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_VALUE}> - ) + # update map with configuration dependent compile options + foreach(CONFIGURATION IN ITEMS RELEASE RELWITHDEBINFO DEBUG) + set(NBL_CONFIGURATION_OPTIONS_VAR_NAME NBL_${NBL_COMPILER_LANGUAGE}_${CONFIGURATION}_${WHAT}_OPTIONS) + set(NBL_CONFIGURATION_OPTIONS_VAR_VALUE ${${NBL_CONFIGURATION_OPTIONS_VAR_NAME}}) - set(NBL_${CONFIGURATION}_COMPILE_OPTIONS ${NBL_${CONFIGURATION}_COMPILE_OPTIONS}) - endforeach() + if(NOT DEFINED ${NBL_CONFIGURATION_OPTIONS_VAR_NAME}) + message(FATAL_ERROR "\"${NBL_PROFILE_PATH}\" did not define \"${NBL_CONFIGURATION_OPTIONS_VAR_NAME}\"!") + endif() + + set(NBL_${CONFIGURATION}_${WHAT}_OPTIONS ${NBL_${CONFIGURATION}_${WHAT}_OPTIONS} + # note that "${NBL_CONFIGURATION_OPTIONS_VAR_VALUE}" MUST NOT contain ANY + # $<$> generator expression in order to support our configuration mapping features + $<$<${WHAT}_LANGUAGE:${NBL_COMPILER_LANGUAGE}>:${NBL_CONFIGURATION_OPTIONS_VAR_VALUE}> + ) + endforeach() + + # update map with global compile options + set(NBL_${WHAT}_OPTIONS ${NBL_${WHAT}_OPTIONS} + $<$<${WHAT}_LANGUAGE:${NBL_COMPILER_LANGUAGE}>:${NBL_${NBL_COMPILER_LANGUAGE}_${WHAT}_OPTIONS}> + ) + endforeach() + + block() + # validate build with a vendor profile, any warning diagnostic = error + # if you hit error it means the profile generates diagnostics due to: + # - an option (compile or link) which doesn't exist (typo? check vendor docs) + # - a set of options which invalidates an option (eg. MSVC's /INCREMENTAL with /LTCG:incremental is invalid, however linker will emit a warning by default + do a fall-back) + # https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS.html#variable:CMAKE_%3CLANG%3E_FLAGS + # https://cmake.org/cmake/help/latest/module/CheckCompilerFlag.html#command:check_compiler_flag + + set(CMAKE_${NBL_COMPILER_LANGUAGE}_FLAGS) + + foreach(CONFIGURATION IN ITEMS Release RelWithDebInfo Debug) + set(CMAKE_TRY_COMPILE_CONFIGURATION ${CONFIGURATION}) + string(TOUPPER "${CONFIGURATION}" CONFIGURATION) + + set(TEST_NAME "NBL_${NBL_COMPILER_LANGUAGE}_LANG_${CONFIGURATION}_BUILD_OPTIONS_SUPPORT") + set(CMAKE_${NBL_COMPILER_LANGUAGE}_FLAGS_${CONFIGURATION}) + + set(COMPILE_OPTIONS ${NBL_${NBL_COMPILER_LANGUAGE}_COMPILE_OPTIONS} ${NBL_${NBL_COMPILER_LANGUAGE}_${CONFIGURATION}_COMPILE_OPTIONS}) + set(LINK_OPTIONS ${NBL_${NBL_COMPILER_LANGUAGE}_${CONFIGURATION}_LINK_OPTIONS}) + set(COMBINED ${COMPILE_OPTIONS} ${LINK_OPTIONS}) + + set(NBL_OUTPUT_FILE "${CMAKE_BINARY_DIR}/.nbl/try-compile/${TEST_NAME}.output") # no hash in output diagnostic file, desired + + string(SHA1 OPTIONS_HASH "${COMBINED}") + string(APPEND TEST_NAME "_HASH_${OPTIONS_HASH}") + + set(FLAG_VAR ${TEST_NAME}) + set(CMAKE_REQUIRED_LINK_OPTIONS ${LINK_OPTIONS}) + string(REPLACE ";" " " CLI_COMPILE_OPTIONS "${COMPILE_OPTIONS}") + + if(NBL_COMPILER_LANGUAGE STREQUAL C) + check_c_compiler_flag("${CLI_COMPILE_OPTIONS}" "${FLAG_VAR}") + elseif(NBL_COMPILER_LANGUAGE STREQUAL CXX) + check_cxx_compiler_flag("${CLI_COMPILE_OPTIONS}" "${FLAG_VAR}") + endif() + + if(NOT ${FLAG_VAR}) + if(NOT "${NBL_COMPILER_FLAG_OUTPUT}" STREQUAL "") + file(WRITE "${NBL_OUTPUT_FILE}" "${NBL_COMPILER_FLAG_OUTPUT}") # lock into file, do not cache, must read from the file because of NBL_COMPILER_FLAG_OUTPUT availability (CMake module writes an output only once before a signature flag status is created) + endif() - # update map with global compile options - list(APPEND NBL_COMPILE_OPTIONS $<$:${NBL_${NBL_COMPILER_LANGUAGE}_COMPILE_OPTIONS}>) + if(EXISTS "${NBL_OUTPUT_FILE}") + file(READ "${NBL_OUTPUT_FILE}" NBL_DIAGNOSTICS) + set(NBL_DIAGNOSTICS "Diagnostics:\n${NBL_DIAGNOSTICS}") + else() + set(NBL_DIAGNOSTICS) + endif() - set(NBL_COMPILE_OPTIONS ${NBL_COMPILE_OPTIONS}) + if(NOT DEFINED NBL_SKIP_BUILD_OPTIONS_VALIDATION) + message(FATAL_ERROR "${TEST_NAME} failed! To skip the validation define \"NBL_SKIP_BUILD_OPTIONS_VALIDATION\". ${NBL_DIAGNOSTICS}") + endif() + endif() + endforeach() + endblock() endforeach() function(NBL_EXT_P_APPEND_COMPILE_OPTIONS NBL_LIST_NAME MAP_RELEASE MAP_RELWITHDEBINFO MAP_DEBUG) @@ -240,23 +281,27 @@ function(nbl_adjust_flags) # global compile options list(APPEND _D_NBL_COMPILE_OPTIONS_ ${NBL_COMPILE_OPTIONS}) - - # per configuration compile options with mapping - list(APPEND _D_NBL_COMPILE_OPTIONS_ $<$:${NBL_${NBL_MAP_DEBUG_ITEM_U}_COMPILE_OPTIONS}>) - list(APPEND _D_NBL_COMPILE_OPTIONS_ $<$:${NBL_${NBL_MAP_RELEASE_ITEM_U}_COMPILE_OPTIONS}>) - list(APPEND _D_NBL_COMPILE_OPTIONS_ $<$:${NBL_${NBL_MAP_RELWITHDEBINFO_ITEM_U}_COMPILE_OPTIONS}>) - - # configuration mapping properties - string(APPEND _D_NBL_CONFIGURATION_MAP_ $<$:${NBL_MAP_DEBUG_ITEM_U}>) - string(APPEND _D_NBL_CONFIGURATION_MAP_ $<$:${NBL_MAP_RELEASE_ITEM_U}>) - string(APPEND _D_NBL_CONFIGURATION_MAP_ $<$:${NBL_MAP_RELWITHDEBINFO_ITEM_U}>) + + foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER "${CONFIG}" CONFIG_U) + + # per configuration options with mapping + foreach(WHAT COMPILE LINK) + list(APPEND _D_NBL_${WHAT}_OPTIONS_ $<$:${NBL_${NBL_MAP_${CONFIG_U}_ITEM_U}_${WHAT}_OPTIONS}>) + endforeach() + + # configuration mapping properties + string(APPEND _D_NBL_CONFIGURATION_MAP_ $<$:${NBL_MAP_${CONFIG_U}_ITEM_U}>) + endforeach() set_target_properties(${NBL_TARGET_ITEM} PROPERTIES NBL_CONFIGURATION_MAP "${_D_NBL_CONFIGURATION_MAP_}" COMPILE_OPTIONS "${_D_NBL_COMPILE_OPTIONS_}" + LINK_OPTIONS "${_D_NBL_LINK_OPTIONS_}" ) unset(_D_NBL_CONFIGURATION_MAP_) unset(_D_NBL_COMPILE_OPTIONS_) + unset(_D_NBL_LINK_OPTIONS_) set(MAPPED_CONFIG $>) diff --git a/cmake/adjust/template/vendor/impl/Clang.cmake b/cmake/adjust/template/vendor/impl/Clang.cmake index 1c3581d425..9f9f432e98 100644 --- a/cmake/adjust/template/vendor/impl/Clang.cmake +++ b/cmake/adjust/template/vendor/impl/Clang.cmake @@ -9,13 +9,13 @@ endif() if(NBL_REQUEST_SSE_4_2) NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -msse4.2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-msse4.2 - REQUIRED) # TODO: (****) optional but then adjust 3rdparty options on fail +) # TODO: (****) optional but then adjust 3rdparty options on fail endif() if(NBL_REQUEST_SSE_AVX2) NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -mavx2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mavx2 - REQUIRED) # TODO: (****) +) # TODO: (****) endif() NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS @@ -33,7 +33,7 @@ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS # sh script for compilation -fcrash-diagnostics=compiler "-fcrash-diagnostics-dir=${NBL_ROOT_PATH_BINARY}/.crash-report" -REQUIRED) +) NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS # latest Clang(CL) 19.1.1 shipped with VS seems to require explicitly features to be listed (simdjson) @@ -71,10 +71,10 @@ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -Wno-error=unused-parameter -Wno-error=ignored-attributes -Wno-error=non-pod-varargs -REQUIRED) +) if(NBL_SANITIZE_ADDRESS) - NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -fsanitize=address REQUIRED) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -fsanitize=address) endif() if(NBL_SANITIZE_THREAD) @@ -87,17 +87,17 @@ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG OPTIONS -Wall # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning -gline-tables-only # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gline-tables-only -Xclang=-fno-inline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions -REQUIRED) +) NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE OPTIONS -O2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg -Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible -REQUIRED) +) NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO OPTIONS -g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g -O1 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg -Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible -REQUIRED) \ No newline at end of file +) \ No newline at end of file diff --git a/cmake/adjust/template/vendor/impl/MSVC.cmake b/cmake/adjust/template/vendor/impl/MSVC.cmake index 5b73b9073e..62129690f9 100644 --- a/cmake/adjust/template/vendor/impl/MSVC.cmake +++ b/cmake/adjust/template/vendor/impl/MSVC.cmake @@ -7,22 +7,19 @@ if(NOT DEFINED LANG) endif() if(NBL_REQUEST_SSE_4_2) - NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS /arch:SSE4.2 # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 - ) +) # TODO: (****) optional but then adjust 3rdparty options on fail endif() if(NBL_REQUEST_SSE_AVX2) - NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS /arch:AVX2 # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 - ) +) # TODO: (****) optional but then adjust 3rdparty options on fail endif() -NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS /Zc:preprocessor # https://learn.microsoft.com/en-us/cpp/build/reference/zc-preprocessor?view=msvc-170 -) - -list(APPEND NBL_${LANG}_COMPILE_OPTIONS /Zc:__cplusplus # https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170 /Zc:wchar_t # https://learn.microsoft.com/en-us/cpp/build/reference/zc-wchar-t-wchar-t-is-native-type?view=msvc-170 /fp:fast # https://learn.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior?view=msvc-170 @@ -30,42 +27,48 @@ list(APPEND NBL_${LANG}_COMPILE_OPTIONS ) if(NBL_SANITIZE_ADDRESS) - list(APPEND NBL_${LANG}_COMPILE_OPTIONS + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS /fsanitize=address # https://learn.microsoft.com/en-us/cpp/build/reference/fsanitize?view=msvc-170 ) - list(APPEND NBL_${LANG}_DEBUG_COMPILE_OPTIONS + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS /RTC1 # https://learn.microsoft.com/en-us/cpp/build/reference/rtc-run-time-error-checks?view=msvc-170 ) endif() -list(APPEND NBL_${LANG}_DEBUG_COMPILE_OPTIONS +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS /Ob0 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170 /Od # https://learn.microsoft.com/en-us/cpp/build/reference/od-disable-debug?view=msvc-170 - /INCREMENTAL # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 /Oy- # https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=msvc-170 + + LINK_OPTIONS + /INCREMENTAL # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 ) -list(APPEND NBL_${LANG}_RELEASE_COMPILE_OPTIONS +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE COMPILE_OPTIONS /O2 # https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-size-maximize-speed?view=msvc-170 /Ob2 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170 - /INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 /DNDEBUG # https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert?view=msvc-170 /GL # https://learn.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization?view=msvc-170 /Gy- # https://learn.microsoft.com/en-us/cpp/build/reference/gy-enable-function-level-linking?view=msvc-170 /sdl- # https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170 /GF # https://learn.microsoft.com/en-us/cpp/build/reference/gf-eliminate-duplicate-strings?view=msvc-170 /GS- # https://learn.microsoft.com/en-us/cpp/build/reference/gs-buffer-security-check?view=msvc-170 + + LINK_OPTIONS + /INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 ) -list(APPEND NBL_${LANG}_RELWITHDEBINFO_COMPILE_OPTIONS +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO COMPILE_OPTIONS /O2 # https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-size-maximize-speed?view=msvc-170 /Ob1 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170 - /INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 - /LTCG:incremental # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170 /Oy- # https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=msvc-170 /DNDEBUG # https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert?view=msvc-170 /GL # https://learn.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization?view=msvc-170 /Gy # https://learn.microsoft.com/en-us/cpp/build/reference/gy-enable-function-level-linking?view=msvc-170 /sdl- # https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170 + + LINK_OPTIONS + /INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 (note: cannot use with /LTCG:incremental) + /LTCG:incremental # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170 ) \ No newline at end of file diff --git a/cmake/adjust/template/vendor/impl/reset.cmake b/cmake/adjust/template/vendor/impl/reset.cmake index 6eb95b6cfd..fc1230f326 100644 --- a/cmake/adjust/template/vendor/impl/reset.cmake +++ b/cmake/adjust/template/vendor/impl/reset.cmake @@ -1,8 +1,10 @@ -# reset profile vars, for sanity +# init profiles vars by resetting required lists foreach(LANG CXX C) - unset(NBL_${LANG}_COMPILE_OPTIONS) - unset(NBL_${LANG}_RELEASE_COMPILE_OPTIONS) - unset(NBL_${LANG}_RELWITHDEBINFO_COMPILE_OPTIONS) - unset(NBL_${LANG}_DEBUG_COMPILE_OPTIONS) + foreach(WHAT COMPILE LINK DEFINITIONS) + set(NBL_${LANG}_${WHAT}_OPTIONS "") + foreach(CONFIG RELEASE RELWITHDEBINFO DEBUG) + set(NBL_${LANG}_${CONFIG}_${WHAT}_OPTIONS "") + endforeach() + endforeach() endforeach() \ No newline at end of file diff --git a/src/nbl/CMakeLists.txt b/src/nbl/CMakeLists.txt index 0f0e4867b5..98c7620159 100755 --- a/src/nbl/CMakeLists.txt +++ b/src/nbl/CMakeLists.txt @@ -396,6 +396,7 @@ if(NBL_STATIC_BUILD) else() target_link_libraries(Nabla PRIVATE bz2_static) endif() +add_dependencies(Nabla bz2_static) # boost target_include_directories(Nabla PUBLIC "${BOOST_PREPROCESSOR_INCLUDE}") From 25e0120e49206a8585da7d38d174bb153e52203f Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Wed, 16 Apr 2025 11:03:32 +0200 Subject: [PATCH 16/22] get rid of MSVC Release linker fallback with /LTCG due to /GL - manually specify the flag --- cmake/adjust/template/vendor/impl/MSVC.cmake | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmake/adjust/template/vendor/impl/MSVC.cmake b/cmake/adjust/template/vendor/impl/MSVC.cmake index 62129690f9..b1b6b01a99 100644 --- a/cmake/adjust/template/vendor/impl/MSVC.cmake +++ b/cmake/adjust/template/vendor/impl/MSVC.cmake @@ -9,13 +9,13 @@ endif() if(NBL_REQUEST_SSE_4_2) NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS /arch:SSE4.2 # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 -) # TODO: (****) optional but then adjust 3rdparty options on fail +) # TODO: (****) should be (?) optional but then adjust 3rdparty options on fail endif() if(NBL_REQUEST_SSE_AVX2) NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS /arch:AVX2 # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 -) # TODO: (****) optional but then adjust 3rdparty options on fail +) # TODO: (****) should be (?) optional but then adjust 3rdparty options on fail endif() NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS @@ -57,6 +57,7 @@ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE COMPILE_OPTIONS LINK_OPTIONS /INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 + /LTCG # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170 (note: /GL implies fallback with LTCG) ) NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO COMPILE_OPTIONS @@ -69,6 +70,6 @@ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO COMPILE_OP /sdl- # https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170 LINK_OPTIONS - /INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 (note: cannot use with /LTCG:incremental) - /LTCG:incremental # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170 + /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) + /LTCG:incremental # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170 ) \ No newline at end of file From b5d6795e293eba4e6c4e3cf658aa1d0178a03248 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Thu, 17 Apr 2025 17:05:09 +0200 Subject: [PATCH 17/22] Create vendor/template/frontend/MSVC.cmake, update profiles, respect CMAKE__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 --- CMakeLists.txt | 2 +- cmake/adjust/template/vendor/impl/Clang.cmake | 111 ++++++++++-------- cmake/adjust/template/vendor/impl/MSVC.cmake | 69 +---------- .../template/vendor/impl/frontend/MSVC.cmake | 68 +++++++++++ cmake/common.cmake | 8 -- src/nbl/CMakeLists.txt | 7 ++ 6 files changed, 138 insertions(+), 127 deletions(-) create mode 100644 cmake/adjust/template/vendor/impl/frontend/MSVC.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 571743f5b0..3c5fa8da4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # This file is part of the "Nabla Engine". # For conditions of distribution and use, see copyright notice in nabla.h.in or nabla.h -cmake_minimum_required(VERSION 3.29) +cmake_minimum_required(VERSION 3.31) cmake_policy(SET CMP0112 NEW) cmake_policy(SET CMP0141 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0141.html#policy:CMP0141 cmake_policy(SET CMP0118 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0118.html#policy:CMP0118 diff --git a/cmake/adjust/template/vendor/impl/Clang.cmake b/cmake/adjust/template/vendor/impl/Clang.cmake index 9f9f432e98..4002bc4f65 100644 --- a/cmake/adjust/template/vendor/impl/Clang.cmake +++ b/cmake/adjust/template/vendor/impl/Clang.cmake @@ -6,19 +6,16 @@ if(NOT DEFINED LANG) message(FATAL_ERROR "LANG must be defined!") endif() -if(NBL_REQUEST_SSE_4_2) - NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS - -msse4.2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-msse4.2 -) # TODO: (****) optional but then adjust 3rdparty options on fail -endif() - -if(NBL_REQUEST_SSE_AVX2) - NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS - -mavx2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mavx2 -) # TODO: (****) +if(NBL_WITH_COMPILER_CRASH_DIAGNOSTICS) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS + # use it to make a repro and attach to an issue if you Clang crashes + # - it outputs preprocessed cpp files with sh script for compilation + -fcrash-diagnostics=compiler + -fcrash-diagnostics-dir=${NBL_ROOT_PATH_BINARY}/.crash-report + ) endif() -NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS -Xclang=-fconstexpr-backtrace-limit=696969 -Xclang=-fconstexpr-depth=696969 -Xclang=-fconstexpr-steps=696969 @@ -28,21 +25,10 @@ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -Xclang=-fspell-checking-limit=0 # no limit -Xclang=-fcaret-diagnostics-max-lines=0 # no limit - # whenever clang frontend or backend crashes we put diagnostics into top build direcotry - # use it to make a repro and attach to an issue - it outputs preprocessed cpp files with - # sh script for compilation - -fcrash-diagnostics=compiler - "-fcrash-diagnostics-dir=${NBL_ROOT_PATH_BINARY}/.crash-report" -) - -NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS # latest Clang(CL) 19.1.1 shipped with VS seems to require explicitly features to be listed (simdjson) - # TODO: Yas, use with REQUEST_VAR, if the request fail then do not promote simdjson to build with - # HASWELL implementation because those flags + avx2 compose subset it wants in this case - - # also instead of enabling single options maybe we could consider requesting an - # instruction implementation set instead, eg -march=haswel, though this approach - # could add a few more flags then we actually need while building - to rethink + # TODO: Yas, we should first do independent check if host has the flags, if the request fail then + # do not promote simdjson to build with HASWELL implementation because those flags + avx2 compose + # subset it wants in this case ################ # TODO: (****) -> @@ -73,31 +59,54 @@ NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -Wno-error=non-pod-varargs ) -if(NBL_SANITIZE_ADDRESS) - NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -fsanitize=address) -endif() - -if(NBL_SANITIZE_THREAD) - NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS -fsanitize=thread) +if(NBL_REQUEST_SSE_4_2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS + -msse4.2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-msse4.2 +) # TODO: (****) optional but then adjust 3rdparty options on fail endif() -NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG OPTIONS - -g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g - -mincremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible - -Wall # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning - -gline-tables-only # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gline-tables-only - -Xclang=-fno-inline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions -) - -NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE OPTIONS - -O2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg - -Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions - -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible -) - -NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO OPTIONS - -g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g - -O1 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg - -Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions - -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible -) \ No newline at end of file +if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES MSVC) + # ClangCL with MSVC frontend (most of the options are compatible but eg /arch:SSE4.2 seems to be not) + include("${CMAKE_CURRENT_LIST_DIR}/frontend/MSVC.cmake") + + # https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_DEBUG_INFORMATION_FORMAT.html + # should be set with CMAKE_MSVC_DEBUG_INFORMATION_FORMAT but for some reason it doesn't respect with ClangCL even though its MSVC frontend + # https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_FRONTEND_VARIANT.html#variable:CMAKE_%3CLANG%3E_COMPILER_FRONTEND_VARIANT + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG RELWITHDEBINFO COMPILE_OPTIONS /Zi) + return() +else() + if(NBL_REQUEST_SSE_AVX2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS + -mavx2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mavx2 + ) # TODO: (****) + endif() + + if(NBL_SANITIZE_ADDRESS) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS -fsanitize=address) + endif() + + if(NBL_SANITIZE_THREAD) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS -fsanitize=thread) + endif() + + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS + -g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g + -mincremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible + -Wall # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning + -gline-tables-only # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gline-tables-only + -Xclang=-fno-inline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions + ) + + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE COMPILE_OPTIONS + -O2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg + -Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions + -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible + ) + + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO COMPILE_OPTIONS + -g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g + -O1 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg + -Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions + -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible + ) +endif() \ No newline at end of file diff --git a/cmake/adjust/template/vendor/impl/MSVC.cmake b/cmake/adjust/template/vendor/impl/MSVC.cmake index b1b6b01a99..803adb1754 100644 --- a/cmake/adjust/template/vendor/impl/MSVC.cmake +++ b/cmake/adjust/template/vendor/impl/MSVC.cmake @@ -1,75 +1,10 @@ include("${CMAKE_CURRENT_LIST_DIR}/reset.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/frontend/MSVC.cmake") # vendor template with options fitting for both C and CXX LANGs -if(NOT DEFINED LANG) - message(FATAL_ERROR "LANG must be defined!") -endif() - if(NBL_REQUEST_SSE_4_2) NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS /arch:SSE4.2 # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 ) # TODO: (****) should be (?) optional but then adjust 3rdparty options on fail -endif() - -if(NBL_REQUEST_SSE_AVX2) - NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS - /arch:AVX2 # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 -) # TODO: (****) should be (?) optional but then adjust 3rdparty options on fail -endif() - -NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS - /Zc:preprocessor # https://learn.microsoft.com/en-us/cpp/build/reference/zc-preprocessor?view=msvc-170 - /Zc:__cplusplus # https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170 - /Zc:wchar_t # https://learn.microsoft.com/en-us/cpp/build/reference/zc-wchar-t-wchar-t-is-native-type?view=msvc-170 - /fp:fast # https://learn.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior?view=msvc-170 - /MP${_NBL_JOBS_AMOUNT_} # https://learn.microsoft.com/en-us/cpp/build/reference/mp-build-with-multiple-processes?view=msvc-170 -) - -if(NBL_SANITIZE_ADDRESS) - NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS - /fsanitize=address # https://learn.microsoft.com/en-us/cpp/build/reference/fsanitize?view=msvc-170 - ) - - NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS - /RTC1 # https://learn.microsoft.com/en-us/cpp/build/reference/rtc-run-time-error-checks?view=msvc-170 - ) -endif() - -NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS - /Ob0 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170 - /Od # https://learn.microsoft.com/en-us/cpp/build/reference/od-disable-debug?view=msvc-170 - /Oy- # https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=msvc-170 - - LINK_OPTIONS - /INCREMENTAL # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 -) - -NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE COMPILE_OPTIONS - /O2 # https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-size-maximize-speed?view=msvc-170 - /Ob2 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170 - /DNDEBUG # https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert?view=msvc-170 - /GL # https://learn.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization?view=msvc-170 - /Gy- # https://learn.microsoft.com/en-us/cpp/build/reference/gy-enable-function-level-linking?view=msvc-170 - /sdl- # https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170 - /GF # https://learn.microsoft.com/en-us/cpp/build/reference/gf-eliminate-duplicate-strings?view=msvc-170 - /GS- # https://learn.microsoft.com/en-us/cpp/build/reference/gs-buffer-security-check?view=msvc-170 - - LINK_OPTIONS - /INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 - /LTCG # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170 (note: /GL implies fallback with LTCG) -) - -NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO COMPILE_OPTIONS - /O2 # https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-size-maximize-speed?view=msvc-170 - /Ob1 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170 - /Oy- # https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=msvc-170 - /DNDEBUG # https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert?view=msvc-170 - /GL # https://learn.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization?view=msvc-170 - /Gy # https://learn.microsoft.com/en-us/cpp/build/reference/gy-enable-function-level-linking?view=msvc-170 - /sdl- # https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170 - - LINK_OPTIONS - /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) - /LTCG:incremental # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170 -) \ No newline at end of file +endif() \ No newline at end of file diff --git a/cmake/adjust/template/vendor/impl/frontend/MSVC.cmake b/cmake/adjust/template/vendor/impl/frontend/MSVC.cmake new file mode 100644 index 0000000000..06ab606104 --- /dev/null +++ b/cmake/adjust/template/vendor/impl/frontend/MSVC.cmake @@ -0,0 +1,68 @@ +# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_FRONTEND_VARIANT.html#variable:CMAKE_%3CLANG%3E_COMPILER_FRONTEND_VARIANT +# vendor frontend template with options fitting for both C and CXX LANGs + +if(NOT DEFINED LANG) + message(FATAL_ERROR "LANG must be defined!") +endif() + +if(NBL_REQUEST_SSE_AVX2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS + /arch:AVX2 # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 +) # TODO: (****) should be (?) optional but then adjust 3rdparty options on fail +endif() + +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS + /Zc:preprocessor # https://learn.microsoft.com/en-us/cpp/build/reference/zc-preprocessor?view=msvc-170 + /Zc:__cplusplus # https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170 + /Zc:wchar_t # https://learn.microsoft.com/en-us/cpp/build/reference/zc-wchar-t-wchar-t-is-native-type?view=msvc-170 + /fp:fast # https://learn.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior?view=msvc-170 + /MP${_NBL_JOBS_AMOUNT_} # https://learn.microsoft.com/en-us/cpp/build/reference/mp-build-with-multiple-processes?view=msvc-170 +) + +if(NBL_SANITIZE_ADDRESS) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS + /fsanitize=address # https://learn.microsoft.com/en-us/cpp/build/reference/fsanitize?view=msvc-170 + ) + + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS + /RTC1 # https://learn.microsoft.com/en-us/cpp/build/reference/rtc-run-time-error-checks?view=msvc-170 + ) +endif() + +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS + /Ob0 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170 + /Od # https://learn.microsoft.com/en-us/cpp/build/reference/od-disable-debug?view=msvc-170 + /Oy- # https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=msvc-170 + + LINK_OPTIONS + /INCREMENTAL # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 +) + +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE COMPILE_OPTIONS + /O2 # https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-size-maximize-speed?view=msvc-170 + /Ob2 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170 + /DNDEBUG # https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert?view=msvc-170 + /GL # https://learn.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization?view=msvc-170 + /Gy- # https://learn.microsoft.com/en-us/cpp/build/reference/gy-enable-function-level-linking?view=msvc-170 + /sdl- # https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170 + /GF # https://learn.microsoft.com/en-us/cpp/build/reference/gf-eliminate-duplicate-strings?view=msvc-170 + /GS- # https://learn.microsoft.com/en-us/cpp/build/reference/gs-buffer-security-check?view=msvc-170 + + LINK_OPTIONS + /INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 + /LTCG # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170 (note: /GL implies fallback with LTCG) +) + +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO COMPILE_OPTIONS + /O2 # https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-size-maximize-speed?view=msvc-170 + /Ob1 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170 + /Oy- # https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=msvc-170 + /DNDEBUG # https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert?view=msvc-170 + /GL # https://learn.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization?view=msvc-170 + /Gy # https://learn.microsoft.com/en-us/cpp/build/reference/gy-enable-function-level-linking?view=msvc-170 + /sdl- # https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170 + + LINK_OPTIONS + /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) + /LTCG:incremental # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170 +) \ No newline at end of file diff --git a/cmake/common.cmake b/cmake/common.cmake index 69b915bbc7..69a0a5b980 100755 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -69,14 +69,6 @@ macro(nbl_create_executable_project _EXTRA_SOURCES _EXTRA_OPTIONS _EXTRA_INCLUDE add_executable(${EXECUTABLE_NAME} ${NBL_EXECUTABLE_SOURCES}) nbl_handle_runtime_lib_properties(${EXECUTABLE_NAME}) - - if(WIN32 AND MSVC) - if(NBL_COMPILER_DYNAMIC_RUNTIME) - target_link_options(${EXECUTABLE_NAME} PUBLIC "/DELAYLOAD:$") - endif() - - target_link_options(${EXECUTABLE_NAME} PUBLIC "/DELAYLOAD:dxcompiler.dll") - endif() endif() nbl_handle_dll_definitions(${EXECUTABLE_NAME} PUBLIC) diff --git a/src/nbl/CMakeLists.txt b/src/nbl/CMakeLists.txt index 98c7620159..ad5aa7c463 100755 --- a/src/nbl/CMakeLists.txt +++ b/src/nbl/CMakeLists.txt @@ -358,6 +358,13 @@ endif() target_compile_definitions(Nabla PRIVATE __NBL_BUILDING_NABLA__) +target_link_options(Nabla INTERFACE # proxy to downstream targets + $<$: + $<$:/DELAYLOAD:$> + /DELAYLOAD:dxcompiler.dll + > +) + if (ANDROID) add_library(android_native_app_glue STATIC ${ANDROID_NDK_ROOT_PATH}/sources/android/native_app_glue/android_native_app_glue.c From a1b9b99777496b62f439dd82d4e19a2c667a7d1d Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 18 Apr 2025 11:17:28 +0200 Subject: [PATCH 18/22] ah DXC needs to point to devshFixes_clang_19_1_1 --- 3rdparty/dxc/dxc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/dxc/dxc b/3rdparty/dxc/dxc index 5ab4d368b6..4621c707ed 160000 --- a/3rdparty/dxc/dxc +++ b/3rdparty/dxc/dxc @@ -1 +1 @@ -Subproject commit 5ab4d368b666d365217c751f5610b496b828ff96 +Subproject commit 4621c707ed774ab8382391f6434810ebecd37111 From 77ed416733f6e337445df4e27b1b62043da47eb7 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 18 Apr 2025 12:56:18 +0200 Subject: [PATCH 19/22] keep designated initializers for ISwapchain's SSharedCreationParams, use hlsl::ShaderStage in IDescriptorSetLayout.h --- include/nbl/asset/IDescriptorSetLayout.h | 3 ++- include/nbl/video/ISwapchain.h | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/nbl/asset/IDescriptorSetLayout.h b/include/nbl/asset/IDescriptorSetLayout.h index ec3c182fdc..a50f267355 100644 --- a/include/nbl/asset/IDescriptorSetLayout.h +++ b/include/nbl/asset/IDescriptorSetLayout.h @@ -330,7 +330,8 @@ class IDescriptorSetLayout : public IDescriptorSetLayoutBase bindings[i].binding = i; bindings[i].type = type; bindings[i].createFlags = SBinding::E_CREATE_FLAGS::ECF_NONE; - bindings[i].stageFlags = stageAccessFlags ? stageAccessFlags[i]:asset::IShader::E_SHADER_STAGE::ESS_ALL_OR_LIBRARY; + + bindings[i].stageFlags = stageAccessFlags ? stageAccessFlags[i]:hlsl::ShaderStage::ESS_ALL_OR_LIBRARY; bindings[i].count = counts ? counts[i]:1u; bindings[i].samplers = nullptr; } diff --git a/include/nbl/video/ISwapchain.h b/include/nbl/video/ISwapchain.h index 99ba2e7975..882ac16648 100644 --- a/include/nbl/video/ISwapchain.h +++ b/include/nbl/video/ISwapchain.h @@ -21,8 +21,6 @@ class ISwapchain : public IBackendObject struct SSharedCreationParams { - SSharedCreationParams() {} - inline bool valid(const IPhysicalDevice* physDev, const ISurface* surface) const { ISurface::SCapabilities caps; @@ -456,12 +454,13 @@ class ISwapchain : public IBackendObject { return params.deduce(getOriginDevice()->getPhysicalDevice(),m_params.surface.get(),{&m_params.sharedParams.presentMode.value,1},{&m_params.sharedParams.compositeAlpha.value,1},{&m_params.sharedParams.preTransform.value,1}); } - inline core::smart_refctd_ptr recreate(SSharedCreationParams params={}) + inline core::smart_refctd_ptr recreate(SSharedCreationParams params) { if (!deduceRecreationParams(params)) return nullptr; return recreate_impl(std::move(params)); } + inline core::smart_refctd_ptr recreate() { return recreate({}); } // Vulkan: const VkSwapchainKHR* virtual const void* getNativeHandle() const = 0; From a2a7e72f42501fe71b6f4f141b92bac4d2b8cd93 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 18 Apr 2025 13:47:08 +0200 Subject: [PATCH 20/22] for my sanity - add -DNDEBUG to Clang profile (Unix) --- cmake/adjust/template/vendor/impl/Clang.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/adjust/template/vendor/impl/Clang.cmake b/cmake/adjust/template/vendor/impl/Clang.cmake index 4002bc4f65..a8ddfcb6bf 100644 --- a/cmake/adjust/template/vendor/impl/Clang.cmake +++ b/cmake/adjust/template/vendor/impl/Clang.cmake @@ -101,6 +101,7 @@ else() -O2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg -Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible + -DNDEBUG ) NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO COMPILE_OPTIONS @@ -108,5 +109,6 @@ else() -O1 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg -Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible + -DNDEBUG ) endif() \ No newline at end of file From cde9e7971a890baf9b82fde753307d38cadf17fe Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 18 Apr 2025 17:24:28 +0200 Subject: [PATCH 21/22] correct CMAKE_MSVC_DEBUG_INFORMATION_FORMAT logic hence make it work without need to specify debug format flags with ClangCL by hand, enforce ProgramDatabase regardless the case (https://gitlab.kitware.com/cmake/cmake/-/issues/26879#note_1649970) --- CMakeLists.txt | 8 +------- cmake/adjust/flags.cmake | 13 +++---------- cmake/adjust/template/vendor/impl/Clang.cmake | 5 ----- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c5fa8da4a..60c10acfab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,13 +24,7 @@ option(NBL_STATIC_BUILD "" OFF) # ON for static builds, OFF for shared option(NBL_COMPILER_DYNAMIC_RUNTIME "" ON) option(NBL_SANITIZE_ADDRESS OFF) -if(CMAKE_CXX_COMPILER_ID STREQUAL MSVC) - if(NBL_SANITIZE_ADDRESS) - set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$:ProgramDatabase>") - else() - set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$:EditAndContinue>$<$:ProgramDatabase>") - endif() -endif() +set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT $<$:ProgramDatabase>) # ignored on non xMSVC-ABI targets if(NBL_STATIC_BUILD) message(STATUS "Static Nabla build enabled!") diff --git a/cmake/adjust/flags.cmake b/cmake/adjust/flags.cmake index d8519aea07..1e67914ae0 100644 --- a/cmake/adjust/flags.cmake +++ b/cmake/adjust/flags.cmake @@ -305,17 +305,10 @@ function(nbl_adjust_flags) set(MAPPED_CONFIG $>) - if(CMAKE_CXX_COMPILER_ID STREQUAL MSVC) - if(NBL_SANITIZE_ADDRESS) - set(NBL_TARGET_MSVC_DEBUG_INFORMATION_FORMAT "$<$,$>:ProgramDatabase>") - else() - set(NBL_TARGET_MSVC_DEBUG_INFORMATION_FORMAT "$<$:EditAndContinue>$<$:ProgramDatabase>") - endif() - endif() - set_target_properties(${NBL_TARGET_ITEM} PROPERTIES - MSVC_DEBUG_INFORMATION_FORMAT "${NBL_TARGET_MSVC_DEBUG_INFORMATION_FORMAT}" - ) + MSVC_DEBUG_INFORMATION_FORMAT $<$,$>:ProgramDatabase> # ignored on non xMSVC-ABI targets + ) + math(EXPR _NBL_ARG_I_ "${_NBL_ARG_I_} + 1") endwhile() else() # DIRECTORY mode diff --git a/cmake/adjust/template/vendor/impl/Clang.cmake b/cmake/adjust/template/vendor/impl/Clang.cmake index a8ddfcb6bf..0b00294411 100644 --- a/cmake/adjust/template/vendor/impl/Clang.cmake +++ b/cmake/adjust/template/vendor/impl/Clang.cmake @@ -68,11 +68,6 @@ endif() if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES MSVC) # ClangCL with MSVC frontend (most of the options are compatible but eg /arch:SSE4.2 seems to be not) include("${CMAKE_CURRENT_LIST_DIR}/frontend/MSVC.cmake") - - # https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_DEBUG_INFORMATION_FORMAT.html - # should be set with CMAKE_MSVC_DEBUG_INFORMATION_FORMAT but for some reason it doesn't respect with ClangCL even though its MSVC frontend - # https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_FRONTEND_VARIANT.html#variable:CMAKE_%3CLANG%3E_COMPILER_FRONTEND_VARIANT - NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG RELWITHDEBINFO COMPILE_OPTIONS /Zi) return() else() if(NBL_REQUEST_SSE_AVX2) From 6e4392e7e6e0e87a990fc7d65677e94c41ae9ef3 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Tue, 22 Apr 2025 10:35:39 +0200 Subject: [PATCH 22/22] add more NEW policies, leave TODO comment for `cmake_policy` --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 60c10acfab..a63d30a89d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,12 @@ # For conditions of distribution and use, see copyright notice in nabla.h.in or nabla.h cmake_minimum_required(VERSION 3.31) -cmake_policy(SET CMP0112 NEW) +# TODO: Yas - once we deploy 4.x we will fire `cmake_policy` instead of manually picking policies +# https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html#policy-version +# also we should update deps which throw warnings about < 3.10 compatibility +cmake_policy(SET CMP0003 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0077.html#cmp0077 +cmake_policy(SET CMP0077 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0077.html#cmp0077 +cmake_policy(SET CMP0112 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0112.html#cmp0112 cmake_policy(SET CMP0141 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0141.html#policy:CMP0141 cmake_policy(SET CMP0118 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0118.html#policy:CMP0118