-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
84 lines (70 loc) · 2.12 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
cmake_minimum_required(VERSION 3.4)
project(skunkwork)
# Get built dynamic libs next to the exe
option(DISTRIBUTE_DEMO "Compile distributable" OFF)
if(DISTRIBUTE_DEMO)
# Set relative paths for shared libraries
set(CMAKE_INSTALL_RPATH $ORIGIN)
# Set relative path to distributable res directory
add_definitions(-DDEMO_MODE -DRES_DIRECTORY="./res/")
# Compile demo as a win32 app to avoid issues with it losing focus because of the opened console window
set(WIN32_DEF WIN32)
else()
# Set absolute path to res directory
add_definitions(-DRES_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}/res/")
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# Set up external dependencies
find_package(OpenGL REQUIRED)
# Set up sub-builds and sources
add_subdirectory(ext)
add_subdirectory(include)
add_subdirectory(src)
# Set up project targets
add_executable(skunkwork ${WIN32_DEF} ${SKUNKWORK_SOURCES})
target_compile_features(skunkwork
PRIVATE
cxx_std_20
)
if(MSVC)
target_compile_options(skunkwork
PRIVATE
# /Wall is very very pedantic
/W4
)
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
else()
target_compile_options(skunkwork
PRIVATE
-Wall
-pedantic
)
endif()
target_compile_definitions(skunkwork PRIVATE SDL_MAIN_HANDLED)
target_include_directories(skunkwork
PRIVATE
${SKUNKWORK_INCLUDE_DIR}
)
target_link_libraries(skunkwork
PRIVATE
${OPENGL_LIBRARIES}
glm
libgl3w
librocket
imgui
SDL2
SDL2_mixer
)
if(DISTRIBUTE_DEMO)
# Prevent SDL build symlinks, we want the raw file for this to be portable
set_property(TARGET SDL2 PROPERTY VERSION)
set_property(TARGET SDL2 PROPERTY SOVERSION)
set_property(TARGET SDL2_mixer PROPERTY VERSION)
set_property(TARGET SDL2_mixer PROPERTY SOVERSION)
install(TARGETS skunkwork SDL2 SDL2_mixer
RUNTIME DESTINATION ${CMAKE_BINARY_DIR}/skunkwork_dist
LIBRARY DESTINATION ${CMAKE_BINARY_DIR}/skunkwork_dist
ARCHIVE DESTINATION ${CMAKE_BINARY_DIR}/skunkwork_dist
)
endif()