Skip to content

Commit 4abbacf

Browse files
committed
Merge branch 'master' into hlsl_path_tracer_example
2 parents 563e072 + 65edc85 commit 4abbacf

File tree

10 files changed

+92
-112
lines changed

10 files changed

+92
-112
lines changed

3rdparty/CMakeLists.txt

Lines changed: 77 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,35 @@ include(../cmake/common.cmake)
66

77
project(Nabla-3rdparty LANGUAGES CXX C)
88
enable_language(C CXX ASM ASM_NASM)
9+
set(BUILD_SHARED_LIBS OFF)
10+
set(SKIP_INSTALL_ALL ON)
11+
set(BUILD_TESTING OFF)
912

1013
option(NBL_FORCE_RELEASE_3RDPARTY "Force map 3rdaprty's configuration regardless Nabla configuration to Release" OFF)
1114
option(NBL_FORCE_RELWITHDEBINFO_3RDPARTY "Force map 3rdaprty's configuration regardless Nabla configuration to RelWithDebInfo" OFF)
1215

16+
# zlib
17+
set(ZLIB_BUILD_SHARED OFF)
18+
set(ZLIB_BUILD_STATIC ON)
19+
set(ZLIB_INSTALL OFF)
20+
set(ZLIB_BUILD_TESTING OFF)
21+
set(ZLIB_BUILD_MINIZIP OFF)
22+
add_subdirectory(zlib zlib EXCLUDE_FROM_ALL)
23+
get_target_property(ZLIB_BINARY_DIR zlibstatic "BINARY_DIR")
24+
set_target_properties(zlibstatic PROPERTIES
25+
ARCHIVE_OUTPUT_DIRECTORY $<1:${ZLIB_BINARY_DIR}>
26+
DEBUG_POSTFIX "d"
27+
RELWITHDEBINFO_POSTFIX "rwdi"
28+
OUTPUT_NAME zlibstatic
29+
)
30+
add_library(ZLIB::ZLIB ALIAS zlibstatic) # trick projects which want to use it via alias
31+
1332
# nlohmann_json
1433
set(JSON_BuildTests OFF)
1534
add_subdirectory(nlohmann_json nlohmann_json EXCLUDE_FROM_ALL)
1635

