CMake: Use inherited dependencies in common and tools (partial pick, need help on this)

This commit is contained in:
Aokromes committed 2016-05-23 06:24:26 +02:00
1 parent beade4616a
commit 460a660d4f
6 files changed
+124 -59

No files matched your search

+1
View File
@@ -56,6 +56,7 @@ endif()
include(CheckPlatform) include(CheckPlatform)
include(GroupSources) include(GroupSources)
include(AutoCollect)
find_package(PCHSupport) find_package(PCHSupport)
find_package(ZMQ REQUIRED) find_package(ZMQ REQUIRED)
+71
View File
@@ -0,0 +1,71 @@
# Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# Collects all source files into the given variable,
# which is useful to include all sources in subdirectories.
# Ignores full qualified directories listed in the variadic arguments.
#
# Use it like:
# CollectSourceFiles(
# ${CMAKE_CURRENT_SOURCE_DIR}
# COMMON_PRIVATE_SOURCES
# # Exclude
# ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders
# ${CMAKE_CURRENT_SOURCE_DIR}/Platform)
#
function(CollectSourceFiles current_dir variable)
list(FIND ARGN "${current_dir}" IS_EXCLUDED)
if(IS_EXCLUDED EQUAL -1)
file(GLOB COLLECTED_SOURCES
${current_dir}/*.c
${current_dir}/*.cc
${current_dir}/*.cpp
${current_dir}/*.inl
${current_dir}/*.def
${current_dir}/*.h
${current_dir}/*.hh
${current_dir}/*.hpp)
list(APPEND ${variable} ${COLLECTED_SOURCES})
file(GLOB SUB_DIRECTORIES ${current_dir}/*)
foreach(SUB_DIRECTORY ${SUB_DIRECTORIES})
if (IS_DIRECTORY ${SUB_DIRECTORY})
CollectSourceFiles("${SUB_DIRECTORY}" "${variable}" "${ARGN}")
endif()
endforeach()
set(${variable} ${${variable}} PARENT_SCOPE)
endif()
endfunction()
# Collects all subdirectoroies into the given variable,
# which is useful to include all subdirectories.
# Ignores full qualified directories listed in the variadic arguments.
#
# Use it like:
# CollectIncludeDirectories(
# ${CMAKE_CURRENT_SOURCE_DIR}
# COMMON_PUBLIC_INCLUDES
# # Exclude
# ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders
# ${CMAKE_CURRENT_SOURCE_DIR}/Platform)
#
function(CollectIncludeDirectories current_dir variable)
list(FIND ARGN "${current_dir}" IS_EXCLUDED)
if(IS_EXCLUDED EQUAL -1)
list(APPEND ${variable} ${current_dir})
file(GLOB SUB_DIRECTORIES ${current_dir}/*)
foreach(SUB_DIRECTORY ${SUB_DIRECTORIES})
if (IS_DIRECTORY ${SUB_DIRECTORY})
CollectIncludeDirectories("${SUB_DIRECTORY}" "${variable}" "${ARGN}")
endif()
endforeach()
set(${variable} ${${variable}} PARENT_SCOPE)
endif()
endfunction()
+46 -53
View File
@@ -8,42 +8,31 @@
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
if( USE_COREPCH ) CollectSourceFiles(
include_directories(${CMAKE_CURRENT_BINARY_DIR}) ${CMAKE_CURRENT_SOURCE_DIR}
endif() PRIVATE_SOURCES
# Exclude
file(GLOB_RECURSE sources_Common Common.cpp Common.h) ${CMAKE_CURRENT_SOURCE_DIR}/Debugging
file(GLOB_RECURSE sources_Collision Collision/*.cpp Collision/*.h) ${CMAKE_CURRENT_SOURCE_DIR}/Platform
file(GLOB_RECURSE sources_Threading Threading/*.cpp Threading/*.h) ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders)
file(GLOB_RECURSE sources_Utilities Utilities/*.cpp Utilities/*.h)
file(GLOB_RECURSE sources_Configuration Configuration/*.cpp Configuration/*.h)
file(GLOB_RECURSE sources_Logging Logging/*.cpp Logging/*.h)
if (SERVERS)
file(GLOB_RECURSE sources_Cryptography Cryptography/*.cpp Cryptography/*.h)
endif (SERVERS)
# Manually set sources for Debugging directory as we don't want to include WheatyExceptionReport in common project # Manually set sources for Debugging directory as we don't want to include WheatyExceptionReport in common project
# It needs to be included both in authserver and worldserver for the static global variable to be properly initialized # It needs to be included both in authserver and worldserver for the static global variable to be properly initialized
# and to handle crash logs on windows # and to handle crash logs on windows
set(sources_Debugging Debugging/Errors.cpp Debugging/Errors.h) list(APPEND PRIVATE_SOURCES
file(GLOB sources_localdir *.cpp *.h) ${CMAKE_CURRENT_SOURCE_DIR}/Debugging/Errors.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Debugging/Errors.h)
if (USE_COREPCH) if (USE_COREPCH)
set(common_STAT_PCH_HDR PrecompiledHeaders/commonPCH.h) set(PRIVATE_PCH_HEADER PrecompiledHeaders/commonPCH.h)
set(common_STAT_PCH_SRC PrecompiledHeaders/commonPCH.cpp) set(PRIVATE_PCH_SOURCE PrecompiledHeaders/commonPCH.cpp)
endif (USE_COREPCH) endif (USE_COREPCH)
set(common_STAT_SRCS GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
${common_STAT_SRCS}
${sources_Common} add_library(common
${sources_Collision} ${PRIVATE_SOURCES}
${sources_Threading} ${PRIVATE_PCH_SOURCE}
${sources_Utilities}
${sources_Debugging}
${sources_Configuration}
${sources_Logging}
${sources_Cryptography}
${sources_localdir}
) )
# Do NOT add any extra include directory here, as we don't want the common # Do NOT add any extra include directory here, as we don't want the common
@@ -55,37 +44,41 @@ set(common_STAT_SRCS
# linkage (enums, defines...) it is discouraged to do so unless necessary, as it will pullute # linkage (enums, defines...) it is discouraged to do so unless necessary, as it will pullute
# include_directories leading to further unnoticed dependency aditions # include_directories leading to further unnoticed dependency aditions
# Linker Depencency requirements: none # Linker Depencency requirements: none
include_directories( CollectIncludeDirectories(
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/Collision PUBLIC_INCLUDES
${CMAKE_CURRENT_SOURCE_DIR}/Collision/Management # Exclude
${CMAKE_CURRENT_SOURCE_DIR}/Collision/Maps ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders)
${CMAKE_CURRENT_SOURCE_DIR}/Collision/Models
${CMAKE_CURRENT_SOURCE_DIR}/Configuration
${CMAKE_CURRENT_SOURCE_DIR}/Cryptography
${CMAKE_CURRENT_SOURCE_DIR}/Debugging
${CMAKE_CURRENT_SOURCE_DIR}/Logging
${CMAKE_CURRENT_SOURCE_DIR}/Utilities
${CMAKE_SOURCE_DIR}/dep/cppformat
${CMAKE_SOURCE_DIR}/dep/g3dlite/include
${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour/Include
${CMAKE_SOURCE_DIR}/dep/SFMT
${CMAKE_SOURCE_DIR}/dep/utf8cpp
${OPENSSL_INCLUDE_DIR}
${VALGRIND_INCLUDE_DIR}
)
GroupSources(${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(common
PUBLIC
# Provide the binary dir for all child targets
${CMAKE_BINARY_DIR}
${PUBLIC_INCLUDES}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR})
add_library(common STATIC target_link_libraries(common
${common_STAT_SRCS} PUBLIC
${common_STAT_PCH_SRC} boost
) cppformat
g3dlib
Detour
sfmt
utf8cpp
openssl
valgrind
threads
jemalloc)
add_dependencies(common revision_data.h) add_dependencies(common revision_data.h)
set_target_properties(common
PROPERTIES
FOLDER
"server")
# Generate precompiled header # Generate precompiled header
if (USE_COREPCH) if (USE_COREPCH)
add_cxx_pch(common ${common_STAT_PCH_HDR} ${common_STAT_PCH_SRC}) add_cxx_pch(common ${PRIVATE_PCH_HEADER} ${PRIVATE_PCH_SOURCE})
endif () endif ()
+6
View File
@@ -13,3 +13,9 @@ add_custom_target(revision_data.h ALL
COMMAND "${CMAKE_COMMAND}" -DBUILDDIR="${CMAKE_BINARY_DIR}" -P "${CMAKE_SOURCE_DIR}/cmake/genrev.cmake" "${CMAKE_BINARY_DIR}" COMMAND "${CMAKE_COMMAND}" -DBUILDDIR="${CMAKE_BINARY_DIR}" -P "${CMAKE_SOURCE_DIR}/cmake/genrev.cmake" "${CMAKE_BINARY_DIR}"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
) )
set_target_properties(revision_data.h
PROPERTIES
FOLDER
"server")
-2
View File
@@ -12,8 +12,6 @@
# This to stop a few silly crashes that could have been avoided IF people # This to stop a few silly crashes that could have been avoided IF people
# weren't doing some -O3 psychooptimizations etc. # weren't doing some -O3 psychooptimizations etc.
find_package(MySQL REQUIRED)
if(CMAKE_COMPILER_IS_GNUCXX AND NOT MINGW) if(CMAKE_COMPILER_IS_GNUCXX AND NOT MINGW)
add_definitions(-fno-delete-null-pointer-checks) add_definitions(-fno-delete-null-pointer-checks)
endif() endif()
-4
View File
@@ -8,10 +8,6 @@
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
if (NOT MYSQL_FOUND)
message(SEND_ERROR "MySQL wasn't found on your system but it's required to build the servers!")
endif()
if( USE_COREPCH ) if( USE_COREPCH )
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
endif() endif()