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-05-11 17:30:54 +02:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
2020-01-22 14:18:31 +09: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
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - OpenGL
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
set(OpenGL_GL_PREFERENCE "LEGACY")
|
2015-02-15 17:36:03 +01:00
|
|
|
|
|
|
|
find_package(OpenGL REQUIRED)
|
|
|
|
|
|
|
|
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
|
|
|
#------------------------------------------------------------------------------
|
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")
|
2020-06-02 06:39:37 +02:00
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} submodule sync --recursive WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
2020-04-13 15:01:10 +02:00
|
|
|
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()
|
|
|
|
|
2020-05-23 03:57:30 +02:00
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
|
|
|
|
2020-04-13 15:01:10 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - EnTT
|
2018-06-12 09:24:43 +02:00
|
|
|
#------------------------------------------------------------------------------
|
2020-04-12 14:38:26 +02:00
|
|
|
add_subdirectory(external/entt)
|
2020-05-23 03:57:30 +02:00
|
|
|
include_directories(external/entt/src)
|
2020-04-13 15:01:10 +02:00
|
|
|
|
2020-07-07 19:33:01 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - SFML
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
set(SFML_STATIC TRUE)
|
|
|
|
|
|
|
|
set(SFML_BUILD_AUDIO FALSE CACHE BOOL "")
|
|
|
|
set(SFML_BUILD_GRAPHICS FALSE CACHE BOOL "")
|
|
|
|
set(SFML_BUILD_NETWORK TRUE CACHE BOOL "")
|
|
|
|
set(SFML_BUILD_WINDOW FALSE CACHE BOOL "")
|
|
|
|
|
|
|
|
add_subdirectory(external/SFML)
|
|
|
|
|
2020-04-13 15:01:10 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - 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
|
|
|
|
2020-05-10 19:36:39 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - zlib
|
|
|
|
#------------------------------------------------------------------------------
|
2020-05-31 22:37:36 +02:00
|
|
|
set(ZLIB_STATIC ON)
|
|
|
|
|
2020-05-10 20:28:17 +02:00
|
|
|
add_subdirectory(external/zlib ${CMAKE_CURRENT_BINARY_DIR}/external/zlib)
|
2020-05-28 14:27:24 +02:00
|
|
|
include_directories(external/zlib ${CMAKE_CURRENT_BINARY_DIR}/external/zlib)
|
2020-05-10 19:36:39 +02:00
|
|
|
|
2020-05-22 16:18:34 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - lua
|
|
|
|
#------------------------------------------------------------------------------
|
2020-05-31 23:02:29 +02:00
|
|
|
set(LUA_BUILD_LUA_LUAC OFF CACHE BOOL "")
|
2020-05-23 03:57:30 +02:00
|
|
|
set(LUA_BUILD_WLUA OFF CACHE BOOL "")
|
2020-05-31 23:02:29 +02:00
|
|
|
set(LUA_USE_READLINE OFF CACHE BOOL "")
|
2020-05-23 03:57:30 +02:00
|
|
|
|
2020-05-22 16:18:34 +02:00
|
|
|
add_subdirectory(external/lua)
|
2020-05-23 03:57:30 +02:00
|
|
|
include_directories(external/lua/src ${CMAKE_CURRENT_BINARY_DIR}/external/lua)
|
2020-05-22 16:18:34 +02:00
|
|
|
|
2020-05-10 19:50:21 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - sol3 (sol2 v3.x)
|
|
|
|
#------------------------------------------------------------------------------
|
2020-05-22 19:39:40 +02:00
|
|
|
set(LUA_LOCAL_DIR external/lua)
|
|
|
|
|
|
|
|
add_subdirectory(external/sol2)
|
2020-05-10 19:50:21 +02:00
|
|
|
|
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)
|