CMake: Use inherited dependencies in database, shared and game

(cherry picked from commit 469f2d3ade)
This commit is contained in:
Naios
2016-03-14 16:52:27 +01:00
parent 0db4f018e8
commit 5fe83abbe5
5 changed files with 117 additions and 315 deletions

View File

@@ -27,8 +27,8 @@ endif(WIN32)
add_subdirectory(database)
add_subdirectory(shared)
add_subdirectory(game)
add_subdirectory(ipc)
add_subdirectory(bnetserver)
add_subdirectory(game)
add_subdirectory(scripts)
add_subdirectory(worldserver)

View File

@@ -8,30 +8,22 @@
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
if( USE_COREPCH )
include_directories(${CMAKE_CURRENT_BINARY_DIR})
endif()
file(GLOB_RECURSE sources_Database Database/*.cpp Database/*.h)
file(GLOB_RECURSE sources_Logging Logging/*.cpp Logging/*.h)
file(GLOB_RECURSE sources_Updater Updater/*.cpp Updater/*.h)
file(GLOB sources_localdir *.cpp *.h)
#
# Build shared sourcelist
#
CollectSourceFiles(
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE_SOURCES
# Exclude
${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders)
if (USE_COREPCH)
set(database_STAT_PCH_HDR PrecompiledHeaders/databasePCH.h)
set(database_STAT_PCH_SRC PrecompiledHeaders/databasePCH.cpp)
set(PRIVATE_PCH_HEADER PrecompiledHeaders/databasePCH.h)
set(PRIVATE_PCH_SOURCE PrecompiledHeaders/databasePCH.cpp)
endif()
set(database_STAT_SRCS
${database_STAT_SRCS}
${sources_Database}
${sources_Logging}
${sources_Updater}
GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
add_library(database
${PRIVATE_SOURCES}
${PRIVATE_PCH_SOURCE}
)
# Do NOT add any extra include directory unless it does not create unneeded extra dependencies,
@@ -43,31 +35,30 @@ set(database_STAT_SRCS
# linkage (enums, defines...) it is discouraged to do so unless necessary, as it will pullute
# include_directories leading to further unnoticed dependency aditions
# Linker Depencency requirements: common
include_directories(
CollectIncludeDirectories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/Database
${CMAKE_CURRENT_SOURCE_DIR}/Updater
${CMAKE_SOURCE_DIR}/dep/cppformat
${CMAKE_SOURCE_DIR}/dep/process
${CMAKE_SOURCE_DIR}/src/common/
${CMAKE_SOURCE_DIR}/src/common/Configuration
${CMAKE_SOURCE_DIR}/src/common/Debugging
${CMAKE_SOURCE_DIR}/src/common/Logging
${CMAKE_SOURCE_DIR}/src/common/Threading
${CMAKE_SOURCE_DIR}/src/common/Utilities
${MYSQL_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR}
${VALGRIND_INCLUDE_DIR}
)
PUBLIC_INCLUDES
# Exclude
${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders)
GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(database
PUBLIC
${PUBLIC_INCLUDES}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR})
add_library(database STATIC
${database_STAT_SRCS}
${database_STAT_PCH_SRC}
)
target_link_libraries(database
PUBLIC
common
process
mysql)
set_target_properties(database
PROPERTIES
FOLDER
"server")
# Generate precompiled header
if (USE_COREPCH)
add_cxx_pch(database ${database_STAT_PCH_HDR} ${database_STAT_PCH_SRC})
add_cxx_pch(database ${PRIVATE_PCH_HEADER} ${PRIVATE_PCH_SOURCE})
endif ()

View File

@@ -8,219 +8,47 @@
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
file(GLOB_RECURSE sources_Accounts Accounts/*.cpp Accounts/*.h)
file(GLOB_RECURSE sources_Achievements Achievements/*.cpp Achievements/*.h)
file(GLOB_RECURSE sources_Addons Addons/*.cpp Addons/*.h)
file(GLOB_RECURSE sources_AI AI/*.cpp AI/*.h)
file(GLOB_RECURSE sources_AuctionHouse AuctionHouse/*.cpp AuctionHouse/*.h)
file(GLOB_RECURSE sources_AuctionHouseBot AuctionHouseBot/*.cpp AuctionHouseBot/*.h)
file(GLOB_RECURSE sources_Battlefield Battlefield/*.cpp Battlefield/*.h)
file(GLOB_RECURSE sources_Battlegrounds Battlegrounds/*.cpp Battlegrounds/*.h)
file(GLOB_RECURSE sources_BattlePets BattlePets/*.cpp BattlePets/*.h)
file(GLOB_RECURSE sources_Calendar Calendar/*.cpp Calendar/*.h)
file(GLOB_RECURSE sources_Chat Chat/*.cpp Chat/*.h)
file(GLOB_RECURSE sources_Combat Combat/*.cpp Combat/*.h)
file(GLOB_RECURSE sources_Conditions Conditions/*.cpp Conditions/*.h)
file(GLOB_RECURSE sources_DataStores DataStores/*.cpp DataStores/*.h)
file(GLOB_RECURSE sources_DungeonFinding DungeonFinding/*.cpp DungeonFinding/*.h)
file(GLOB_RECURSE sources_Entities Entities/*.cpp Entities/*.h)
file(GLOB_RECURSE sources_Events Events/*.cpp Events/*.h)
file(GLOB_RECURSE sources_Garrison Garrison/*.cpp Garrison/*.h)
file(GLOB_RECURSE sources_Globals Globals/*.cpp Globals/*.h)
file(GLOB_RECURSE sources_Grids Grids/*.cpp Grids/*.h)
file(GLOB_RECURSE sources_Groups Groups/*.cpp Groups/*.h)
file(GLOB_RECURSE sources_Guilds Guilds/*.cpp Guilds/*.h)
file(GLOB_RECURSE sources_Handlers Handlers/*.cpp Handlers/*.h)
file(GLOB_RECURSE sources_Instances Instances/*.cpp Instances/*.h)
file(GLOB_RECURSE sources_Loot Loot/*.cpp Loot/*.h)
file(GLOB_RECURSE sources_Mails Mails/*.cpp Mails/*.h)
file(GLOB_RECURSE sources_Maps Maps/*.cpp Maps/*.h)
file(GLOB_RECURSE sources_Miscellaneous Miscellaneous/*.cpp Miscellaneous/*.h)
file(GLOB_RECURSE sources_Movement Movement/*.cpp Movement/*.h)
file(GLOB_RECURSE sources_OutdoorPvP OutdoorPvP/*.cpp OutdoorPvP/*.h)
file(GLOB_RECURSE sources_Pools Pools/*.cpp Pools/*.h)
file(GLOB_RECURSE sources_Quests Quests/*.cpp Quests/*.h)
file(GLOB_RECURSE sources_Reputation Reputation/*.cpp Reputation/*.h)
file(GLOB_RECURSE sources_Scripting Scripting/*.cpp Scripting/*.h)
file(GLOB_RECURSE sources_Server Server/*.cpp Server/*.h)
file(GLOB_RECURSE sources_Skills Skills/*.cpp Skills/*.h)
file(GLOB_RECURSE sources_Spells Spells/*.cpp Spells/*.h)
file(GLOB_RECURSE sources_Support Support/*.cpp Support/*.h)
file(GLOB_RECURSE sources_Texts Texts/*.cpp Texts/*.h)
file(GLOB_RECURSE sources_Tools Tools/*.cpp Tools/*.h)
file(GLOB_RECURSE sources_Warden Warden/*.cpp Warden/*.h)
file(GLOB_RECURSE sources_Weather Weather/*.cpp Weather/*.h)
file(GLOB_RECURSE sources_World World/*.cpp World/*.h)
# Create game-libary
CollectSourceFiles(
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE_SOURCES
# Exclude
${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders)
if (USE_COREPCH)
set(game_STAT_PCH_HDR PrecompiledHeaders/gamePCH.h)
set(game_STAT_PCH_SRC PrecompiledHeaders/gamePCH.cpp)
set(PRIVATE_PCH_HEADER PrecompiledHeaders/gamePCH.h)
set(PRIVATE_PCH_SOURCE PrecompiledHeaders/gamePCH.cpp)
endif ()
set(game_STAT_SRCS
${game_STAT_SRCS}
${sources_Accounts}
${sources_Achievements}
${sources_Addons}
${sources_AI}
${sources_AuctionHouse}
${sources_AuctionHouseBot}
${sources_Battlefield}
${sources_Battlegrounds}
${sources_BattlePets}
${sources_Calendar}
${sources_Chat}
${sources_Combat}
${sources_Conditions}
${sources_DataStores}
${sources_DungeonFinding}
${sources_Entities}
${sources_Events}
${sources_Garrison}
${sources_Globals}
${sources_Grids}
${sources_Groups}
${sources_Guilds}
${sources_Handlers}
${sources_Instances}
${sources_Loot}
${sources_Mails}
${sources_Maps}
${sources_Miscellaneous}
${sources_Movement}
${sources_OutdoorPvP}
${sources_Pools}
${sources_Quests}
${sources_Reputation}
${sources_Scripting}
${sources_Server}
${sources_Skills}
${sources_Spells}
${sources_Support}
${sources_Texts}
${sources_Tools}
${sources_Warden}
${sources_Weather}
${sources_World}
)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/Accounts
${CMAKE_CURRENT_SOURCE_DIR}/Achievements
${CMAKE_CURRENT_SOURCE_DIR}/Addons
${CMAKE_CURRENT_SOURCE_DIR}/AI
${CMAKE_CURRENT_SOURCE_DIR}/AI/CoreAI
${CMAKE_CURRENT_SOURCE_DIR}/AI/ScriptedAI
${CMAKE_CURRENT_SOURCE_DIR}/AI/SmartScripts
${CMAKE_CURRENT_SOURCE_DIR}/AuctionHouse
${CMAKE_CURRENT_SOURCE_DIR}/AuctionHouseBot
${CMAKE_CURRENT_SOURCE_DIR}/Battlefield
${CMAKE_CURRENT_SOURCE_DIR}/Battlefield/Zones
${CMAKE_CURRENT_SOURCE_DIR}/Battlegrounds
${CMAKE_CURRENT_SOURCE_DIR}/Battlegrounds/Zones
${CMAKE_CURRENT_SOURCE_DIR}/BattlePets
${CMAKE_CURRENT_SOURCE_DIR}/Calendar
${CMAKE_CURRENT_SOURCE_DIR}/Chat
${CMAKE_CURRENT_SOURCE_DIR}/Chat/Channels
${CMAKE_CURRENT_SOURCE_DIR}/Combat
${CMAKE_CURRENT_SOURCE_DIR}/Conditions
${CMAKE_CURRENT_SOURCE_DIR}/DataStores
${CMAKE_CURRENT_SOURCE_DIR}/DungeonFinding
${CMAKE_CURRENT_SOURCE_DIR}/Entities/AreaTrigger
${CMAKE_CURRENT_SOURCE_DIR}/Entities/Corpse
${CMAKE_CURRENT_SOURCE_DIR}/Entities/Creature
${CMAKE_CURRENT_SOURCE_DIR}/Entities/DynamicObject
${CMAKE_CURRENT_SOURCE_DIR}/Entities/GameObject
${CMAKE_CURRENT_SOURCE_DIR}/Entities/Item
${CMAKE_CURRENT_SOURCE_DIR}/Entities/Item/Container
${CMAKE_CURRENT_SOURCE_DIR}/Entities/Object
${CMAKE_CURRENT_SOURCE_DIR}/Entities/Object/Updates
${CMAKE_CURRENT_SOURCE_DIR}/Entities/Pet
${CMAKE_CURRENT_SOURCE_DIR}/Entities/Player
${CMAKE_CURRENT_SOURCE_DIR}/Entities/Taxi
${CMAKE_CURRENT_SOURCE_DIR}/Entities/Totem
${CMAKE_CURRENT_SOURCE_DIR}/Entities/Transport
${CMAKE_CURRENT_SOURCE_DIR}/Entities/Unit
${CMAKE_CURRENT_SOURCE_DIR}/Entities/Vehicle
${CMAKE_CURRENT_SOURCE_DIR}/Events
${CMAKE_CURRENT_SOURCE_DIR}/Garrison
${CMAKE_CURRENT_SOURCE_DIR}/Globals
${CMAKE_CURRENT_SOURCE_DIR}/Grids
${CMAKE_CURRENT_SOURCE_DIR}/Grids/Cells
${CMAKE_CURRENT_SOURCE_DIR}/Grids/Notifiers
${CMAKE_CURRENT_SOURCE_DIR}/Groups
${CMAKE_CURRENT_SOURCE_DIR}/Guilds
${CMAKE_CURRENT_SOURCE_DIR}/Handlers
${CMAKE_CURRENT_SOURCE_DIR}/Instances
${CMAKE_CURRENT_SOURCE_DIR}/Loot
${CMAKE_CURRENT_SOURCE_DIR}/Mails
${CMAKE_CURRENT_SOURCE_DIR}/Maps
${CMAKE_CURRENT_SOURCE_DIR}/Miscellaneous
${CMAKE_CURRENT_SOURCE_DIR}/Movement
${CMAKE_CURRENT_SOURCE_DIR}/Movement/MovementGenerators
${CMAKE_CURRENT_SOURCE_DIR}/Movement/Spline
${CMAKE_CURRENT_SOURCE_DIR}/Movement/Waypoints
${CMAKE_CURRENT_SOURCE_DIR}/OutdoorPvP
${CMAKE_CURRENT_SOURCE_DIR}/Pools
${CMAKE_CURRENT_SOURCE_DIR}/Quests
${CMAKE_CURRENT_SOURCE_DIR}/Reputation
${CMAKE_CURRENT_SOURCE_DIR}/Scripting
${CMAKE_CURRENT_SOURCE_DIR}/Server
${CMAKE_CURRENT_SOURCE_DIR}/Server/Packets
${CMAKE_CURRENT_SOURCE_DIR}/Server/Protocol
${CMAKE_CURRENT_SOURCE_DIR}/Skills
${CMAKE_CURRENT_SOURCE_DIR}/Spells
${CMAKE_CURRENT_SOURCE_DIR}/Spells/Auras
${CMAKE_CURRENT_SOURCE_DIR}/Support
${CMAKE_CURRENT_SOURCE_DIR}/Texts
${CMAKE_CURRENT_SOURCE_DIR}/Tickets
${CMAKE_CURRENT_SOURCE_DIR}/Tools
${CMAKE_CURRENT_SOURCE_DIR}/Warden
${CMAKE_CURRENT_SOURCE_DIR}/Warden/Modules
${CMAKE_CURRENT_SOURCE_DIR}/Weather
${CMAKE_CURRENT_SOURCE_DIR}/World
${CMAKE_SOURCE_DIR}/dep/cppformat
${CMAKE_SOURCE_DIR}/dep/g3dlite/include
${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour/Include
${CMAKE_SOURCE_DIR}/dep/zlib
${CMAKE_SOURCE_DIR}/dep/zmqpp
${CMAKE_SOURCE_DIR}/src/common
${CMAKE_SOURCE_DIR}/src/common/Collision
${CMAKE_SOURCE_DIR}/src/common/Collision/Management
${CMAKE_SOURCE_DIR}/src/common/Collision/Maps
${CMAKE_SOURCE_DIR}/src/common/Collision/Models
${CMAKE_SOURCE_DIR}/src/common/Configuration
${CMAKE_SOURCE_DIR}/src/common/Cryptography
${CMAKE_SOURCE_DIR}/src/common/Cryptography/Authentication
${CMAKE_SOURCE_DIR}/src/common/Debugging
${CMAKE_SOURCE_DIR}/src/common/Logging
${CMAKE_SOURCE_DIR}/src/common/Threading
${CMAKE_SOURCE_DIR}/src/common/Utilities
${CMAKE_SOURCE_DIR}/src/server/database
${CMAKE_SOURCE_DIR}/src/server/database/Database
${CMAKE_SOURCE_DIR}/src/server/ipc
${CMAKE_SOURCE_DIR}/src/server/shared
${CMAKE_SOURCE_DIR}/src/server/shared/DataStores
${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic
${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic/LinkedReference
${CMAKE_SOURCE_DIR}/src/server/shared/Networking
${CMAKE_SOURCE_DIR}/src/server/shared/Packets
${MYSQL_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR}
${VALGRIND_INCLUDE_DIR}
${ZMQ_INCLUDE_DIR}
)
GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
add_library(game STATIC
${game_STAT_PCH_SRC}
${game_STAT_SRCS}
add_library(game
${PRIVATE_SOURCES}
${PRIVATE_PCH_SOURCE}
)
CollectIncludeDirectories(
${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC_INCLUDES
# Exclude
${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders)
target_include_directories(game
PUBLIC
${PUBLIC_INCLUDES}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(game
PUBLIC
ipc
Detour)
set_target_properties(game
PROPERTIES
FOLDER
"server")
# Generate precompiled header
if (USE_COREPCH)
add_cxx_pch(game ${game_STAT_PCH_HDR} ${game_STAT_PCH_SRC})
add_cxx_pch(game ${PRIVATE_PCH_HEADER} ${PRIVATE_PCH_SOURCE})
endif ()

View File

@@ -8,18 +8,26 @@
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
file(GLOB_RECURSE sources_ipc *.cpp *.h)
CollectSourceFiles(
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE_SOURCES)
set(ipc_SRCS
${sources_ipc}
)
GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/dep/zmqpp
${CMAKE_SOURCE_DIR}/src/common
${CMAKE_SOURCE_DIR}/src/server/shared
${ZMQ_INCLUDE_DIR}
)
add_library(ipc ${PRIVATE_SOURCES})
add_library(ipc STATIC ${ipc_SRCS})
target_include_directories(ipc
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(ipc
PUBLIC
shared
zmqpp)
set_target_properties(ipc
PROPERTIES
FOLDER
"server")

View File

@@ -8,71 +8,46 @@
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
if( USE_COREPCH )
include_directories(${CMAKE_CURRENT_BINARY_DIR})
endif()
file(GLOB_RECURSE sources_Cryptography Cryptography/*.cpp Cryptography/*.h)
file(GLOB_RECURSE sources_DataStores DataStores/*.cpp DataStores/*.h)
file(GLOB_RECURSE sources_Dynamic Dynamic/*.cpp Dynamic/*.h)
file(GLOB_RECURSE sources_Networking Networking/*.cpp Networking/*.h)
file(GLOB_RECURSE sources_Packets Packets/*.cpp Packets/*.h)
file(GLOB_RECURSE sources_Realm Realm/*.cpp Realm/*.h)
file(GLOB sources_localdir *.cpp *.h)
# Manually set sources for Debugging directory as we don't want to include WheatyExceptionReport in shared project
# It needs to be included both in bnetserver and worldserver for the static global variable to be properly initialized
# and to handle crash logs on windows
set(sources_Debugging Debugging/Errors.cpp Debugging/Errors.h)
#
# Build shared sourcelist
#
CollectSourceFiles(
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE_SOURCES
# Exclude
${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders)
if (USE_COREPCH)
set(shared_STAT_PCH_HDR PrecompiledHeaders/sharedPCH.h)
set(shared_STAT_PCH_SRC PrecompiledHeaders/sharedPCH.cpp)
set(PRIVATE_PCH_HEADER PrecompiledHeaders/sharedPCH.h)
set(PRIVATE_PCH_SOURCE PrecompiledHeaders/sharedPCH.cpp)
endif()
set(shared_STAT_SRCS
${shared_STAT_SRCS}
${sources_Cryptography}
${sources_DataStores}
${sources_Dynamic}
${sources_Networking}
${sources_Packets}
${sources_Realm}
${sources_Service}
${sources_localdir}
)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/Dynamic
${CMAKE_CURRENT_SOURCE_DIR}/Networking
${CMAKE_SOURCE_DIR}/dep/cppformat
${CMAKE_SOURCE_DIR}/src/common/
${CMAKE_SOURCE_DIR}/src/common/Debugging
${CMAKE_SOURCE_DIR}/src/common/Logging
${CMAKE_SOURCE_DIR}/src/common/Threading
${CMAKE_SOURCE_DIR}/src/common/Utilities
${CMAKE_SOURCE_DIR}/src/server/database
${CMAKE_SOURCE_DIR}/src/server/database/Database
${MYSQL_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR}
${VALGRIND_INCLUDE_DIR}
)
GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
add_library(shared STATIC
${shared_STAT_SRCS}
${shared_STAT_PCH_SRC}
add_library(shared
${PRIVATE_SOURCES}
${PRIVATE_PCH_SOURCE}
)
add_dependencies(shared revision_data.h)
CollectIncludeDirectories(
${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC_INCLUDES
# Exclude
${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders)
target_include_directories(shared
PUBLIC
${PUBLIC_INCLUDES}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(shared
PUBLIC
database)
set_target_properties(shared
PROPERTIES
FOLDER
"server")
# Generate precompiled header
if (USE_COREPCH)
add_cxx_pch(shared ${shared_STAT_PCH_HDR} ${shared_STAT_PCH_SRC})
add_cxx_pch(shared ${PRIVATE_PCH_HEADER} ${PRIVATE_PCH_SOURCE})
endif ()