2018-06-12 09:24:43 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# CMakeLists.txt
|
|
|
|
#------------------------------------------------------------------------------
|
2018-06-14 02:49:56 +02:00
|
|
|
cmake_minimum_required(VERSION 3.1)
|
2015-02-15 17:36:03 +01:00
|
|
|
|
2019-01-09 19:32:28 +01:00
|
|
|
project(openminer)
|
2015-02-15 17:36:03 +01:00
|
|
|
|
2018-06-12 09:24:43 +02:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
2015-02-15 17:36:03 +01:00
|
|
|
|
2020-01-22 14:18:31 +09:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdl2")
|
|
|
|
|
2020-01-22 19:45:50 +09:00
|
|
|
if (WIN32)
|
|
|
|
set(WIN_LIBRARIES_PATH "C:/Libraries")
|
2020-01-22 14:18:31 +09:00
|
|
|
endif ()
|
2015-02-15 17:36:03 +01:00
|
|
|
|
2020-04-30 00:18:35 +02:00
|
|
|
if (APPLE)
|
|
|
|
add_definitions(-DGL_SILENCE_DEPRECATION=1)
|
|
|
|
endif ()
|
|
|
|
|
2020-03-17 20:35:21 +01:00
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
|
|
|
|
2020-04-13 15:01:10 +02:00
|
|
|
include_directories(external)
|
|
|
|
|
2020-02-14 18:36:45 +09:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Compiler flags
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
set(DEBUG_GCC_FLAGS -g -Og -Wall -Wextra -Wfatal-errors -Wno-variadic-macros)
|
2020-03-02 21:09:16 +01:00
|
|
|
set(RELEASE_GCC_FLAGS -O3)
|
|
|
|
set(RELWITHDEB_GCC_FLAGS -g -O3 -Wall -Wextra -Wfatal-errors -Wno-variadic-macros)
|
2020-02-14 18:36:45 +09:00
|
|
|
|
2020-04-12 14:38:26 +02:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2020-02-14 18:36:45 +09:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Setting default build type
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
set(DEFAULT_BUILD_TYPE RelWithDebInfo)
|
|
|
|
|
|
|
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
|
|
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
|
|
|
|
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
|
|
|
|
|
|
|
|
# Set the possible values of build type for cmake-gui
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
|
|
|
endif()
|
|
|
|
|
2018-06-12 09:24:43 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Packages
|
2018-07-06 11:58:34 +02:00
|
|
|
#------------------------------------------------------------------------------
|
2018-12-19 22:36:20 +01:00
|
|
|
# - Lua
|
2018-07-06 11:58:34 +02:00
|
|
|
#------------------------------------------------------------------------------
|
2020-01-22 19:45:50 +09:00
|
|
|
if (WIN32)
|
|
|
|
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WIN_LIBRARIES_PATH}/lua)
|
2020-01-22 14:18:31 +09:00
|
|
|
endif ()
|
|
|
|
|
2018-12-19 22:36:20 +01:00
|
|
|
find_package(Lua REQUIRED)
|
2020-01-22 14:18:31 +09:00
|
|
|
|
2018-12-19 22:36:20 +01:00
|
|
|
if(NOT LUA_FOUND)
|
|
|
|
message(FATAL_ERROR "Lua is needed to build the project. Please install it correctly.")
|
2018-07-06 11:58:34 +02:00
|
|
|
endif()
|
|
|
|
|
2019-02-26 15:55:31 +01:00
|
|
|
include_directories(${LUA_INCLUDE_DIR})
|
2018-12-19 22:36:20 +01:00
|
|
|
link_directories(${LUA_LIBRARY_DIRS})
|
2018-07-06 11:58:34 +02:00
|
|
|
|
2018-06-12 09:24:43 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - tinyxml2
|
|
|
|
#------------------------------------------------------------------------------
|
2020-01-22 19:45:50 +09:00
|
|
|
if (WIN32)
|
|
|
|
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WIN_LIBRARIES_PATH}/tinyxml2)
|
2020-01-22 14:18:31 +09:00
|
|
|
endif ()
|
|
|
|
|
2018-06-12 09:24:43 +02:00
|
|
|
find_package(TinyXml2 REQUIRED)
|
2020-01-22 14:18:31 +09:00
|
|
|
|
2018-06-12 09:24:43 +02:00
|
|
|
if(NOT TINYXML2_FOUND)
|
|
|
|
message(FATAL_ERROR "tinyxml2 is needed to build the project. Please install it correctly.")
|
|
|
|
endif()
|
|
|
|
|
2020-01-22 14:18:31 +09:00
|
|
|
include_directories(${TINYXML2_INCLUDE_DIRS})
|
2018-06-12 09:24:43 +02:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - OpenGL
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
set(OpenGL_GL_PREFERENCE "LEGACY")
|
2015-02-15 17:36:03 +01:00
|
|
|
|
2020-01-22 19:45:50 +09:00
|
|
|
if (WIN32)
|
|
|
|
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WIN_LIBRARIES_PATH}/glm)
|
2020-01-22 14:18:31 +09:00
|
|
|
endif ()
|
|
|
|
|
2015-02-15 17:36:03 +01:00
|
|
|
find_package(OpenGL REQUIRED)
|
2018-06-12 09:24:43 +02:00
|
|
|
find_package(GLM REQUIRED)
|
2015-02-15 17:36:03 +01:00
|
|
|
|
|
|
|
if(NOT OPENGL_FOUND)
|
2018-06-12 09:24:43 +02:00
|
|
|
message(FATAL_ERROR "OpenGL not found!")
|
2015-02-15 17:36:03 +01:00
|
|
|
endif(NOT OPENGL_FOUND)
|
|
|
|
|
2018-06-12 09:24:43 +02:00
|
|
|
if(NOT GLM_FOUND)
|
|
|
|
message(FATAL_ERROR "glm not found!")
|
|
|
|
endif(NOT GLM_FOUND)
|
|
|
|
|
|
|
|
include_directories(${GLM_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
2018-12-28 06:19:40 +01:00
|
|
|
# - SDL2, SDL2_image, SDL2_mixer
|
2018-06-12 09:24:43 +02:00
|
|
|
#------------------------------------------------------------------------------
|
2020-01-24 15:16:54 +09:00
|
|
|
if (MSVC)
|
2020-01-22 19:45:50 +09:00
|
|
|
set(SDL2_PATH ${WIN_LIBRARIES_PATH}/SDL2 CACHE BOOL "" FORCE)
|
|
|
|
set(SDL2_IMAGE_PATH ${WIN_LIBRARIES_PATH}/SDL2_image CACHE BOOL "" FORCE)
|
|
|
|
set(SDL2_MIXER_PATH ${WIN_LIBRARIES_PATH}/SDL2_mixer CACHE BOOL "" FORCE)
|
|
|
|
set(SDL2_TTF_PATH ${WIN_LIBRARIES_PATH}/SDL2_ttf CACHE BOOL "" FORCE)
|
2020-01-24 15:16:54 +09:00
|
|
|
elseif (WIN32)
|
|
|
|
set(SDL2_PATH ${WIN_LIBRARIES_PATH}/SDL2/i686-w64-mingw32 CACHE BOOL "" FORCE)
|
|
|
|
set(SDL2_IMAGE_PATH ${WIN_LIBRARIES_PATH}/SDL2_image/i686-w64-mingw32 CACHE BOOL "" FORCE)
|
|
|
|
set(SDL2_MIXER_PATH ${WIN_LIBRARIES_PATH}/SDL2_mixer/i686-w64-mingw32 CACHE BOOL "" FORCE)
|
|
|
|
set(SDL2_TTF_PATH ${WIN_LIBRARIES_PATH}/SDL2_ttf/i686-w64-mingw32 CACHE BOOL "" FORCE)
|
2020-01-22 14:18:31 +09:00
|
|
|
endif ()
|
2018-12-28 06:19:40 +01:00
|
|
|
|
2020-01-22 14:18:31 +09:00
|
|
|
find_package(SDL2 REQUIRED)
|
|
|
|
find_package(SDL2_image REQUIRED)
|
|
|
|
find_package(SDL2_mixer REQUIRED)
|
|
|
|
find_package(SDL2_ttf REQUIRED)
|
2018-12-28 06:19:40 +01:00
|
|
|
|
|
|
|
if(NOT SDL2_FOUND)
|
|
|
|
message(FATAL_ERROR "SDL2 not found!")
|
|
|
|
endif(NOT SDL2_FOUND)
|
|
|
|
|
2020-01-22 14:18:31 +09:00
|
|
|
if(NOT SDL2_IMAGE_FOUND)
|
2018-12-28 06:19:40 +01:00
|
|
|
message(FATAL_ERROR "SDL2_image not found!")
|
2020-01-22 14:18:31 +09:00
|
|
|
endif(NOT SDL2_IMAGE_FOUND)
|
2015-02-15 17:36:03 +01:00
|
|
|
|
2020-01-22 14:18:31 +09:00
|
|
|
if(NOT SDL2_MIXER_FOUND)
|
2018-12-28 06:19:40 +01:00
|
|
|
message(FATAL_ERROR "SDL2_mixer not found!")
|
2020-01-22 14:18:31 +09:00
|
|
|
endif(NOT SDL2_MIXER_FOUND)
|
2015-02-15 17:36:03 +01:00
|
|
|
|
2020-01-22 14:18:31 +09:00
|
|
|
if(NOT SDL2_TTF_FOUND)
|
2018-12-30 23:47:51 +01:00
|
|
|
message(FATAL_ERROR "SDL2_ttf not found!")
|
2020-01-22 14:18:31 +09:00
|
|
|
endif(NOT SDL2_TTF_FOUND)
|
2018-12-30 23:47:51 +01:00
|
|
|
|
2018-12-28 06:19:40 +01:00
|
|
|
include_directories(${SDL2_INCLUDE_DIRS}
|
2020-01-22 14:18:31 +09:00
|
|
|
${SDL2_IMAGE_INCLUDE_DIRS}
|
|
|
|
${SDL2_MIXER_INCLUDE_DIRS}
|
|
|
|
${SDL2_TTF_INCLUDE_DIRS})
|
2018-12-30 23:47:51 +01:00
|
|
|
|
2020-01-22 14:18:31 +09:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - GLEW
|
|
|
|
#------------------------------------------------------------------------------
|
2020-01-22 19:45:50 +09:00
|
|
|
if (WIN32)
|
|
|
|
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WIN_LIBRARIES_PATH}/glew)
|
2020-01-22 14:18:31 +09:00
|
|
|
|
|
|
|
find_package(GLEW REQUIRED)
|
|
|
|
|
|
|
|
if(NOT GLEW_FOUND)
|
|
|
|
message(FATAL_ERROR "GLEW not found!")
|
|
|
|
endif(NOT GLEW_FOUND)
|
|
|
|
|
|
|
|
include_directories(${GLEW_INCLUDE_DIRS})
|
|
|
|
endif ()
|
|
|
|
|
2018-06-12 09:24:43 +02:00
|
|
|
#------------------------------------------------------------------------------
|
2020-04-13 15:01:10 +02:00
|
|
|
# Submodules
|
|
|
|
# from https://cliutils.gitlab.io/modern-cmake/chapters/projects/submodule.html
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
find_package(Git QUIET)
|
|
|
|
|
|
|
|
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
|
|
|
option(GIT_SUBMODULE "Check submodules during build" ON)
|
|
|
|
if(GIT_SUBMODULE)
|
|
|
|
message(STATUS "Submodule update")
|
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
RESULT_VARIABLE GIT_SUBMOD_RESULT)
|
|
|
|
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
|
|
|
|
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/gamekit/CMakeLists.txt")
|
|
|
|
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - EnTT
|
2018-06-12 09:24:43 +02:00
|
|
|
#------------------------------------------------------------------------------
|
2020-04-12 14:38:26 +02:00
|
|
|
add_subdirectory(external/entt)
|
2020-04-13 15:01:10 +02:00
|
|
|
include_directories(external/entt/single_include)
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - gamekit
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
add_subdirectory(external/gamekit)
|
2020-04-29 18:07:48 +02:00
|
|
|
include_directories(external/gamekit/include)
|
2020-04-13 15:01:10 +02:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - SFML network
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
set(SFML_BUILD_AUDIO FALSE)
|
|
|
|
set(SFML_BUILD_GRAPHICS FALSE)
|
|
|
|
set(SFML_BUILD_WINDOW FALSE)
|
2020-04-29 20:50:39 +02:00
|
|
|
set(SFML_STATIC TRUE)
|
2020-04-12 14:38:26 +02:00
|
|
|
|
2020-04-29 20:50:39 +02:00
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
2020-04-13 15:01:10 +02:00
|
|
|
|
|
|
|
add_subdirectory(external/SFML)
|
|
|
|
|
2020-05-10 19:36:39 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - zlib
|
|
|
|
#------------------------------------------------------------------------------
|
2020-05-10 20:28:17 +02:00
|
|
|
add_subdirectory(external/zlib ${CMAKE_CURRENT_BINARY_DIR}/external/zlib)
|
2020-05-10 19:36:39 +02:00
|
|
|
|
2020-05-10 19:50:21 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - sol3 (sol2 v3.x)
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
include_directories(external/sol2/single/include/sol)
|
|
|
|
|
2020-04-13 15:01:10 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Subdirectories
|
|
|
|
#------------------------------------------------------------------------------
|
2020-03-17 20:35:21 +01:00
|
|
|
add_subdirectory(source/common)
|
|
|
|
add_subdirectory(source/server)
|
|
|
|
add_subdirectory(source/client)
|