From e04781edbd316e6dafdcf4c4e87d1930c134eaad Mon Sep 17 00:00:00 2001 From: Ali Cheraghi Date: Fri, 22 Nov 2024 20:15:34 +0330 Subject: [PATCH 1/4] rename `NBL_ALL_TARGETS` to `NBL_ALL_3RDPARTY_TARGETS` Signed-off-by: Ali Cheraghi --- 3rdparty/CMakeLists.txt | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index c0bae07ec..9f6eb3f94 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -274,6 +274,11 @@ add_library(lzma STATIC lzma/C/LzFind.c lzma/C/LzmaDec.c lzma/C/LzmaEnc.c + lzma/C/LzFind.c + lzma/C/LzFindMt.c + lzma/C/LzFindOpt.c + lzma/C/CpuArch.c + lzma/C/Threads.c ) target_compile_definitions(lzma PRIVATE _7ZIP_ST) @@ -578,8 +583,17 @@ function(NBL_ADJUST_FOLDER NBL_TARGET NBL_PREFIX KEEP_PRESENT_PREFIX) endif() endfunction() -NBL_GET_ALL_TARGETS(NBL_ALL_TARGETS) -foreach(NBL_TARGET IN LISTS NBL_ALL_TARGETS) +NBL_GET_ALL_TARGETS(NBL_ALL_3RDPARTY_TARGETS) +foreach(NBL_TARGET IN LISTS NBL_ALL_3RDPARTY_TARGETS) + get_target_property(NBL_TARGET_SOURCE_DIR ${NBL_TARGET} SOURCE_DIR) + if(${NBL_TARGET_SOURCE_DIR} MATCHES "${NBL_ROOT_PATH}/3rdparty/dxc*" OR ${NBL_TARGET_SOURCE_DIR} MATCHES "${NBL_ROOT_PATH}/3rdparty/libjpeg-turbo*") + message("found:${NBL_TARGET}:${NBL_TARGET_SOURCE_DIR}") + list(APPEND NBL_IMMUTABLE_TARGETS NBL_TARGET) + endif() +endforeach() + +NBL_GET_ALL_TARGETS(NBL_ALL_3RDPARTY_TARGETS) +foreach(NBL_TARGET IN LISTS NBL_ALL_3RDPARTY_TARGETS) NBL_ADJUST_FOLDER(${NBL_TARGET} 3rdparty/excluded ON) # first pass to group all targets in IDE set_target_properties(${NBL_TARGET} PROPERTIES EXCLUDE_FROM_ALL TRUE) # in case somebody forgots to exclude subdirectory force all as excluded endforeach() @@ -646,4 +660,8 @@ if(NBL_3RDPARTY_EXPORT_TO_BUILD_TREE) export(TARGETS extensions APPEND FILE "${NBL_EXTENSIONS_EXPORT_INCLUDE}") endif() -# nbl_install_dir("${CMAKE_CURRENT_SOURCE_DIR}/parallel-hashmap/parallel_hashmap") # TODO: THIS SHOULD NOT BE EXPOSED \ No newline at end of file +# nbl_install_dir("${CMAKE_CURRENT_SOURCE_DIR}/parallel-hashmap/parallel_hashmap") # TODO: THIS SHOULD NOT BE EXPOSED + +set(NBL_ALL_3RDPARTY_TARGETS + ${NBL_ALL_3RDPARTY_TARGETS} +PARENT_SCOPE) \ No newline at end of file From 2b1aa854400e2ac209bc822324c357622e92952b Mon Sep 17 00:00:00 2001 From: Ali Cheraghi Date: Thu, 28 Nov 2024 17:10:38 +0330 Subject: [PATCH 2/4] build: fix dxc flags conflict Signed-off-by: Ali Cheraghi --- 3rdparty/CMakeLists.txt | 21 ++++++++++++--------- cmake/adjust/flags.cmake | 14 +------------- cmake/common.cmake | 13 +++++++++++++ cmake/init/buildSystem.cmake | 8 +------- 4 files changed, 27 insertions(+), 29 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 9f6eb3f94..b2ed06d55 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -585,14 +585,17 @@ endfunction() NBL_GET_ALL_TARGETS(NBL_ALL_3RDPARTY_TARGETS) foreach(NBL_TARGET IN LISTS NBL_ALL_3RDPARTY_TARGETS) - get_target_property(NBL_TARGET_SOURCE_DIR ${NBL_TARGET} SOURCE_DIR) - if(${NBL_TARGET_SOURCE_DIR} MATCHES "${NBL_ROOT_PATH}/3rdparty/dxc*" OR ${NBL_TARGET_SOURCE_DIR} MATCHES "${NBL_ROOT_PATH}/3rdparty/libjpeg-turbo*") - message("found:${NBL_TARGET}:${NBL_TARGET_SOURCE_DIR}") - list(APPEND NBL_IMMUTABLE_TARGETS NBL_TARGET) - endif() + get_target_property(NBL_TARGET_SOURCE_DIR ${NBL_TARGET} SOURCE_DIR) + set(NBL_3RDPARTY_IMMUTABLE_TARGET_SRC_PATTERNS "${NBL_ROOT_PATH}/3rdparty/dxc*") + NBL_MATCH_PATTERNS("${NBL_TARGET_SOURCE_DIR}" NBL_3RDPARTY_IMMUTABLE_TARGET_SRC_PATTERNS MATCH_FOUND) + + if(MATCH_FOUND) + list(APPEND NBL_IMMUTABLE_TARGETS ${NBL_TARGET}) + else() + list(APPEND NBL_MUTABLE_TARGETS ${NBL_TARGET}) + endif() endforeach() -NBL_GET_ALL_TARGETS(NBL_ALL_3RDPARTY_TARGETS) foreach(NBL_TARGET IN LISTS NBL_ALL_3RDPARTY_TARGETS) NBL_ADJUST_FOLDER(${NBL_TARGET} 3rdparty/excluded ON) # first pass to group all targets in IDE set_target_properties(${NBL_TARGET} PROPERTIES EXCLUDE_FROM_ALL TRUE) # in case somebody forgots to exclude subdirectory force all as excluded @@ -662,6 +665,6 @@ endif() # nbl_install_dir("${CMAKE_CURRENT_SOURCE_DIR}/parallel-hashmap/parallel_hashmap") # TODO: THIS SHOULD NOT BE EXPOSED -set(NBL_ALL_3RDPARTY_TARGETS - ${NBL_ALL_3RDPARTY_TARGETS} -PARENT_SCOPE) \ No newline at end of file +set(NBL_MUTABLE_TARGETS ${NBL_MUTABLE_TARGETS} PARENT_SCOPE) +set(NBL_IMMUTABLE_TARGETS ${NBL_IMMUTABLE_TARGETS} PARENT_SCOPE) +set(NBL_ALL_3RDPARTY_TARGETS ${NBL_ALL_3RDPARTY_TARGETS} PARENT_SCOPE) \ No newline at end of file diff --git a/cmake/adjust/flags.cmake b/cmake/adjust/flags.cmake index dda941598..c07aa051d 100644 --- a/cmake/adjust/flags.cmake +++ b/cmake/adjust/flags.cmake @@ -177,19 +177,7 @@ function(nbl_adjust_flags) unset(_D_NBL_CONFIGURATION_MAP_) unset(_D_NBL_COMPILE_OPTIONS_) - set(MAPPED_CONFIG $>) - - if(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}" - ) + set(MAPPED_CONFIG $>) math(EXPR _NBL_ARG_I_ "${_NBL_ARG_I_} + 1") endwhile() else() # DIRECTORY mode diff --git a/cmake/common.cmake b/cmake/common.cmake index 12cc3e584..24b5b569a 100755 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -1335,3 +1335,16 @@ macro(NBL_TARGET_FORCE_ASSEMBLER_EXECUTABLE _NBL_TARGET_ _NBL_ASM_DIALECT_ _NBL_ PROPERTIES LANGUAGE "${_NBL_ASM_DIALECT_}" ) endmacro() + +function(NBL_MATCH_PATTERNS IN_STRING PATTERNS_VAR RESULT_VAR) + set(NBL_MATCHED FALSE) + + foreach(PATTERN IN LISTS ${PATTERNS_VAR}) + if(${IN_STRING} MATCHES "${PATTERN}") + set(NBL_MATCHED TRUE) + break() + endif() + endforeach() + + set(${RESULT_VAR} ${NBL_MATCHED} PARENT_SCOPE) +endfunction() \ No newline at end of file diff --git a/cmake/init/buildSystem.cmake b/cmake/init/buildSystem.cmake index 23f0eb47b..1d3180245 100644 --- a/cmake/init/buildSystem.cmake +++ b/cmake/init/buildSystem.cmake @@ -98,13 +98,7 @@ option(NBL_STATIC_BUILD "" OFF) # ON for static builds, OFF for shared option(NBL_DYNAMIC_MSVC_RUNTIME "" ON) option(NBL_SANITIZE_ADDRESS OFF) -if(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>") if(NOT NBL_STATIC_BUILD) if(WIN32 AND MSVC) # TODO: needs correcting those checks From 05daf2ccf1115eb7808ac6a9519450668d0d3385 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sat, 30 Nov 2024 14:20:08 +0100 Subject: [PATCH 3/4] fix issues with ASM dialects, make Nabla build, mark TODOs for Ali --- 3rdparty/CMakeLists.txt | 1 - cmake/common.cmake | 11 ----------- cmake/init/buildSystem.cmake | 6 +----- src/nbl/CMakeLists.txt | 15 ++++++++------- 4 files changed, 9 insertions(+), 24 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index b2ed06d55..42f5296a2 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -215,7 +215,6 @@ target_include_directories(jpegConfig INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/libjpeg-turbo" INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/libjpeg-turbo" ) -NBL_TARGET_FORCE_ASSEMBLER_EXECUTABLE(simd ASM_NASM libjpeg-turbo/simd/) unset(CMAKE_INSTALL_DOCDIR) unset(CMAKE_INSTALL_MANDIR) diff --git a/cmake/common.cmake b/cmake/common.cmake index 24b5b569a..93df35d21 100755 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -1325,17 +1325,6 @@ function(NBL_IMPORT_VS_CONFIG) endif() endfunction() -macro(NBL_TARGET_FORCE_ASSEMBLER_EXECUTABLE _NBL_TARGET_ _NBL_ASM_DIALECT_ _NBL_PREPEND_PATH_TRANSFORM_) - get_target_property(_NBL_TARGET_SOURCES_ "${_NBL_TARGET_}" SOURCES) - list(FILTER _NBL_TARGET_SOURCES_ INCLUDE REGEX "\\.asm$") - list(TRANSFORM _NBL_TARGET_SOURCES_ PREPEND "${_NBL_PREPEND_PATH_TRANSFORM_}") - - set_source_files_properties(${_NBL_TARGET_SOURCES_} - TARGET_DIRECTORY "${_NBL_TARGET_}" - PROPERTIES LANGUAGE "${_NBL_ASM_DIALECT_}" - ) -endmacro() - function(NBL_MATCH_PATTERNS IN_STRING PATTERNS_VAR RESULT_VAR) set(NBL_MATCHED FALSE) diff --git a/cmake/init/buildSystem.cmake b/cmake/init/buildSystem.cmake index 1d3180245..0314de51d 100644 --- a/cmake/init/buildSystem.cmake +++ b/cmake/init/buildSystem.cmake @@ -194,11 +194,7 @@ if (UNIX) endif() endif() -enable_language(C CXX ASM) - -if(MSVC) - enable_language(ASM_MASM) -endif() +enable_language(C CXX) if(NOT TARGET Threads::Threads) find_package(Threads REQUIRED) diff --git a/src/nbl/CMakeLists.txt b/src/nbl/CMakeLists.txt index 061893015..a299f7cd1 100755 --- a/src/nbl/CMakeLists.txt +++ b/src/nbl/CMakeLists.txt @@ -161,13 +161,14 @@ start_tracking_variables_for_propagation_to_parent() add_subdirectory(ext) propagate_changed_variables_to_parent_scope() -if(NOT NBL_STATIC_BUILD) - add_custom_command(OUTPUT "${NABLA_PUBLIC_DEFINE_H}" - COMMAND "${CMAKE_COMMAND}" -DNBL_ROOT_PATH:PATH=${NBL_ROOT_PATH} -DNBL_WRAPPER_FILE:FILEPATH=${_NBL_DEFINE_FILE_WRAPPER_} -DNBL_GEN_DIRECTORY:PATH=${NABLA_PUBLIC_DEFINE_H_DIRECTORY} -D_NABLA_DLL_NAME_:STRING=$ -D_DXC_DLL_NAME_:STRING=${DXC_DLL_NAME} -D_NABLA_INSTALL_DIR_:PATH="${CMAKE_INSTALL_PREFIX}" -P ${NBL_ROOT_PATH}/cmake/scripts/nbl/nablaDefines.cmake - COMMENT "Generating \"${NABLA_PUBLIC_DEFINE_H}\"!" - VERBATIM - ) -endif() +# TODO: we should be able to generate all of that at CMake generate time (no build target required) +add_custom_target(nbl_define_h + COMMAND "${CMAKE_COMMAND}" -DNBL_ROOT_PATH:PATH=${NBL_ROOT_PATH} -DNBL_WRAPPER_FILE:FILEPATH=${_NBL_DEFINE_FILE_WRAPPER_} -DNBL_GEN_DIRECTORY:PATH=${NABLA_PUBLIC_DEFINE_H_DIRECTORY} -D_NABLA_DLL_NAME_:STRING=$ -D_DXC_DLL_NAME_:STRING=${DXC_DLL_NAME} -D_NABLA_INSTALL_DIR_:PATH="${CMAKE_INSTALL_PREFIX}" -P ${NBL_ROOT_PATH}/cmake/scripts/nbl/nablaDefines.cmake + BYPRODUCTS "${NABLA_PUBLIC_DEFINE_H}" + COMMENT "Generating \"${NABLA_PUBLIC_DEFINE_H}\"!" + VERBATIM +) +add_dependencies(Nabla nbl_define_h) if(NBL_STATIC_BUILD) target_link_libraries(Nabla INTERFACE 3rdparty) From 8a48ad9a1f2003e8aedf2ffc2e72df3758f73003 Mon Sep 17 00:00:00 2001 From: Ali Cheraghi Date: Thu, 5 Dec 2024 16:59:16 +0330 Subject: [PATCH 4/4] build: fix define.h missing build error and include `git-version-tracking` from root `CMakeLists.txt` Co-authored-by: AnastaZIuk Signed-off-by: Ali Cheraghi --- 3rdparty/CMakeLists.txt | 8 -------- CMakeLists.txt | 8 ++++++++ cmake/scripts/nbl/nablaDefines.cmake | 6 +----- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 42f5296a2..cbf612baf 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -311,14 +311,6 @@ add_library(spirv_cross STATIC ) target_compile_definitions(spirv_cross PUBLIC SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS) -# cmake-git-version-tracking -# note that checking if a repository is dirty may cost build time (especially a lot if like us you have a lot of submodules) - by default we run with all checks but if you want to increase build time iterations I recommend to exclude this check -option(GIT_EXCLUDE_IS_DIRTY "Exclude IS_DIRTY from git tracking checks, will increase build time iterations at the expense of the meta information loss" OFF) -add_subdirectory(git-version-tracking EXCLUDE_FROM_ALL) -NBL_ADD_GIT_TRACKING_META_LIBRARY(nabla "${NBL_ROOT_PATH}") -NBL_ADD_GIT_TRACKING_META_LIBRARY(dxc "${CMAKE_CURRENT_SOURCE_DIR}/dxc/dxc") -NBL_GENERATE_GIT_TRACKING_META() - if(NBL_BUILD_IMGUI) set(NBL_IMGUI_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/imgui") set(NBL_IMGUI_TEST_ENGINE_PROJECT_ROOT "${THIRD_PARTY_SOURCE_DIR}/imgui_test_engine") diff --git a/CMakeLists.txt b/CMakeLists.txt index 38827dadc..85aa9edd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,14 @@ option(NBL_3RDPARTY_FIND_EXPORTED_TARGETS "Do not add ./3rdparty as subdirecotry #include(submodules/update) find_package(Python3 COMPONENTS Interpreter REQUIRED) +# cmake-git-version-tracking +# note that checking if a repository is dirty may cost build time (especially a lot if like us you have a lot of submodules) - by default we run with all checks but if you want to increase build time iterations I recommend to exclude this check +option(GIT_EXCLUDE_IS_DIRTY "Exclude IS_DIRTY from git tracking checks, will increase build time iterations at the expense of the meta information loss" OFF) +add_subdirectory(3rdparty/git-version-tracking EXCLUDE_FROM_ALL) +NBL_ADD_GIT_TRACKING_META_LIBRARY(nabla "${NBL_ROOT_PATH}") +NBL_ADD_GIT_TRACKING_META_LIBRARY(dxc "3rdparty/dxc/dxc") +NBL_GENERATE_GIT_TRACKING_META() + #NBL_3RDPARTY_EXPORT_MODULE_NAME #NBL_EXTENSIONS_EXPORT_MODULE_NAME diff --git a/cmake/scripts/nbl/nablaDefines.cmake b/cmake/scripts/nbl/nablaDefines.cmake index 615e041aa..4b246e0c6 100644 --- a/cmake/scripts/nbl/nablaDefines.cmake +++ b/cmake/scripts/nbl/nablaDefines.cmake @@ -30,11 +30,7 @@ else() message(FATAL_ERROR "NBL_WRAPPER_FILE variable must be specified for this script!") endif() -if(DEFINED NBL_GEN_DIRECTORY) # directory where nabla.h will be created - if(NOT EXISTS ${NBL_GEN_DIRECTORY}) - message(FATAL_ERROR "NBL_GEN_DIRECTORY as '${NBL_GEN_DIRECTORY}' is invalid!") - endif() -else() +if(NOT DEFINED NBL_GEN_DIRECTORY) # directory where nabla.h will be created message(FATAL_ERROR "NBL_GEN_DIRECTORY variable must be specified for this script!") endif()