Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

newBuildSystem post master merge compile fixes & updates #796

Open
wants to merge 4 commits into
base: newBuildSystem
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -274,6 +273,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)

Expand Down Expand Up @@ -307,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")
Expand Down Expand Up @@ -578,8 +574,20 @@ 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)
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()

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()
Expand Down Expand Up @@ -646,4 +654,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
# nbl_install_dir("${CMAKE_CURRENT_SOURCE_DIR}/parallel-hashmap/parallel_hashmap") # TODO: THIS SHOULD NOT BE EXPOSED

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)
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 1 addition & 13 deletions cmake/adjust/flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,7 @@ function(nbl_adjust_flags)
unset(_D_NBL_CONFIGURATION_MAP_)
unset(_D_NBL_COMPILE_OPTIONS_)

set(MAPPED_CONFIG $<TARGET_GENEX_EVAL:${NBL_TARGET_ITEM},$<TARGET_PROPERTY:${NBL_TARGET_ITEM},NBL_CONFIGURATION_MAP>>)

if(MSVC)
if(NBL_SANITIZE_ADDRESS)
set(NBL_TARGET_MSVC_DEBUG_INFORMATION_FORMAT "$<$<OR:$<STREQUAL:${MAPPED_CONFIG},DEBUG>,$<STREQUAL:${MAPPED_CONFIG},RELWITHDEBINFO>>:ProgramDatabase>")
else()
set(NBL_TARGET_MSVC_DEBUG_INFORMATION_FORMAT "$<$<STREQUAL:${MAPPED_CONFIG},DEBUG>:EditAndContinue>$<$<STREQUAL:${MAPPED_CONFIG},RELWITHDEBINFO>:ProgramDatabase>")
endif()
endif()

set_target_properties(${NBL_TARGET_ITEM} PROPERTIES
MSVC_DEBUG_INFORMATION_FORMAT "${NBL_TARGET_MSVC_DEBUG_INFORMATION_FORMAT}"
)
set(MAPPED_CONFIG $<TARGET_GENEX_EVAL:${NBL_TARGET_ITEM},$<TARGET_PROPERTY:${NBL_TARGET_ITEM},NBL_CONFIGURATION_MAP>>)
math(EXPR _NBL_ARG_I_ "${_NBL_ARG_I_} + 1")
endwhile()
else() # DIRECTORY mode
Expand Down
22 changes: 12 additions & 10 deletions cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1325,13 +1325,15 @@ 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)

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()
14 changes: 2 additions & 12 deletions cmake/init/buildSystem.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>")
else()
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug>:EditAndContinue>$<$<CONFIG:RelWithDebInfo>:ProgramDatabase>")
endif()
endif()
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>")

if(NOT NBL_STATIC_BUILD)
if(WIN32 AND MSVC) # TODO: needs correcting those checks
Expand Down Expand Up @@ -200,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)
Expand Down
6 changes: 1 addition & 5 deletions cmake/scripts/nbl/nablaDefines.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
15 changes: 8 additions & 7 deletions src/nbl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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=$<TARGET_FILE_NAME:Nabla> -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=$<TARGET_FILE_NAME:Nabla> -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)
Expand Down