1736
# simdjson
18-
set(_OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
19-
set(_OLD_BUILD_STATIC_LIBS ${BUILD_STATIC_LIBS})
20-
set(_OLD_BUILD_TESTING ${BUILD_TESTING})
21-
set(BUILD_SHARED_LIBS OFF)
22-
set(BUILD_STATIC_LIBS OFF)
23-
set(BUILD_TESTING OFF)
2437
add_subdirectory(simdjson simdjson EXCLUDE_FROM_ALL)
25-
set(BUILD_SHARED_LIBS ${_OLD_BUILD_SHARED_LIBS})
26-
set(BUILD_STATIC_LIBS ${_OLD_BUILD_STATIC_LIBS})
27-
set(BUILD_TESTING ${_OLD_BUILD_TESTING})
2838

2939
# freetype2
3040
set(FT_WITH_HARFBUZZ OFF)
@@ -87,64 +97,6 @@ endif()
8797
# boost
8898
add_subdirectory(boost boost EXCLUDE_FROM_ALL)
8999

90-
# zlib (target is zlibstatic)
91-
set(_OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
92-
set(_OLD_SKIP_INSTALL_ALL ${SKIP_INSTALL_ALL})
93-
set(BUILD_SHARED_LIBS OFF)
94-
set(SKIP_INSTALL_ALL ON)
95-
96-
file(LOCK "${CMAKE_CURRENT_SOURCE_DIR}/zlib" DIRECTORY GUARD PROCESS RESULT_VARIABLE NBL_LOCK TIMEOUT 60)
97-
add_subdirectory(zlib zlib EXCLUDE_FROM_ALL)
98-
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/zlib/zconf.h.included")
99-
execute_process(COMMAND "${CMAKE_COMMAND}" -E rename zconf.h.included zconf.h
100-
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/zlib"
101-
) # clean zlib git working-tree
102-
endif()
103-
file(LOCK "${CMAKE_CURRENT_SOURCE_DIR}/zlib" DIRECTORY RELEASE RESULT_VARIABLE NBL_LOCK)
104-
set(SKIP_INSTALL_ALL ${_OLD_SKIP_INSTALL_ALL})
105-
set(BUILD_SHARED_LIBS ${_OLD_BUILD_SHARED_LIBS})
106-
107-
get_target_property(ZLIB_SOURCE_DIR zlibstatic "SOURCE_DIR")
108-
get_target_property(ZLIB_BINARY_DIR zlibstatic "BINARY_DIR")
109-
get_filename_component(_ORIGINAL_SOURCE_ "${ZLIB_SOURCE_DIR}" ABSOLUTE)
110-
get_filename_component(_COPY_BIN_SOURCE_ "${ZLIB_BINARY_DIR}/copy_source" ABSOLUTE)
111-
112-
add_custom_target(zlib_copy
113-
COMMAND ${CMAKE_COMMAND} -E rm -Rf "${_COPY_BIN_SOURCE_}"
114-
COMMAND ${CMAKE_COMMAND} -E copy_directory "${_ORIGINAL_SOURCE_}" "${_COPY_BIN_SOURCE_}"
115-
COMMAND ${CMAKE_COMMAND} -E rm -f ${_COPY_BIN_SOURCE_}/zconf.h # no duplicates in include search paths!
116-
COMMENT "Copying zlib..."
117-
)
118-
119-
unset(_ORIGINAL_SOURCE_)
120-
unset(_COPY_BIN_SOURCE_)
121-
122-
#https://stackoverflow.com/questions/47175912/using-cmake-how-to-stop-the-debug-and-release-subdirectories
123-
set_target_properties(zlibstatic PROPERTIES ARCHIVE_OUTPUT_DIRECTORY $<1:${ZLIB_BINARY_DIR}>)
124-
set_target_properties(zlibstatic PROPERTIES DEBUG_POSTFIX "d")
125-
if (MSVC)
126-
set(ZLIB_BINARY_DIR_DEBUG "${ZLIB_BINARY_DIR}")
127-
set(ZLIB_BINARY_DIR_RELEASE "${ZLIB_BINARY_DIR}")
128-
set(ZLIB_BINARY_DIR_RELWITHDEBINFO "${ZLIB_BINARY_DIR}")
129-
get_target_property(ZLIB_NAME zlibstatic "NAME")
130-
else()
131-
set(ZLIB_BINARY_DIR_DEBUG ${ZLIB_BINARY_DIR})
132-
set(ZLIB_BINARY_DIR_RELEASE ${ZLIB_BINARY_DIR})
133-
set(ZLIB_BINARY_DIR_RELWITHDEBINFO ${ZLIB_BINARY_DIR})
134-
get_target_property(ZLIB_NAME zlibstatic "OUTPUT_NAME")
135-
endif()
136-
137-
get_target_property(ZLIB_DEBUG_POSTFIX zlibstatic "DEBUG_POSTFIX")
138-
set(ZLIB_INCLUDE_DIR "${THIRD_PARTY_SOURCE_DIR}/zlib;${THIRD_PARTY_BINARY_DIR}/zlib" CACHE INTERNAL "" FORCE)
139-
set(ZLIB_LIBRARY_DEBUG "${ZLIB_BINARY_DIR_DEBUG}/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_NAME}${ZLIB_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE INTERNAL "" FORCE)
140-
set(ZLIB_LIBRARY_RELEASE "${ZLIB_BINARY_DIR_RELEASE}/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE INTERNAL "" FORCE)
141-
set(ZLIB_LIBRARY_RELWITHDEBINFO "${ZLIB_BINARY_DIR_RELWITHDEBINFO}/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE INTERNAL "" FORCE)
142-
set(ZLIB_LIBRARY # for PNGLIB purposes
143-
$<$<CONFIG:Debug>:${ZLIB_LIBRARY_DEBUG}>
144-
$<$<CONFIG:Release>:${ZLIB_LIBRARY_RELEASE}>
145-
$<$<CONFIG:RelWithDebInfo>:${ZLIB_LIBRARY_RELWITHDEBINFO}>
146-
CACHE INTERNAL "" FORCE)
147-
148100
set(SPIRV_HEADERS_SKIP_INSTALL ON CACHE INTERNAL "Skip SPIRV-Headers install")
149101
set(SPIRV_HEADERS_SKIP_EXAMPLES ON CACHE INTERNAL "Skip SPIRV-Headers examples")
150102
add_subdirectory("${DXC_SPIRV_HEADERS_DIR}" SPIRV-Headers EXCLUDE_FROM_ALL)
@@ -167,29 +119,67 @@ set(SHADERC_SKIP_INSTALL ON CACHE INTERNAL "Install shaderc?")
167119
add_subdirectory(shaderc shaderc EXCLUDE_FROM_ALL)
168120

169121
# libjpeg-turbo
170-
option(WITH_SIMD "libjpeg-turbo" ON)
171-
option(WITH_MEM_SRCDST "libjpeg-turbo" ON)
172-
option(WITH_TURBOJPEG "libjpeg-turbo" ON)
173-
option(ENABLE_STATIC "libjpeg-turbo" ON)
174-
option(ENABLE_SHARED "libjpeg-turbo" OFF)
175-
option(WITH_CRT_DLL "libjpeg-turbo" OFF)
176-
option(WITH_FUZZ "libjpeg-turbo" OFF)
177-
option(WITH_JAVA "libjpeg-turbo" OFF)
178-
set(CMAKE_INSTALL_DOCDIR "${CMAKE_CURRENT_BINARY_DIR}/libjpeg-turbo/install/docdir")
179-
set(CMAKE_INSTALL_MANDIR "${CMAKE_CURRENT_BINARY_DIR}/libjpeg-turbo/install/mandir")
180-
add_subdirectory(libjpeg-turbo libjpeg-turbo EXCLUDE_FROM_ALL)
181-
NBL_TARGET_FORCE_ASSEMBLER_EXECUTABLE(simd ASM_NASM libjpeg-turbo/simd/)
182-
183-
unset(CMAKE_INSTALL_DOCDIR)
184-
unset(CMAKE_INSTALL_MANDIR)
122+
set(NBL_JPEG_CMAKE_OPTIONS
123+
-DCMAKE_MSVC_RUNTIME_LIBRARY:STATIC=MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${NBL_COMPILER_DYNAMIC_RUNTIME}>:DLL>
124+
-DCMAKE_POLICY_DEFAULT_CMP0057=NEW
125+
-DCMAKE_POLICY_DEFAULT_CMP0091=NEW
126+
-DENABLE_SHARED=OFF
127+
-DENABLE_STATIC=ON
128+
-DWITH_CRT_DLL=ON
129+
-DWITH_SIMD=ON
130+
-DWITH_MEM_SRCDST=ON
131+
-DWITH_TURBOJPEG=ON
132+
-DWITH_FUZZ=OFF
133+
-DWITH_JAVA=OFF
134+
)
135+
136+
if(NOT NBL_IS_MULTI_CONFIG)
137+
list(APPEND NBL_JPEG_CMAKE_OPTIONS "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
138+
endif()
139+
140+
if(NOT CMAKE_GENERATOR MATCHES "Ninja*")
141+
list(APPEND NBL_JPEG_CMAKE_OPTIONS -Ax64)
142+
endif()
143+
144+
if(CMAKE_GENERATOR_TOOLSET)
145+
list(APPEND NBL_JPEG_CMAKE_OPTIONS -T "${CMAKE_GENERATOR_TOOLSET}")
146+
endif()
147+
148+
if(CMAKE_TOOLCHAIN_FILE)
149+
list(APPEND NBL_JPEG_CMAKE_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
150+
endif()
151+
152+
# TODO: might find an alternative library which supports add_subdirectory, untill then we need to switch to a workaround just like
153+
# we do for DXC due to: https://github.com/libjpeg-turbo/libjpeg-turbo/blob/0b742742c873025e2a127918d4969238ace7ae5b/CMakeLists.txt#L69
154+
execute_process(COMMAND "${CMAKE_COMMAND}" -S "${CMAKE_CURRENT_SOURCE_DIR}/libjpeg-turbo" -B "${CMAKE_CURRENT_BINARY_DIR}/libjpeg-turbo" -G "${CMAKE_GENERATOR}" ${NBL_JPEG_CMAKE_OPTIONS}
155+
RESULT_VARIABLE JPEG_CMAKE_RESULT
156+
OUTPUT_VARIABLE JPEG_CMAKE_STREAM_PIPE
157+
)
158+
159+
if(NOT "${JPEG_CMAKE_RESULT}" STREQUAL "0")
160+
message(FATAL_ERROR "${JPEG_CMAKE_STREAM_PIPE}")
161+
endif()
162+
163+
set(JPEG_LIB_OUTPUT "${THIRD_PARTY_BINARY_DIR}/libjpeg-turbo/$<CONFIG>/jpeg-static${CMAKE_STATIC_LIBRARY_SUFFIX}")
164+
add_custom_command(OUTPUT ${JPEG_LIB_OUTPUT}
165+
COMMAND "${CMAKE_COMMAND}" --build "${THIRD_PARTY_BINARY_DIR}/libjpeg-turbo" -t jpeg-static --config $<CONFIG>
166+
COMMENT "Building libjpeg-turbo static library"
167+
VERBATIM USES_TERMINAL
168+
)
169+
add_library(jpeg-static INTERFACE ${JPEG_LIB_OUTPUT})
170+
target_include_directories(jpeg-static INTERFACE
171+
"${THIRD_PARTY_SOURCE_DIR}/libjpeg-turbo/src"
172+
"${THIRD_PARTY_BINARY_DIR}/libjpeg-turbo"
173+
)
174+
target_link_libraries(jpeg-static INTERFACE "${JPEG_LIB_OUTPUT}")
185175

186176
# blake3
187177
add_subdirectory(blake/c EXCLUDE_FROM_ALL)
188178

189-
#manipulating libpng cmake options from within cmake script
190-
set(PNG_BUILD_ZLIB ON CACHE INTERNAL "" FORCE) # get ZLIB from our /3rdparty
191-
option(PNG_SHARED "Build shared lib" OFF)
192-
option(PNG_TESTS "Build libpng tests" OFF)
179+
# manipulating libpng cmake options from within cmake script
180+
set(PNG_BUILD_ZLIB OFF)
181+
set(PNG_SHARED OFF)
182+
set(PNG_TESTS OFF)
193183
add_subdirectory(libpng libpng EXCLUDE_FROM_ALL)
194184
add_dependencies(png_static zlibstatic)
195185

@@ -441,7 +431,7 @@ if (NBL_BUILD_MITSUBA_LOADER)
441431
)
442432
set(MITSUBA_LOADER_DEPENDENTS ${MITSUBA_LOADER_DEPENDENTS} PARENT_SCOPE)
443433
set(MITSUBA_LOADER_DEPENDENT_LIBS
444-
expat "${ZLIB_LIBRARY}"
434+
expat zlibstatic
445435
)
446436
set(MITSUBA_LOADER_DEPENDENT_LIBS ${MITSUBA_LOADER_DEPENDENT_LIBS} PARENT_SCOPE)
447437
endif()
@@ -468,7 +458,6 @@ set(NBL_3RDPARTY_TARGETS
468458
zlibstatic
469459
shaderc_util
470460
shaderc
471-
jpeg-static
472461
bz2_static
473462
simdjson
474463
nlohmann_json

3rdparty/dxc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ if(CMAKE_TOOLCHAIN_FILE)
9898
list(APPEND NBL_DXC_CMAKE_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
9999
endif()
100100

101+
# TODO: add_subdirectory but don't modify dxc target compile options
101102
execute_process(COMMAND "${CMAKE_COMMAND}" -C "${CMAKE_CURRENT_SOURCE_DIR}/dxc/cmake/caches/PredefinedParams.cmake" -S "${CMAKE_CURRENT_SOURCE_DIR}/dxc" -B "${DXC_BUILD_DIR}" -G "${CMAKE_GENERATOR}" ${NBL_DXC_CMAKE_OPTIONS}
102103
RESULT_VARIABLE DXC_CMAKE_RESULT
103104
OUTPUT_VARIABLE DXC_CMAKE_STREAM_PIPE

3rdparty/dxc/dxc

3rdparty/freetype2

Submodule freetype2 updated 754 files

3rdparty/libjpeg-turbo

Submodule libjpeg-turbo updated 690 files

3rdparty/libpng

Submodule libpng updated 310 files

3rdparty/zlib

Submodule zlib updated 200 files

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (C) 2018-2025 - DevSH Graphics Programming Sp. z O.O.
22
# This file is part of the "Nabla Engine".
33
# For conditions of distribution and use, see copyright notice in nabla.h.in or nabla.h
4-
cmake_minimum_required(VERSION 3.31)
4+
cmake_minimum_required(VERSION 3.31..4.2.0)
55

66
# TODO: Yas - once we deploy 4.x we will fire `cmake_policy(VERSION <min>[...<max>])` instead of manually picking policies
77
# https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html#policy-version

cmake/FindZLIB.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if(NOT TARGET ZLIB::ZLIB)
2+
message(FATAL_ERROR "define ZLIB::ZLIB target!")
3+
endif()
4+
5+
set(ZLIB_FOUND TRUE)
6+
set(ZLIB_LIBRARY ZLIB::ZLIB)
7+
set(ZLIB_INCLUDE_DIR "${THIRD_PARTY_SOURCE_DIR}/zlib;${THIRD_PARTY_BINARY_DIR}/zlib")

src/nbl/CMakeLists.txt

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ if(MSVC)
307307
list(APPEND NABLA_SRCS_COMMON "${PROJECT_SOURCE_DIR}/tools/debug/VisualStudio/DynamicArrayVisualizer.natvis")
308308
endif()
309309

310-
get_target_property(JPEG_STATIC_BINARY_DIR jpeg-static BINARY_DIR)
311310
get_target_property(PNG_STATIC_BINARY_DIR png_static BINARY_DIR)
312311

313312
set(PUBLIC_BUILD_INCLUDE_DIRS
@@ -319,7 +318,6 @@ set(PUBLIC_BUILD_INCLUDE_DIRS
319318
${THIRD_PARTY_SOURCE_DIR}/glm
320319
${THIRD_PARTY_SOURCE_DIR}/renderdoc # for renderdoc api header
321320
${CMAKE_BINARY_DIR}/3rdparty/zlib # for dynamically generated zconf.h
322-
${JPEG_STATIC_BINARY_DIR} # for dynamically generated pnglibconf.h
323321
${PNG_STATIC_BINARY_DIR} # for dynamically generated jconfig.h
324322
${CONFIG_DIRECOTORY} # Nabla config directory
325323
)
@@ -486,27 +484,12 @@ if (UNIX)
486484
endif()
487485

488486
# zlib
489-
add_dependencies(zlibstatic zlib_copy)
490-
add_dependencies(Nabla zlibstatic)
491-
492487
if(NBL_STATIC_BUILD)
493488
target_link_libraries(Nabla INTERFACE zlibstatic)
494-
target_link_libraries(Nabla INTERFACE
495-
$<$<CONFIG:Debug>:${ZLIB_LIBRARY_DEBUG}>
496-
$<$<CONFIG:Release>:${ZLIB_LIBRARY_RELEASE}>
497-
$<$<CONFIG:RelWithDebInfo>:${ZLIB_LIBRARY_RELWITHDEBINFO}>
498-
)
499489
else()
500490
target_link_libraries(Nabla PRIVATE zlibstatic)
501-
target_link_libraries(Nabla PRIVATE
502-
$<$<CONFIG:Debug>:${ZLIB_LIBRARY_DEBUG}>
503-
$<$<CONFIG:Release>:${ZLIB_LIBRARY_RELEASE}>
504-
$<$<CONFIG:RelWithDebInfo>:${ZLIB_LIBRARY_RELWITHDEBINFO}>
505-
)
506491
endif()
507492

508-
list(APPEND PUBLIC_BUILD_INCLUDE_DIRS $<TARGET_PROPERTY:zlibstatic,BINARY_DIR>/copy_source)
509-
510493
# blake3
511494
add_dependencies(Nabla blake3)
512495
list(APPEND PUBLIC_BUILD_INCLUDE_DIRS $<TARGET_PROPERTY:blake3,INCLUDE_DIRECTORIES>)
@@ -562,7 +545,7 @@ list(APPEND PUBLIC_BUILD_INCLUDE_DIRS ${THIRD_PARTY_SOURCE_DIR}/simdjson)
562545
# libjpeg
563546
add_dependencies(Nabla jpeg-static)
564547
if(NBL_STATIC_BUILD)
565-
target_link_libraries(Nabla INTERFACE jpeg-static)
548+
target_link_libraries(Nabla PUBLIC jpeg-static)
566549
else()
567550
target_link_libraries(Nabla PRIVATE jpeg-static)
568551
endif()

0 commit comments

Comments
 (0)