From 2e74a78f46b527b7c3700cfa003695194d91e4dd Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 29 Jan 2024 21:18:32 +0100 Subject: [PATCH] build: Improve unity builds --- cmake/build_helpers.cmake | 13 +++++++++++-- lib/libimhex/source/api/imhex_api.cpp | 1 - lib/libimhex/source/helpers/fs.cpp | 1 + lib/libimhex/source/helpers/utils.cpp | 1 + main/gui/source/main.cpp | 1 + main/gui/source/window/win_window.cpp | 2 +- plugins/diffing/CMakeLists.txt | 7 ++++--- plugins/disassembler/CMakeLists.txt | 1 + plugins/hashes/CMakeLists.txt | 1 + 9 files changed, 21 insertions(+), 7 deletions(-) diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 70ec7d69c..a59570528 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -55,6 +55,7 @@ macro(detectOS) set(CMAKE_INSTALL_BINDIR ".") set(CMAKE_INSTALL_LIBDIR ".") set(PLUGINS_INSTALL_LOCATION "plugins") + add_compile_definitions(WIN32_LEAN_AND_MEAN) elseif (APPLE) add_compile_definitions(OS_MACOS) set(CMAKE_INSTALL_BINDIR ".") @@ -611,9 +612,17 @@ macro(addBundledLibraries) set(JTHREAD_LIBRARIES jthread) endif() - set(LIBPL_BUILD_CLI_AS_EXECUTABLE OFF) + set(LIBPL_BUILD_CLI_AS_EXECUTABLE OFF CACHE BOOL "" FORCE) + set(LIBPL_SHARED_LIBRARY ON CACHE BOOL "" FORCE) add_subdirectory(${EXTERNAL_LIBS_FOLDER}/pattern_language EXCLUDE_FROM_ALL) - set_target_properties(libpl PROPERTIES POSITION_INDEPENDENT_CODE ON) + set_target_properties( + libpl + PROPERTIES + POSITION_INDEPENDENT_CODE ON + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} + ) + enableUnityBuild(libpl) find_package(mbedTLS 3.4.0 REQUIRED) find_library(MAGIC 5.39 magic REQUIRED) diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index 6c5fe192f..c1cac1925 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -16,7 +16,6 @@ #include #if defined(OS_WINDOWS) - #define WIN32_LEAN_AND_MEAN #include #else #include diff --git a/lib/libimhex/source/helpers/fs.cpp b/lib/libimhex/source/helpers/fs.cpp index 3e0265fa6..056c94f90 100644 --- a/lib/libimhex/source/helpers/fs.cpp +++ b/lib/libimhex/source/helpers/fs.cpp @@ -11,6 +11,7 @@ #if defined(OS_WINDOWS) #include #include + #include #elif defined(OS_LINUX) || defined(OS_WEB) #include #include diff --git a/lib/libimhex/source/helpers/utils.cpp b/lib/libimhex/source/helpers/utils.cpp index ad74fc5fd..ef5def35c 100644 --- a/lib/libimhex/source/helpers/utils.cpp +++ b/lib/libimhex/source/helpers/utils.cpp @@ -11,6 +11,7 @@ #if defined(OS_WINDOWS) #include + #include #elif defined(OS_LINUX) #include #include diff --git a/main/gui/source/main.cpp b/main/gui/source/main.cpp index c5fbc3768..ddb5e3280 100644 --- a/main/gui/source/main.cpp +++ b/main/gui/source/main.cpp @@ -21,6 +21,7 @@ #if defined(OS_WINDOWS) #include + #include #include #elif defined(OS_WEB) #include diff --git a/main/gui/source/window/win_window.cpp b/main/gui/source/window/win_window.cpp index 8f9304222..f7805d7ee 100644 --- a/main/gui/source/window/win_window.cpp +++ b/main/gui/source/window/win_window.cpp @@ -21,7 +21,7 @@ #include #include #include - #include + #include #include diff --git a/plugins/diffing/CMakeLists.txt b/plugins/diffing/CMakeLists.txt index f228fe0d5..9eba9bd74 100644 --- a/plugins/diffing/CMakeLists.txt +++ b/plugins/diffing/CMakeLists.txt @@ -7,10 +7,11 @@ if (USE_SYSTEM_EDLIB) else() set(BUILD_TESTING OFF CACHE BOOL "" FORCE) add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/edlib ${CMAKE_CURRENT_BINARY_DIR}/edlib EXCLUDE_FROM_ALL) + enableUnityBuild(edlib) + set_target_properties(edlib + PROPERTIES POSITION_INDEPENDENT_CODE ON + ) endif() -set_target_properties(edlib - PROPERTIES POSITION_INDEPENDENT_CODE ON -) add_imhex_plugin( NAME diff --git a/plugins/disassembler/CMakeLists.txt b/plugins/disassembler/CMakeLists.txt index 2347186e6..22793d2dc 100644 --- a/plugins/disassembler/CMakeLists.txt +++ b/plugins/disassembler/CMakeLists.txt @@ -9,6 +9,7 @@ if (NOT USE_SYSTEM_CAPSTONE) add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/capstone ${CMAKE_CURRENT_BINARY_DIR}/capstone EXCLUDE_FROM_ALL) set_target_properties(capstone PROPERTIES POSITION_INDEPENDENT_CODE ON) target_compile_options(capstone PRIVATE -Wno-unused-function) + enableUnityBuild(capstone) set(CAPSTONE_LIBRARY "capstone") set(CAPSTONE_INCLUDE_DIR ${THIRD_PARTY_LIBS_FOLDER}/capstone/include) else() diff --git a/plugins/hashes/CMakeLists.txt b/plugins/hashes/CMakeLists.txt index 7bad19fdb..fc0d6d115 100644 --- a/plugins/hashes/CMakeLists.txt +++ b/plugins/hashes/CMakeLists.txt @@ -4,6 +4,7 @@ include(ImHexPlugin) add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/HashLibPlus ${CMAKE_CURRENT_BINARY_DIR}/HashLibPlus) set_target_properties(hashplus PROPERTIES POSITION_INDEPENDENT_CODE ON) +enableUnityBuild(hashplus) add_imhex_plugin( NAME