build: Add support for unity builds

This commit is contained in:
WerWolv
2023-11-30 10:22:15 +01:00
parent 09904b77eb
commit e370fdb0fc
25 changed files with 77 additions and 79 deletions

View File

@@ -450,6 +450,9 @@ macro(setupCompilerFlags target)
# Disable some warnings
set(IMHEX_C_CXX_FLAGS "-Wno-array-bounds -Wno-deprecated-declarations")
if (IMHEX_ENABLE_UNITY_BUILD AND WIN32)
set(IMHEX_COMMON_FLAGS "${IMHEX_COMMON_FLAGS} -Wa,-mbig-obj")
endif ()
endif()
# Disable some warnings for gcc
@@ -634,6 +637,12 @@ macro(addBundledLibraries)
endif ()
endmacro()
function(enableUnityBuild TARGET)
if (IMHEX_ENABLE_UNITY_BUILD)
set_target_properties(${TARGET} PROPERTIES UNITY_BUILD ON UNITY_BUILD_MODE BATCH)
endif ()
endfunction()
function(generatePDBs)
if (NOT WIN32 OR CMAKE_BUILD_TYPE STREQUAL "Debug")
return()

View File

@@ -33,6 +33,7 @@ macro(add_imhex_plugin)
# Enable required compiler flags
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
enableUnityBuild(${IMHEX_PLUGIN_NAME})
setupCompilerFlags(${IMHEX_PLUGIN_NAME})
# Configure build properties