Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Build: added support for unity builds in most projects except for Sto…
Browse files Browse the repository at this point in the history
…rmLib, ZLib and Scripts
  • Loading branch information
Ovahlord committed Oct 9, 2023
1 parent 8acfadc commit b49f95e
Show file tree
Hide file tree
Showing 28 changed files with 219 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ set(WITH_SOURCE_TREE "hierarchical" CACHE STRING "Build the source tree for I
set_property(CACHE WITH_SOURCE_TREE PROPERTY STRINGS no flat hierarchical hierarchical-folders)
option(WITHOUT_GIT "Disable the GIT testing routines" 0)
option(BUILD_TESTING "Build test suite" 0)

option(UNITY_BUILDS "Enables the unity build mode which combines multiple source files into buckets to speed up build time" 0)
6 changes: 6 additions & 0 deletions cmake/showoptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ else()
message("* Build unit tests : No (default)")
endif()

if(UNITY_BUILDS)
message("* Unity build enabled : Yes")
else()
message("* Unity build enabled : No (default)")
endif()

if(USE_COREPCH)
message("* Build core w/PCH : Yes (default)")
else()
Expand Down
9 changes: 9 additions & 0 deletions dep/MinHook/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,12 @@ else()
set_target_properties(minhook PROPERTIES POSTFIX "")
set_target_properties(minhook PROPERTIES DEBUG_POSTFIX "d")
endif()

if(UNITY_BUILDS)
set_target_properties(minhook
PROPERTIES UNITY_BUILD ON)
set_target_properties(minhook
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 2)
endif()
9 changes: 9 additions & 0 deletions dep/bzip2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,12 @@ else()
FOLDER
"dep")
endif()

if(UNITY_BUILDS)
set_target_properties(bzip2
PROPERTIES UNITY_BUILD ON)
set_target_properties(bzip2
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 8)
endif()
9 changes: 9 additions & 0 deletions dep/efsw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,12 @@ if (BUILD_SHARED_LIBS)
else ()
add_library(efsw INTERFACE IMPORTED GLOBAL)
endif ()

if(UNITY_BUILDS)
set_target_properties(efsw
PROPERTIES UNITY_BUILD ON)
set_target_properties(efsw
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 8)
endif()
9 changes: 9 additions & 0 deletions dep/fmt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,12 @@ set_target_properties(fmt
PROPERTIES
FOLDER
"dep")

if(UNITY_BUILDS)
set_target_properties(fmt
PROPERTIES UNITY_BUILD ON)
set_target_properties(fmt
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 8)
endif()
9 changes: 9 additions & 0 deletions dep/g3dlite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,12 @@ set_target_properties(g3dlib
PROPERTIES
FOLDER
"dep")

if(UNITY_BUILDS)
set_target_properties(g3dlib
PROPERTIES UNITY_BUILD ON)
set_target_properties(g3dlib
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 8)
endif()
9 changes: 9 additions & 0 deletions dep/gsoap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ set_target_properties(gsoap
FOLDER
"dep")

if(UNITY_BUILDS)
set_target_properties(gsoap
PROPERTIES UNITY_BUILD ON)
set_target_properties(gsoap
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 7)
endif()

if (MSVC)
# Little fix for MSVC / Windows platforms
target_compile_definitions(gsoap
Expand Down
9 changes: 9 additions & 0 deletions dep/jemalloc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,12 @@ else()
valgrind)

endif()

if(UNITY_BUILDS)
set_target_properties(jemalloc
PROPERTIES UNITY_BUILD ON)
set_target_properties(jemalloc
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 8)
endif()
9 changes: 9 additions & 0 deletions dep/libzmq/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,12 @@ target_compile_definitions(libzmq
-DZMQ_STATIC
${ZMQ_PLATFORM}
${ADDITIONAL_DEFINES})

if(UNITY_BUILDS)
set_target_properties(libzmq
PROPERTIES UNITY_BUILD ON)
set_target_properties(libzmq
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 2)
endif()
9 changes: 9 additions & 0 deletions dep/recastnavigation/Detour/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@ set_target_properties(Detour
PROPERTIES
FOLDER
"dep")

