Skip to content

Commit

Permalink
Remake CMake dependency structure into a more modern one
Browse files Browse the repository at this point in the history
Also bumps minimum supported CMake version to 3.0 as we use modern features.
  • Loading branch information
Warlockbugs committed Sep 2, 2017
1 parent 75899ad commit 6c2b704
Show file tree
Hide file tree
Showing 51 changed files with 259 additions and 166 deletions.
53 changes: 27 additions & 26 deletions CMakeLists.txt
Expand Up @@ -21,7 +21,7 @@ project(CMaNGOS_WoTLK)
set(CMANGOS_BINARY_SERVER_NAME "mangosd")
set(CMANGOS_BINARY_REALMD_NAME "realmd")

cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.0)

# Function to remove duplicate entries in provided string
function(RemoveDuplicateSubstring stringIn stringOut)
Expand Down Expand Up @@ -221,51 +221,52 @@ if(WIN32)
set(OPENSSL_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/dep/lib/include")
set(OPENSSL_LIBRARIES "${CMAKE_SOURCE_DIR}/dep/lib/${DEP_ARCH}_release/libcrypto.dll.lib")
set(OPENSSL_DEBUG_LIBRARIES "${CMAKE_SOURCE_DIR}/dep/lib/${DEP_ARCH}_debug/libcrypto.dll.lib")
set(ZLIB_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/dep/zlib")
set(ZLIB_LIBRARIES "z")
set(BZIP2_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/dep/src/bzip2")
set(BZIP2_LIBRARIES "bzip2")
endif()

# *nix-specific packages
if(UNIX)
if(POSTGRESQL)
find_package(PostgreSQL REQUIRED)

if(POSTGRESQL_FOUND)
include_directories(${POSTGRESQL_INCLUDE_DIRS})
endif(POSTGRESQL_FOUND)

else()
find_package(MySQL REQUIRED)
endif()

# If OpenSSL path isn't specified on mac we set the one that homebrew uses
# since that's what most people will be using.
if (APPLE)
if (NOT OPENSSL_ROOT_DIR)
if(APPLE)
find_package(OpenSSL 1.0.1)
if(NOT OpenSSL_FOUND AND NOT OPENSSL_FOUND)
# If OpenSSL path isn't specified on mac we set the one that homebrew uses and try again
set(OPENSSL_ROOT_DIR /usr/local/opt/openssl/)
endif()
if (NOT OPENSSL_INCLUDE_DIR)
set(OPENSSL_INCLUDE_DIR /usr/local/opt/openssl/include)
find_package(OpenSSL 1.0.1)
endif()
else()
find_package(OpenSSL 1.0.1)
endif()
# Some Linux distributions provide an OpenSSL-1.0 package alongside 1.1+
if (UNIX)
if (NOT OPENSSL_ROOT_DIR)
set(OPENSSL_ROOT_DIR /usr/lib/openssl-1.0)

if(NOT OpenSSL_FOUND AND NOT OPENSSL_FOUND)
message(FATAL_ERROR "OpenSSL not found!")
else()
if(OpenSSL_VERSION AND NOT OPENSSL_VERSION)
set(OPENSSL_VERSION ${OpenSSL_VERSION})
endif()
if (NOT OPENSSL_INCLUDE_DIR)
set(OPENSSL_INCLUDE_DIR /usr/include/openssl-1.0)
if(OPENSSL_VERSION VERSION_LESS 1.0.1)
message(WARNING "You are using an outdated version of OpenSSL library. It may be incompatible or vulnerable.")
endif()
endif()
find_package(OpenSSL 1.0 REQUIRED)
if(NOT OPENSSL_VERSION VERSION_LESS "1.1")
message(FATAL_ERROR "You have unsupported version of OpenSSL library. Use version below 1.1")
endif()

find_package(ZLIB REQUIRED)
if(ZLIB_FOUND)
# add to global includes and linking lists for all sub-projects at once
include_directories(${ZLIB_INCLUDE_DIRS})
link_libraries(${ZLIB_LIBRARIES})
endif()
if(BUILD_EXTRACTORS)
find_package(BZip2 REQUIRED)
if(BZip2_FOUND OR BZIP2_FOUND)
# add to global includes and linking lists for all sub-projects at once
include_directories(${BZIP2_INCLUDE_DIRS})
link_libraries(${BZIP2_LIBRARIES})
endif()
endif()
endif()

Expand Down
11 changes: 6 additions & 5 deletions contrib/extractor/CMakeLists.txt
Expand Up @@ -14,22 +14,23 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

cmake_minimum_required (VERSION 2.6)
cmake_minimum_required (VERSION 3.0)
set(EXECUTABLE_NAME "ad")
project (${EXECUTABLE_NAME})

list(APPEND AD_SOURCE
loadlib/loadlib.cpp
loadlib/adt.cpp
loadlib/wdt.cpp
dbcfile.cpp
mpq_libmpq.cpp
System.cpp)
System.cpp
)

include_directories(loadlib ${CMAKE_SOURCE_DIR}/dep/libmpq)
include_directories(loadlib)

add_executable(${EXECUTABLE_NAME} ${AD_SOURCE})
target_link_libraries(${EXECUTABLE_NAME} mpqlib ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES})

target_link_libraries(${EXECUTABLE_NAME} mpqlib)

if(MSVC)
# Define OutDir to source/bin/(platform)_(configuaration) folder.
Expand Down
24 changes: 14 additions & 10 deletions contrib/mmap/CMakeLists.txt
Expand Up @@ -8,7 +8,7 @@
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

cmake_minimum_required (VERSION 2.6)
cmake_minimum_required (VERSION 3.0)

set(EXECUTABLE_NAME "MoveMapGen")
project (${EXECUTABLE_NAME})
Expand All @@ -26,18 +26,12 @@ endif()

include_directories(
../../src
../../src/shared
../../src/game
../../src/game/Vmap
../../dep/include/g3dlite
../../src/framework
../../dep/recastnavigation/Detour/Include
../../dep/recastnavigation/Recast/Include
${ZLIB_INCLUDE_DIRS}
)

# TODO: Do we still need that vmaplib?
add_library(vmaplib
add_library(vmaplib STATIC
../../src/game/Vmap/BIH.cpp
../../src/game/Vmap/VMapManager2.cpp
../../src/game/Vmap/MapTree.cpp
Expand All @@ -51,7 +45,13 @@ IF(APPLE)
SET(EXTRA_LIBS ${CORE_SERVICES})
ENDIF (APPLE)

target_link_libraries(vmaplib g3dlite ${ZLIB_LIBRARIES} ${EXTRA_LIBS})
target_link_libraries(vmaplib
PUBLIC shared
PUBLIC g3dlite
PUBLIC detour
PUBLIC recast
PUBLIC ${EXTRA_LIBS}
)

set(SOURCES
./src/IntermediateValues.cpp
Expand All @@ -63,7 +63,11 @@ set(SOURCES

add_executable(${EXECUTABLE_NAME} ${SOURCES})

target_link_libraries(${EXECUTABLE_NAME} g3dlite vmaplib detour recast ${ZLIB_LIBRARIES})
target_link_libraries(${EXECUTABLE_NAME}
vmaplib
detour
recast
)

if(MSVC)
# Define OutDir to source/bin/(platform)_(configuaration) folder.
Expand Down
12 changes: 7 additions & 5 deletions contrib/vmap_assembler/CMakeLists.txt
Expand Up @@ -23,10 +23,7 @@ if(UNIX)
ADD_DEFINITIONS("-ggdb")
endif()

include_directories(${CMAKE_SOURCE_DIR}/src/shared
${CMAKE_SOURCE_DIR}/src/game/Vmap
${CMAKE_SOURCE_DIR}/dep/include/g3dlite
${CMAKE_SOURCE_DIR}/src/framework)
include_directories(${CMAKE_SOURCE_DIR}/src/game/Vmap)

list(APPEND VMAP_ASSEMBLER_SOURCE
${CMAKE_SOURCE_DIR}/src/game/Vmap/BIH.cpp
Expand All @@ -43,7 +40,12 @@ IF(APPLE)
ENDIF (APPLE)

add_executable(${EXECUTABLE_NAME} ${VMAP_ASSEMBLER_SOURCE})
target_link_libraries(${EXECUTABLE_NAME} g3dlite ${ZLIB_LIBRARIES} ${EXTRA_LIBS})

target_link_libraries(${EXECUTABLE_NAME}
shared
g3dlite
${EXTRA_LIBS}
)

if(MSVC)
# Define OutDir to source/bin/(platform)_(configuaration) folder.
Expand Down
4 changes: 1 addition & 3 deletions contrib/vmap_extractor/CMakeLists.txt
Expand Up @@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

cmake_minimum_required (VERSION 2.6)
cmake_minimum_required (VERSION 3.0)
project (MANGOS_VMAP_EXTRACT_IO)

# uncomment next line to disable debug mode
Expand All @@ -34,6 +34,4 @@ if (APPLE)
add_definitions("-Dftello64=ftello")
endif()

include_directories(${CMAKE_SOURCE_DIR}/dep/libmpq)

add_subdirectory(vmapextract)
7 changes: 4 additions & 3 deletions contrib/vmap_extractor/vmapextract/CMakeLists.txt
Expand Up @@ -14,13 +14,14 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

cmake_minimum_required (VERSION 2.6)
cmake_minimum_required (VERSION 3.0)
set(EXECUTABLE_NAME "vmap_extractor")
project (${EXECUTABLE_NAME})

add_executable(${EXECUTABLE_NAME} adtfile.cpp dbcfile.cpp gameobject_extract.cpp model.cpp mpq_libmpq.cpp vmapexport.cpp wdtfile.cpp wmo.cpp)
add_executable(${EXECUTABLE_NAME} adtfile.cpp dbcfile.cpp gameobject_extract.cpp model.cpp mpq_libmpq.cpp vmapexport.cpp wdtfile.cpp wmo.cpp)

target_link_libraries(${EXECUTABLE_NAME} mpqlib)

target_link_libraries(${EXECUTABLE_NAME} mpqlib ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES})
if(MSVC)
# Define OutDir to source/bin/(platform)_(configuaration) folder.
set_target_properties(${EXECUTABLE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG "${DEV_BIN_DIR}/Extractors")
Expand Down
6 changes: 0 additions & 6 deletions dep/CMakeLists.txt
Expand Up @@ -22,9 +22,3 @@ add_subdirectory(src)
if (BUILD_EXTRACTORS)
add_subdirectory(libmpq)
endif()

if(MSVC)
add_subdirectory(zlib)
set_target_properties(${ZLIB_LIBRARIES} PROPERTIES PROJECT_LABEL "zlib")
set_target_properties(${ZLIB_LIBRARIES} PROPERTIES FOLDER "Dependencies")
endif()
27 changes: 19 additions & 8 deletions dep/libmpq/CMakeLists.txt
Expand Up @@ -8,21 +8,32 @@
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

cmake_minimum_required (VERSION 2.8)
project(mpqlib)
cmake_minimum_required (VERSION 3.0)

# disable warnings for dependencies
DisableWarnings()

include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/libmpq
${ZLIB_INCLUDE_DIRS}
${BZIP2_INCLUDE_DIRS})
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/libmpq
)

file(GLOB mpqfiles libmpq/*.c libmpq/*.h *.h)

add_library(mpqlib STATIC ${mpqfiles})
target_link_libraries(mpqlib ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES})
add_library(mpqlib STATIC
${mpqfiles}
)

if(WIN32)
target_link_libraries(mpqlib
PUBLIC z
PUBLIC bzip2
)
endif()

target_include_directories(mpqlib
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
)

if(MSVC)
target_compile_options(mpqlib PRIVATE /wd4103)
Expand Down
17 changes: 14 additions & 3 deletions dep/recastnavigation/CMakeLists.txt
Expand Up @@ -18,11 +18,22 @@

if (BUILD_GAME_SERVER OR BUILD_EXTRACTORS)
add_subdirectory(Detour)

set_target_properties(detour PROPERTIES FOLDER "Dependencies")
if(MSVC)
set_target_properties(detour PROPERTIES FOLDER "Dependencies")
endif()
target_include_directories(detour
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/Detour/Include
)
endif()

if (BUILD_EXTRACTORS)
add_subdirectory(Recast)
set_target_properties(recast PROPERTIES FOLDER "Dependencies")
if(MSVC)
set_target_properties(recast PROPERTIES FOLDER "Dependencies")
endif()
target_include_directories(recast
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/Recast/Include
)
endif()
4 changes: 2 additions & 2 deletions dep/src/CMakeLists.txt
Expand Up @@ -18,14 +18,14 @@

if (BUILD_GAME_SERVER OR BUILD_LOGIN_SERVER)
add_subdirectory(gsoap)
set_target_properties(gsoap PROPERTIES FOLDER "Dependencies")
endif()

add_subdirectory(g3dlite)
add_subdirectory(utf8cpp)

if(WIN32)
add_subdirectory(zlib)
if(BUILD_EXTRACTORS)
add_subdirectory(bzip2)
set_target_properties(${BZIP2_LIBRARIES} PROPERTIES FOLDER "Dependencies")
endif()
endif()
33 changes: 24 additions & 9 deletions dep/src/bzip2/CMakeLists.txt
Expand Up @@ -15,17 +15,32 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

list(APPEND BZIP2_SRCS
compress.c
crctable.c
decompress.c
huffman.c
randtable.c
blocksort.c
bzlib.c)
set(LIBRARY_NAME bzip2)

set(LIBRARY_SRCS
compress.c
crctable.c
decompress.c
huffman.c
randtable.c
blocksort.c
bzlib.c
)

include_directories(
${CMAKE_SOURCE_DIR}/dep/include/bzip2
${CMAKE_CURRENT_SOURCE_DIR}
)

add_library(bzip2 STATIC ${BZIP2_SRCS})
add_library(${LIBRARY_NAME} STATIC
${LIBRARY_SRCS}
)

target_include_directories(${LIBRARY_NAME}
INTERFACE ${CMAKE_SOURCE_DIR}/dep/include/bzip2
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
)

if(MSVC)
set_target_properties(${LIBRARY_NAME} PROPERTIES FOLDER "Dependencies")
endif()
13 changes: 8 additions & 5 deletions dep/src/g3dlite/CMakeLists.txt
Expand Up @@ -120,18 +120,21 @@ set(LIBRARY_SRCS

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/dep/include
${CMAKE_SOURCE_DIR}/dep/include/g3dlite
${ZLIB_INCLUDE_DIRS}
)

add_library(${LIBRARY_NAME} STATIC
${LIBRARY_SRCS}
)

if(WIN32)
target_link_libraries(${LIBRARY_NAME} PUBLIC z)
endif()

target_include_directories(${LIBRARY_NAME}
INTERFACE ${CMAKE_SOURCE_DIR}/dep/include/g3dlite
)

if(MSVC)
target_link_libraries(${LIBRARY_NAME}
${ZLIB_LIBRARIES}
)
set_target_properties(${LIBRARY_NAME} PROPERTIES FOLDER "Dependencies")
endif()

0 comments on commit 6c2b704

Please sign in to comment.