-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathCMakeLists.txt
60 lines (50 loc) · 1.72 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
57
58
59
60
cmake_minimum_required(VERSION 3.15)
project(SmallGameEngine LANGUAGES CXX)
# Set options
option(SMALLGAMEENGINE_STATIC_STD_LIBS "Use statically linked standard/runtime libraries? This option must match the one used for SFML." OFF)
# SmallGameEngine 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(NOT BUILD_SHARED_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(SmallGameEngine
src/main.cpp
src/Application.hpp
src/Application.cpp
src/State.hpp
src/State.cpp
src/StateMachine.hpp
src/StateMachine.cpp
src/IntroState.hpp
src/IntroState.cpp
src/MenuState.hpp
src/MenuState.cpp
src/PlayState.hpp
src/PlayState.cpp
)
# Make sure that the runtime library gets linked statically
if(SMALLGAMEENGINE_STATIC_STD_LIBS)
if(NOT SFML_STATIC_LIBRARIES)
message("\n-> If you check SMALLGAMEENGINE_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 SmallGameEngine 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(SmallGameEngine PRIVATE -static)
endif()
endif()
# Link SFML
target_link_libraries(SmallGameEngine sfml-graphics)
# Install executable
install(TARGETS SmallGameEngine
RUNTIME DESTINATION .)
# Install game data
install(DIRECTORY bin/img
DESTINATION .)