From 80d51ac8a64dc0e42cfa92b8204a5d77643d9414 Mon Sep 17 00:00:00 2001 From: Dennis Brakhane Date: Mon, 28 Jul 2025 09:02:49 +0200 Subject: [PATCH] cmake: add support for unity builds (#1186) --- Samples/Example_ImGui/CMakeLists.txt | 2 +- Samples/Example_ImGui_Docking/CMakeLists.txt | 2 +- WickedEngine/CMakeLists.txt | 12 ++++++++++++ WickedEngine/Utility/CMakeLists.txt | 10 +++++----- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Samples/Example_ImGui/CMakeLists.txt b/Samples/Example_ImGui/CMakeLists.txt index 77605816d..f0b1550c4 100644 --- a/Samples/Example_ImGui/CMakeLists.txt +++ b/Samples/Example_ImGui/CMakeLists.txt @@ -63,7 +63,7 @@ endif () if (MSVC) set_property(TARGET Example_ImGui PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") endif () - +set_property(TARGET Example_ImGui PROPERTY UNITY_BUILD NO) # Copy content to build folder: add_dependencies(Example_ImGui Content) diff --git a/Samples/Example_ImGui_Docking/CMakeLists.txt b/Samples/Example_ImGui_Docking/CMakeLists.txt index d730f739c..dbccdae46 100644 --- a/Samples/Example_ImGui_Docking/CMakeLists.txt +++ b/Samples/Example_ImGui_Docking/CMakeLists.txt @@ -69,7 +69,7 @@ endif () if (MSVC) set_property(TARGET Example_ImGui_Docking PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") endif () - +set_property(TARGET Example_ImGui_Docking PROPERTY UNITY_BUILD NO) # Copy content to build folder: add_dependencies(Example_ImGui_Docking Content) diff --git a/WickedEngine/CMakeLists.txt b/WickedEngine/CMakeLists.txt index 9a06c7446..d37cf4462 100644 --- a/WickedEngine/CMakeLists.txt +++ b/WickedEngine/CMakeLists.txt @@ -170,6 +170,7 @@ else () set_target_properties(FAudio PROPERTIES POSITION_INDEPENDENT_CODE ${WICKED_PIC} + UNITY_BUILD NO ) set(WICKEDENGINE_STATIC_LIBRARIES ${WICKEDENGINE_STATIC_LIBRARIES} FAudio) @@ -195,6 +196,17 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E create_symlink ${WICKED_ROOT_DIR}/WickedEngine/shaders ${CMAKE_CURRENT_BINARY_DIR}/shaders ) +set_property(SOURCE + wiAudio.cpp + wiOcean.cpp + wiPrimitive_BindLUA.cpp + wiPhysics_Jolt.cpp + wiGraphicsDevice_Vulkan.cpp + wiGraphicsDevice_DX12.cpp + + PROPERTY SKIP_UNITY_BUILD_INCLUSION TRUE +) +set_property(TARGET LUA PROPERTY UNITY_BUILD NO) # OFFLINE SHADER COMPILER add_executable(offlineshadercompiler diff --git a/WickedEngine/Utility/CMakeLists.txt b/WickedEngine/Utility/CMakeLists.txt index 965353780..1ccf9761c 100644 --- a/WickedEngine/Utility/CMakeLists.txt +++ b/WickedEngine/Utility/CMakeLists.txt @@ -45,11 +45,11 @@ set_property( PROPERTY HEADER_FILE_ONLY ON ) -if (NOT WIN32) - list(REMOVE_ITEM SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/D3D12MemAlloc.cpp - ) -endif() +# linux doesn't support it, and windows includes +# it directly in wiGraphicsDevice_DX12.cpp +list(REMOVE_ITEM SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/D3D12MemAlloc.cpp +) add_library(Utility STATIC ${SOURCE_FILES} ${HEADER_FILES}