if(UNITY_BUILDS)
set_target_properties(Detour
PROPERTIES UNITY_BUILD ON)
set_target_properties(Detour
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 7)
endif()
9 changes: 9 additions & 0 deletions dep/recastnavigation/Recast/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,12 @@ set_target_properties(Recast
PROPERTIES
FOLDER
"dep")

if(UNITY_BUILDS)
set_target_properties(Recast
PROPERTIES UNITY_BUILD ON)
set_target_properties(Recast
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 2)
endif()
9 changes: 9 additions & 0 deletions dep/zmqpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,12 @@ target_compile_definitions(zmqpp
-DBUILD_VERSION_MINOR=2
-DBUILD_VERSION_REVISION=0
-DBUILD_VERSION="3.2.0")

if(UNITY_BUILDS)
set_target_properties(zmqpp
PROPERTIES UNITY_BUILD ON)
set_target_properties(zmqpp
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 6)
endif()
9 changes: 9 additions & 0 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ set_target_properties(common
FOLDER
"server")

if(UNITY_BUILDS)
set_target_properties(common
PROPERTIES UNITY_BUILD ON)
set_target_properties(common
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 4)
endif()

if(BUILD_SHARED_LIBS)
if(UNIX)
install(TARGETS common
Expand Down
9 changes: 9 additions & 0 deletions src/server/bnetserver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ set_target_properties(bnetserver
FOLDER
"server")

if(UNITY_BUILDS)
set_target_properties(bnetserver
PROPERTIES UNITY_BUILD ON)
set_target_properties(bnetserver
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 8)
endif()

if (WIN32)
if ("${CMAKE_MAKE_PROGRAM}" MATCHES "MSBuild")
add_custom_command(TARGET bnetserver
Expand Down
9 changes: 9 additions & 0 deletions src/server/database/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,12 @@ endif()
if(USE_COREPCH)
add_cxx_pch(database ${PRIVATE_PCH_HEADER})
endif()

if(UNITY_BUILDS)
set_target_properties(database
PROPERTIES UNITY_BUILD ON)
set_target_properties(database
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 8)
endif()
2 changes: 1 addition & 1 deletion src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ EndScriptData */

float const MAX_PLAYER_DISTANCE = 100.0f;

enum Points
enum ScriptedFollowerPoints
{
POINT_COMBAT_START = 0xFFFFFF
};
Expand Down
9 changes: 9 additions & 0 deletions src/server/game/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ set_target_properties(game
FOLDER
"server")

if(UNITY_BUILDS)
set_target_properties(game
PROPERTIES UNITY_BUILD ON)
set_target_properties(game
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 8)
endif()

if(BUILD_SHARED_LIBS)
if(UNIX)
install(TARGETS game
Expand Down
4 changes: 2 additions & 2 deletions src/server/game/Warden/WardenMac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void WardenMac::RequestHash()
_session->SendPacket(&pkt);
}

struct keyData {
struct keyDataMac {
union
{
struct
Expand All @@ -132,7 +132,7 @@ void WardenMac::HandleHashResult(ByteBuffer &buff)
// test
int keyIn[4];

keyData mod_seed = { { { { 0x4D, 0x80, 0x8D, 0x2C, 0x77, 0xD9, 0x05, 0xC4, 0x1A, 0x63, 0x80, 0xEC, 0x08, 0x58, 0x6A, 0xFE } } } };
keyDataMac mod_seed = { { { { 0x4D, 0x80, 0x8D, 0x2C, 0x77, 0xD9, 0x05, 0xC4, 0x1A, 0x63, 0x80, 0xEC, 0x08, 0x58, 0x6A, 0xFE } } } };

for (int i = 0; i < 4; ++i)
{
Expand Down
9 changes: 9 additions & 0 deletions src/server/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ set_target_properties(shared
FOLDER
"server")

if(UNITY_BUILDS)
set_target_properties(shared
PROPERTIES UNITY_BUILD ON)
set_target_properties(shared
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 8)
endif()

if(BUILD_SHARED_LIBS)
if(UNIX)
install(TARGETS shared
Expand Down
4 changes: 2 additions & 2 deletions src/server/shared/DataStores/DBCDatabaseLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ DBCDatabaseLoader::DBCDatabaseLoader(std::string const& storageName, std::string
}
}

static char const* nullStr = "";
static char const* dbcNullStr = "";

char* DBCDatabaseLoader::Load(uint32& records, char**& indexTable)
{
Expand Down Expand Up @@ -130,7 +130,7 @@ char* DBCDatabaseLoader::Load(uint32& records, char**& indexTable)
offset += 1;
break;
case FT_STRING:
*reinterpret_cast<char**>(&dataValue[offset]) = const_cast<char*>(nullStr);
*reinterpret_cast<char**>(&dataValue[offset]) = const_cast<char*>(dbcNullStr);
offset += sizeof(char*);
break;
}
Expand Down
9 changes: 9 additions & 0 deletions src/server/worldserver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ set_target_properties(worldserver
FOLDER
"server")

if(UNITY_BUILDS)
set_target_properties(worldserver
PROPERTIES UNITY_BUILD ON)
set_target_properties(worldserver
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 4)
endif()

# Add all dynamic projects as dependency to the worldserver
if(WORLDSERVER_DYNAMIC_SCRIPT_MODULES_DEPENDENCIES)
add_dependencies(worldserver ${WORLDSERVER_DYNAMIC_SCRIPT_MODULES_DEPENDENCIES})
Expand Down
9 changes: 9 additions & 0 deletions src/tools/client_launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,13 @@ target_link_libraries(${target_name}
common
)

if(UNITY_BUILDS)
set_target_properties(${target_name}
PROPERTIES UNITY_BUILD ON)
set_target_properties(${target_name}
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 8)
endif()

install(TARGETS ${target_name} DESTINATION "${CMAKE_INSTALL_PREFIX}")
9 changes: 9 additions & 0 deletions src/tools/client_patcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,13 @@ target_link_libraries(${target_name}
minhook
)

if(UNITY_BUILDS)
set_target_properties(${target_name}
PROPERTIES UNITY_BUILD ON)
set_target_properties(${target_name}
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 4)
endif()

install(TARGETS ${target_name} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}")
9 changes: 9 additions & 0 deletions src/tools/connection_patcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ target_link_libraries(connection_patcher
common
)

if(UNITY_BUILDS)
set_target_properties(connection_patcher
PROPERTIES UNITY_BUILD ON)
set_target_properties(connection_patcher
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 2)
endif()

if (UNIX)
install(TARGETS connection_patcher DESTINATION bin)
elseif (WIN32)
Expand Down
9 changes: 9 additions & 0 deletions src/tools/map_extractor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ set_target_properties(mapextractor
FOLDER
"tools")

if(UNITY_BUILDS)
set_target_properties(mapextractor
PROPERTIES UNITY_BUILD ON)
set_target_properties(mapextractor
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 6)
endif()

if(UNIX)
install(TARGETS mapextractor DESTINATION bin)
elseif(WIN32)
Expand Down
9 changes: 9 additions & 0 deletions src/tools/mmaps_generator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ set_target_properties(mmaps_generator
FOLDER
"tools")

if(UNITY_BUILDS)
set_target_properties(mmaps_generator
PROPERTIES UNITY_BUILD ON)
set_target_properties(mmaps_generator
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 4)
endif()

if(UNIX)
install(TARGETS mmaps_generator DESTINATION bin)
elseif(WIN32)
Expand Down
9 changes: 9 additions & 0 deletions src/tools/vmap4_extractor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ set_target_properties(vmap4extractor
FOLDER
"tools")

if(UNITY_BUILDS)
set_target_properties(vmap4extractor
PROPERTIES UNITY_BUILD ON)
set_target_properties(vmap4extractor
PROPERTIES
UNITY_BUILD_MODE BATCH
UNITY_BUILD_BATCH_SIZE 8)
endif()

if(UNIX)
install(TARGETS vmap4extractor DESTINATION bin)
elseif(WIN32)
Expand Down

0 comments on commit b49f95e

Please sign in to comment.