Skip to content

Commit

Permalink
update build sys
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-Leo-Smith committed Dec 4, 2023
1 parent c1d08cc commit 4e7d11c
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 15 deletions.
31 changes: 30 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ set(CMAKE_POLICY_DEFAULT_CMP0072 NEW)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_EXTENSIONS OFF)
set(BUILD_SHARED_LIBS ON)

project(LuisaRender LANGUAGES C CXX VERSION 0.1)

if (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
Expand All @@ -27,6 +35,27 @@ endif ()
option(LUISA_RENDER_BUILD_TESTS "Build tests for LuisaRender" ${LUISA_RENDER_MASTER_PROJECT})
option(LUISA_RENDER_ENABLE_UNITY_BUILD "Enable unity build to speed up compilation" OFF)

include(src/compute/scripts/setup_compilation.cmake)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")

get_cmake_property(LUISA_RENDERIS_MULTI_CONFIG GENERATOR_IS_MULTI_CONFIG)
if (LUISA_RENDERIS_MULTI_CONFIG)
foreach (config ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${config} CONFIG_UPPER)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONFIG_UPPER} "${CMAKE_BINARY_DIR}/bin/${config}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONFIG_UPPER} "${CMAKE_BINARY_DIR}/bin/${config}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_UPPER} "${CMAKE_BINARY_DIR}/lib/${config}")
set(CMAKE_PDB_OUTPUT_DIRECTORY_${CONFIG_UPPER} "${CMAKE_BINARY_DIR}/lib/${config}")
endforeach ()
else ()
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif ()
endif ()

set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)

add_subdirectory(src)
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
/Zc:preprocessor)
endif ()

set(LUISA_COMPUTE_ENABLE_LTO OFF CACHE BOOL "" FORCE)
set(LUISA_COMPUTE_ENABLE_PYTHON OFF CACHE BOOL "" FORCE)
set(LUISA_COMPUTE_ENABLE_UNITY_BUILD ${LUISA_RENDER_ENABLE_UNITY_BUILD} CACHE BOOL "" FORCE)
add_subdirectory(compute)
Expand Down
2 changes: 1 addition & 1 deletion src/compute
Submodule compute updated 112 files
18 changes: 8 additions & 10 deletions src/ext/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,16 @@ target_link_libraries(luisa-render-ext INTERFACE assimp::assimp)
# tinyexr
set(TINYEXR_BUILD_SAMPLE OFF CACHE BOOL "" FORCE)
if (ZLIB_FOUND)
add_library(tinyexr SHARED tinyexr.cpp)
target_compile_definitions(tinyexr PUBLIC TINYEXR_USE_MINIZ=0)
target_link_libraries(tinyexr PRIVATE ZLIB::ZLIB)
add_library(luisa-render-ext-tinyexr OBJECT tinyexr.cpp)
target_compile_definitions(luisa-render-ext-tinyexr PUBLIC TINYEXR_USE_MINIZ=0)
target_link_libraries(luisa-render-ext-tinyexr PRIVATE ZLIB::ZLIB)
else ()
add_library(tinyexr SHARED tinyexr.cpp tinyexr/deps/miniz/miniz.c)
target_compile_definitions(tinyexr PUBLIC TINYEXR_USE_MINIZ=1)
target_include_directories(tinyexr PRIVATE tinyexr/deps/miniz)
add_library(luisa-render-ext-tinyexr SHARED tinyexr.cpp tinyexr/deps/miniz/miniz.c)
target_compile_definitions(luisa-render-ext-tinyexr PUBLIC TINYEXR_USE_MINIZ=1)
target_include_directories(luisa-render-ext-tinyexr PRIVATE tinyexr/deps/miniz)
endif ()
target_include_directories(tinyexr PUBLIC tinyexr)
target_link_libraries(tinyexr PUBLIC ${CMAKE_DL_LIBS})
set_target_properties(tinyexr PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
target_link_libraries(luisa-render-ext INTERFACE tinyexr)
target_include_directories(luisa-render-ext-tinyexr PUBLIC tinyexr)
target_link_libraries(luisa-render-ext-tinyexr PUBLIC ${CMAKE_DL_LIBS})

# nlohmann json
add_library(nlohmann_json INTERFACE)
Expand Down
7 changes: 5 additions & 2 deletions src/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ add_library(luisa-render-util SHARED
polymorphic_closure.h
command_buffer.cpp command_buffer.h
thread_pool.cpp thread_pool.h)
target_link_libraries(luisa-render-util PUBLIC
target_link_libraries(luisa-render-util
PUBLIC
luisa::compute
luisa-render-include
luisa-render-ext)
luisa-render-ext
PRIVATE
luisa-render-ext-tinyexr)
set_target_properties(luisa-render-util PROPERTIES
WINDOWS_EXPORT_ALL_SYMBOLS ON
UNITY_BUILD ${LUISA_RENDER_ENABLE_UNITY_BUILD})
2 changes: 1 addition & 1 deletion src/util/imageio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <tinyexr.h>
#include <stb/stb_image.h>
#include <stb/stb_image_write.h>
#include <stb/stb_image_resize.h>
#include <stb/stb_image_resize2.h>

#include <core/logging.h>
#include <util/imageio.h>
Expand Down

0 comments on commit 4e7d11c

Please sign in to comment.