-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
77 lines (57 loc) · 2.16 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
cmake_minimum_required(VERSION 3.0.2)
project(conspiracy LANGUAGES CXX)
set(CXX_STANDARD 11)
set(CXX_STANDARD_REQUIRED ON)
# Set directory folders
set (PROJECT_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include")
set (PROJECT_SRC_DIR "${PROJECT_SOURCE_DIR}/src")
set (PROJECT_ASSETS_DIR "${PROJECT_SOURCE_DIR}/assets")
set (CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install)
# Gets the list of files inside the src directory
file(GLOB_RECURSE SOURCES "${PROJECT_SRC_DIR}/*.cpp"
"${PROJECT_SRC_DIR}/*.c")
# Include Headers
include_directories("${PROJECT_INCLUDE_DIR}")
#### Compilation ####
# Compilation Flags
set(COMPILE_FLAGS "")
if (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
set(COMPILE_FLAGS "${COMPILE_FLAGS} -std=c++11 -W -Wall -fstack-protector-all -pedantic -Wshadow -O2 -g")
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
set(COMPILE_FLAGS "${COMPILE_FLAGS} -std=c++11 -W -Wall -fstack-protector-all -pedantic -Wshadow -O2 -g")
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
set(COMPILE_FLAGS "${COMPILE_FLAGS} /Wall /W4")
endif()
# Cmake compilation flags redefinition
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILE_FLAGS}")
#### Dependencies ####
# Add engine
set (PROJECT_ENGINE_DIR "${PROJECT_SOURCE_DIR}/engine")
add_subdirectory(${PROJECT_ENGINE_DIR})
include_directories(${ENGINE_INCLUDE_DIR})
# Add game
set (PROJECT_GAME_DIR "${PROJECT_SOURCE_DIR}/game")
add_subdirectory(${PROJECT_GAME_DIR})
include_directories(${GAME_INCLUDE_DIR})
#### Executable ####
add_executable(conspiracy ${SOURCES})
target_link_libraries(conspiracy
engine
game
SDL2 SDL2_image SDL2_ttf SDL2_mixer)
#### Custom Commands ####
# Copy assets folder to build
add_custom_command(TARGET conspiracy POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${PROJECT_ASSETS_DIR} ${CMAKE_BINARY_DIR}/assets)
#### Install/Packaging ####
install(TARGETS conspiracy
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
install(DIRECTORY ${PROJECT_ASSETS_DIR}
DESTINATION bin/
)
#TODO: Add SDL2 libraries to the install phase
include(CPack.cmake)