2022-01-17 11:46:33 +00:00
|
|
|
cmake_minimum_required(VERSION 3.14)
|
2021-12-05 17:54:36 +00:00
|
|
|
project(Darkflame)
|
2022-01-03 15:00:21 +00:00
|
|
|
include(CTest)
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-10 19:40:26 +00:00
|
|
|
set (CMAKE_CXX_STANDARD 17)
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
# Read variables from file
|
|
|
|
FILE(READ "${CMAKE_SOURCE_DIR}/CMakeVariables.txt" variables)
|
|
|
|
|
|
|
|
string(REPLACE "\\\n" "" variables ${variables})
|
|
|
|
string(REPLACE "\n" ";" variables ${variables})
|
|
|
|
|
|
|
|
# Set the cmake variables, formatted as "VARIABLE #" in variables
|
|
|
|
foreach(variable ${variables})
|
2022-07-16 23:24:16 +00:00
|
|
|
# If the string contains a #, skip it
|
|
|
|
if(NOT "${variable}" MATCHES "#")
|
2022-08-02 05:30:19 +00:00
|
|
|
|
2022-07-18 09:01:43 +00:00
|
|
|
# Split the variable into name and value
|
2022-07-16 23:24:16 +00:00
|
|
|
string(REPLACE "=" ";" variable ${variable})
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-18 09:01:43 +00:00
|
|
|
# Check that the length of the variable is 2 (name and value)
|
2022-07-16 23:24:16 +00:00
|
|
|
list(LENGTH variable length)
|
|
|
|
if(${length} EQUAL 2)
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-16 23:24:16 +00:00
|
|
|
list(GET variable 0 variable_name)
|
|
|
|
list(GET variable 1 variable_value)
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-16 23:24:16 +00:00
|
|
|
# Set the variable
|
|
|
|
set(${variable_name} ${variable_value})
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-16 23:24:16 +00:00
|
|
|
# Add compiler definition
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D${variable_name}=${variable_value}")
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-16 23:24:16 +00:00
|
|
|
message(STATUS "Variable: ${variable_name} = ${variable_value}")
|
2022-07-04 08:30:11 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2021-12-05 17:54:36 +00:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# Set the version
|
|
|
|
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
|
|
|
|
|
|
|
# Echo the version
|
|
|
|
message(STATUS "Version: ${PROJECT_VERSION}")
|
|
|
|
|
2022-08-19 02:23:42 +00:00
|
|
|
# Disable demo, tests and examples for recastNavigation. Turn these to ON if you want to use them
|
|
|
|
# This has to be done here to prevent a rare build error due to missing dependencies on the initial generations.
|
|
|
|
set(RECASTNAVIGATION_DEMO OFF CACHE BOOL "" FORCE)
|
|
|
|
set(RECASTNAVIGATION_TESTS OFF CACHE BOOL "" FORCE)
|
|
|
|
set(RECASTNAVIGATION_EXAMPLES OFF CACHE BOOL "" FORCE)
|
|
|
|
|
2022-07-16 23:24:16 +00:00
|
|
|
# Compiler flags:
|
2022-08-02 05:30:19 +00:00
|
|
|
# Disabled deprecated warnings as the MySQL includes have deprecated code in them.
|
2022-07-16 23:24:16 +00:00
|
|
|
# Disabled misleading indentation as DL_LinkedList from RakNet has a weird indent.
|
|
|
|
# Disabled no-register
|
|
|
|
# Disabled unknown pragmas because Linux doesn't understand Windows pragmas.
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPROJECT_VERSION=${PROJECT_VERSION}")
|
|
|
|
if(UNIX)
|
|
|
|
if(APPLE)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17 -O2 -Wuninitialized -D_GLIBCXX_USE_CXX11_ABI=0 -D_GLIBCXX_USE_CXX17_ABI=0 -fPIC")
|
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17 -O2 -Wuninitialized -D_GLIBCXX_USE_CXX11_ABI=0 -D_GLIBCXX_USE_CXX17_ABI=0 -static-libgcc -fPIC")
|
|
|
|
endif()
|
2022-08-19 02:23:42 +00:00
|
|
|
if (__dynamic AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
2022-07-16 23:24:16 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
|
|
|
|
endif()
|
|
|
|
if (__ggdb)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb")
|
|
|
|
endif()
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -O2 -fPIC")
|
|
|
|
elseif(MSVC)
|
|
|
|
# Skip warning for invalid conversion from size_t to uint32_t for all targets below for now
|
2022-07-20 08:23:53 +00:00
|
|
|
add_compile_options("/wd4267" "/utf-8")
|
2022-07-16 23:24:16 +00:00
|
|
|
elseif(WIN32)
|
|
|
|
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
|
|
|
endif()
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
# Our output dir
|
|
|
|
set(CMAKE_BINARY_DIR ${PROJECT_BINARY_DIR})
|
2022-07-16 23:24:16 +00:00
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
# Create a /res directory
|
|
|
|
make_directory(${CMAKE_BINARY_DIR}/res)
|
|
|
|
|
|
|
|
# Create a /locale directory
|
|
|
|
make_directory(${CMAKE_BINARY_DIR}/locale)
|
|
|
|
|
2021-12-13 15:57:43 +00:00
|
|
|
# Create a /logs directory
|
|
|
|
make_directory(${CMAKE_BINARY_DIR}/logs)
|
|
|
|
|
2022-07-18 09:01:43 +00:00
|
|
|
# Copy resource files on first build
|
2022-07-17 06:54:36 +00:00
|
|
|
set(RESOURCE_FILES "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blacklist.dcf")
|
|
|
|
foreach(resource_file ${RESOURCE_FILES})
|
|
|
|
if (NOT EXISTS ${PROJECT_BINARY_DIR}/${resource_file})
|
2022-07-16 23:24:16 +00:00
|
|
|
configure_file(
|
2022-07-17 06:54:36 +00:00
|
|
|
${CMAKE_SOURCE_DIR}/resources/${resource_file} ${PROJECT_BINARY_DIR}/${resource_file}
|
2022-07-16 23:24:16 +00:00
|
|
|
COPYONLY
|
|
|
|
)
|
2022-07-17 06:54:36 +00:00
|
|
|
message("Moved ${resource_file} to project binary directory")
|
2022-07-16 23:24:16 +00:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-16 23:24:16 +00:00
|
|
|
# Copy vanity files on first build
|
|
|
|
set(VANITY_FILES "CREDITS.md" "INFO.md" "TESTAMENT.md" "NPC.xml")
|
|
|
|
foreach(file ${VANITY_FILES})
|
|
|
|
configure_file("${CMAKE_SOURCE_DIR}/vanity/${file}" "${CMAKE_BINARY_DIR}/vanity/${file}" COPYONLY)
|
|
|
|
endforeach()
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-10 19:40:26 +00:00
|
|
|
# Move our migrations for MasterServer to run
|
|
|
|
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/migrations/)
|
|
|
|
file(GLOB SQL_FILES ${CMAKE_SOURCE_DIR}/migrations/dlu/*.sql)
|
2022-07-16 23:24:16 +00:00
|
|
|
foreach(file ${SQL_FILES})
|
|
|
|
get_filename_component(file ${file} NAME)
|
|
|
|
if (NOT EXISTS ${PROJECT_BINARY_DIR}/migrations/${file})
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_SOURCE_DIR}/migrations/dlu/${file} ${PROJECT_BINARY_DIR}/migrations/${file}
|
|
|
|
COPYONLY
|
|
|
|
)
|
|
|
|
endif()
|
2022-07-10 19:40:26 +00:00
|
|
|
endforeach()
|
|
|
|
|
2022-07-16 23:24:16 +00:00
|
|
|
# Create our list of include directories
|
|
|
|
set(INCLUDED_DIRECTORIES
|
|
|
|
"dCommon"
|
|
|
|
"dChatFilter"
|
2022-08-02 05:30:19 +00:00
|
|
|
"dGame"
|
|
|
|
"dGame/dBehaviors"
|
|
|
|
"dGame/dComponents"
|
|
|
|
"dGame/dGameMessages"
|
|
|
|
"dGame/dInventory"
|
|
|
|
"dGame/dMission"
|
|
|
|
"dGame/dEntity"
|
|
|
|
"dGame/dUtilities"
|
|
|
|
"dPhysics"
|
|
|
|
"dNavigation"
|
2022-08-04 00:59:47 +00:00
|
|
|
"dNavigation/dTerrain"
|
2022-08-02 05:30:19 +00:00
|
|
|
"dZoneManager"
|
|
|
|
"dDatabase"
|
2022-07-16 23:24:16 +00:00
|
|
|
"dDatabase/Tables"
|
|
|
|
"dNet"
|
|
|
|
"dScripts"
|
|
|
|
|
|
|
|
"thirdparty/raknet/Source"
|
|
|
|
"thirdparty/tinyxml2"
|
2022-08-19 02:23:42 +00:00
|
|
|
"thirdparty/recastnavigation"
|
2022-07-16 23:24:16 +00:00
|
|
|
"thirdparty/SQLite"
|
|
|
|
"thirdparty/cpplinq"
|
|
|
|
)
|
|
|
|
|
|
|
|
# Add system specfic includes for Apple, Windows and Other Unix OS' (including Linux)
|
|
|
|
if (APPLE)
|
|
|
|
include_directories("/usr/local/include/")
|
|
|
|
endif()
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-16 23:24:16 +00:00
|
|
|
if (WIN32)
|
|
|
|
set(INCLUDED_DIRECTORIES ${INCLUDED_DIRECTORIES} "thirdparty/libbcrypt/include")
|
|
|
|
elseif (UNIX)
|
|
|
|
set(INCLUDED_DIRECTORIES ${INCLUDED_DIRECTORIES} "thirdparty/libbcrypt")
|
|
|
|
set(INCLUDED_DIRECTORIES ${INCLUDED_DIRECTORIES} "thirdparty/libbcrypt/include/bcrypt")
|
|
|
|
endif()
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-16 23:24:16 +00:00
|
|
|
include_directories(${ZLIB_INCLUDE_DIRS})
|
|
|
|
# Add binary directory as an include directory
|
2021-12-05 17:54:36 +00:00
|
|
|
include_directories(${PROJECT_BINARY_DIR})
|
|
|
|
|
2022-07-16 23:24:16 +00:00
|
|
|
# Actually include the directories from our list
|
|
|
|
foreach (dir ${INCLUDED_DIRECTORIES})
|
|
|
|
include_directories(${PROJECT_SOURCE_DIR}/${dir})
|
|
|
|
endforeach()
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-16 23:24:16 +00:00
|
|
|
# Add linking directories:
|
|
|
|
link_directories(${PROJECT_BINARY_DIR})
|
2022-07-04 22:24:45 +00:00
|
|
|
|
2022-07-16 23:24:16 +00:00
|
|
|
# Load all of our third party directories
|
|
|
|
add_subdirectory(thirdparty)
|
2022-07-04 22:24:45 +00:00
|
|
|
|
2022-07-16 23:24:16 +00:00
|
|
|
# Glob together all headers that need to be precompiled
|
2022-07-04 22:24:45 +00:00
|
|
|
file(
|
2022-07-16 23:24:16 +00:00
|
|
|
GLOB HEADERS_DDATABASE
|
|
|
|
LIST_DIRECTORIES false
|
|
|
|
${PROJECT_SOURCE_DIR}/dDatabase/*.h
|
|
|
|
${PROJECT_SOURCE_DIR}/dDatabase/Tables/*.h
|
|
|
|
${PROJECT_SOURCE_DIR}/thirdparty/SQLite/*.h
|
2022-07-04 22:24:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
file(
|
2022-07-16 23:24:16 +00:00
|
|
|
GLOB HEADERS_DZONEMANAGER
|
|
|
|
LIST_DIRECTORIES false
|
|
|
|
${PROJECT_SOURCE_DIR}/dZoneManager/*.h
|
2022-07-04 22:24:45 +00:00
|
|
|
)
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
file(
|
2022-07-16 23:24:16 +00:00
|
|
|
GLOB HEADERS_DCOMMON
|
|
|
|
LIST_DIRECTORIES false
|
|
|
|
${PROJECT_SOURCE_DIR}/dCommon/*.h
|
2021-12-05 17:54:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
file(
|
2022-07-16 23:24:16 +00:00
|
|
|
GLOB HEADERS_DGAME
|
|
|
|
LIST_DIRECTORIES false
|
2022-08-02 05:30:19 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/dGame/Entity.h
|
2022-07-16 23:24:16 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/dGame/dGameMessages/GameMessages.h
|
|
|
|
${PROJECT_SOURCE_DIR}/dGame/EntityManager.h
|
|
|
|
${PROJECT_SOURCE_DIR}/dScripts/CppScripts.h
|
|
|
|
)
|
|
|
|
|
|
|
|
# Add our library subdirectories for creation of the library object
|
|
|
|
add_subdirectory(dCommon)
|
|
|
|
add_subdirectory(dDatabase)
|
|
|
|
add_subdirectory(dChatFilter)
|
|
|
|
add_subdirectory(dNet)
|
|
|
|
add_subdirectory(dScripts) # Add for dGame to use
|
|
|
|
add_subdirectory(dGame)
|
|
|
|
add_subdirectory(dZoneManager)
|
2022-08-02 05:30:19 +00:00
|
|
|
add_subdirectory(dNavigation)
|
2022-07-16 23:24:16 +00:00
|
|
|
add_subdirectory(dPhysics)
|
|
|
|
|
|
|
|
# Create a list of common libraries shared between all binaries
|
|
|
|
set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "mariadbConnCpp")
|
|
|
|
|
|
|
|
# Add platform specific common libraries
|
|
|
|
if (UNIX)
|
|
|
|
set(COMMON_LIBRARIES ${COMMON_LIBRARIES} "dl" "pthread")
|
|
|
|
|
|
|
|
if (NOT APPLE AND __include_backtrace__)
|
|
|
|
set(COMMON_LIBRARIES ${COMMON_LIBRARIES} "backtrace")
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-16 23:24:16 +00:00
|
|
|
add_subdirectory(tests)
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-16 23:24:16 +00:00
|
|
|
# Include all of our binary directories
|
|
|
|
add_subdirectory(dWorldServer)
|
|
|
|
add_subdirectory(dAuthServer)
|
|
|
|
add_subdirectory(dChatServer)
|
|
|
|
add_subdirectory(dMasterServer) # Add MasterServer last so it can rely on the other binaries
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-16 23:24:16 +00:00
|
|
|
# Add our precompiled headers
|
2022-07-04 22:24:45 +00:00
|
|
|
target_precompile_headers(
|
2022-08-02 05:30:19 +00:00
|
|
|
dGame PRIVATE
|
2022-07-16 23:24:16 +00:00
|
|
|
${HEADERS_DGAME}
|
2022-07-04 22:24:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
target_precompile_headers(
|
2022-08-02 05:30:19 +00:00
|
|
|
dZoneManager PRIVATE
|
2022-07-16 23:24:16 +00:00
|
|
|
${HEADERS_DZONEMANAGER}
|
2022-07-04 22:24:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Need to specify to use the CXX compiler language here or else we get errors including <string>.
|
|
|
|
target_precompile_headers(
|
2022-08-02 05:30:19 +00:00
|
|
|
dDatabase PRIVATE
|
2022-07-16 23:24:16 +00:00
|
|
|
"$<$<COMPILE_LANGUAGE:CXX>:${HEADERS_DDATABASE}>"
|
2022-07-04 22:24:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
target_precompile_headers(
|
2022-07-16 23:24:16 +00:00
|
|
|
dCommon PRIVATE
|
|
|
|
${HEADERS_DCOMMON}
|
2022-07-04 22:24:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
target_precompile_headers(
|
2022-07-16 23:24:16 +00:00
|
|
|
tinyxml2 PRIVATE
|
|
|
|
"$<$<COMPILE_LANGUAGE:CXX>:${PROJECT_SOURCE_DIR}/thirdparty/tinyxml2/tinyxml2.h>"
|
2022-08-02 05:30:19 +00:00
|
|
|
)
|