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
|
|
|
|
2018-12-20 00:00:01 +01:00
|
|
|
project(OpenMiner VERSION 0.0.1 LANGUAGES CXX)
|
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
|
|
|
|
2018-06-12 09:24:43 +02:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
2015-02-15 17:36:03 +01:00
|
|
|
|
2018-06-12 09:24:43 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Get source files
|
|
|
|
#------------------------------------------------------------------------------
|
2018-12-19 22:36:20 +01:00
|
|
|
file(GLOB_RECURSE SOURCE_FILES source/*.cpp external/*.cpp)
|
|
|
|
file(GLOB_RECURSE HEADER_FILES include/*.hpp external/*.hpp)
|
2018-06-12 09:24:43 +02:00
|
|
|
|
|
|
|
foreach(HEADER_FILE ${HEADER_FILES})
|
|
|
|
get_filename_component(HEADER_DIRECTORY ${HEADER_FILE} DIRECTORY)
|
|
|
|
include_directories(${HEADER_DIRECTORY})
|
|
|
|
endforeach(HEADER_FILE)
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
2018-06-14 02:49:56 +02:00
|
|
|
# Create executable target
|
2018-06-12 09:24:43 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
add_executable(${CMAKE_PROJECT_NAME} ${SOURCE_FILES})
|
|
|
|
|
2018-06-14 02:49:56 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Compiler flags
|
|
|
|
#------------------------------------------------------------------------------
|
2018-06-19 05:38:14 +02:00
|
|
|
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -O3 -ffast-math -g -Wall -Wextra -Wfatal-errors -Wno-variadic-macros)
|
|
|
|
# target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -g -Wall -Wextra -Wfatal-errors -Wno-variadic-macros)
|
2018-06-14 02:49:56 +02:00
|
|
|
target_compile_features(${CMAKE_PROJECT_NAME} PRIVATE cxx_std_17)
|
|
|
|
|
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
|
|
|
#------------------------------------------------------------------------------
|
2018-12-19 22:36:20 +01:00
|
|
|
find_package(Lua REQUIRED)
|
|
|
|
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()
|
|
|
|
|
2018-12-19 22:36:20 +01:00
|
|
|
include_directories(${LUA_INCLUDE_DIRS})
|
|
|
|
link_directories(${LUA_LIBRARY_DIRS})
|
2018-07-06 11:58:34 +02:00
|
|
|
|
2018-06-12 09:24:43 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - tinyxml2
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
find_package(TinyXml2 REQUIRED)
|
|
|
|
if(NOT TINYXML2_FOUND)
|
|
|
|
message(FATAL_ERROR "tinyxml2 is needed to build the project. Please install it correctly.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include_directories(${TINYXML2_INCLUDE_DIRS})
|
|
|
|
link_directories(${TINYXML2_LIBRARY_DIRS})
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# - OpenGL
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
set(OpenGL_GL_PREFERENCE "LEGACY")
|
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-26 19:04:36 +01:00
|
|
|
# - SFML
|
2018-06-12 09:24:43 +02:00
|
|
|
#------------------------------------------------------------------------------
|
2018-12-26 19:04:36 +01:00
|
|
|
find_package(SFML COMPONENTS audio graphics network system window REQUIRED)
|
|
|
|
if(NOT SFML_FOUND)
|
|
|
|
message(FATAL_ERROR "SFML is needed to build the project. Please install it correctly.")
|
|
|
|
endif()
|
2015-02-15 17:36:03 +01:00
|
|
|
|
2018-12-26 19:04:36 +01:00
|
|
|
include_directories(${SFML_INCLUDE_DIRS})
|
2015-02-15 17:36:03 +01:00
|
|
|
|
2018-06-12 09:24:43 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# Link options
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
target_link_libraries(${CMAKE_PROJECT_NAME}
|
2018-06-21 05:45:17 +02:00
|
|
|
${TINYXML2_LIBRARIES}
|
2018-12-19 22:36:20 +01:00
|
|
|
${LUA_LIBRARIES}
|
2018-06-12 09:24:43 +02:00
|
|
|
${OPENGL_LIBRARIES}
|
2018-12-26 19:04:36 +01:00
|
|
|
sfml-audio
|
|
|
|
sfml-graphics
|
|
|
|
sfml-network
|
|
|
|
sfml-system
|
|
|
|
sfml-window)
|
2015-02-15 17:36:03 +01:00
|
|
|
|