-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
56 lines (46 loc) · 1.63 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
cmake_minimum_required(VERSION 3.15)
project(MartisOpibus LANGUAGES CXX)
# Set options
option(MARTISOPIBUS_STATIC_LIBS "Use static libraries?" OFF)
option(MARTISOPIBUS_STATIC_STD_LIBS "Use statically linked standard/runtime libraries? This option must match the one used for SFML." OFF)
# Martis Opibus uses C++17 features
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Request static SFML libraries when building statically
if(MARTISOPIBUS_STATIC_LIBS)
set(SFML_STATIC_LIBRARIES true)
endif()
# Find SFML
find_package(SFML 2.5 COMPONENTS graphics REQUIRED)
# Tell CMake to build a executable
add_executable(MartisOpibus
src/main.cpp
src/Game.hpp
src/Game.cpp
src/Grid.hpp
src/Grid.cpp
src/Unit.hpp
src/Unit.cpp
src/MathUtil.hpp
)
# Make sure that the runtime library gets linked statically
if(MARTISOPIBUS_STATIC_STD_LIBS)
if(NOT SFML_STATIC_LIBRARIES)
message("\n-> If you check MARTISOPIBUS_STATIC_STD_LIBS, you also need to check SFML_STATIC_LIBRARIES.")
message("-> It would lead to multiple runtime environments which results in undefined behavior.\n")
elseif(WIN32 AND MSVC)
set_property(TARGET MartisOpibus PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
elseif(CMAKE_COMPILER_IS_GNUCXX)
# Note: Doesn't work for TDM compiler, since it's compiling the runtime libs statically by default
target_compile_options(MartisOpibus PRIVATE -static)
endif()
endif()
# Link SFML
target_link_libraries(MartisOpibus sfml-graphics)
# Install executable
install(TARGETS MartisOpibus
RUNTIME DESTINATION .)
# Install game data
install(DIRECTORY assets
DESTINATION .)