-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
59 lines (38 loc) · 1.57 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
cmake_minimum_required(VERSION 3.0.2)
project(game LANGUAGES CXX)
# 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")
# 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 -pedantic -std=c++11 -Wshadow -O2 -g")
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
set(COMPILE_FLAGS "${COMPILE_FLAGS} -std=c++11 -W -Wall -pedantic -std=c++11 -Wshadow -O2 -g")
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
set(COMPILE_FLAGS "${COMPILE_FLAGS} /Wall")
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})
#### Executable ####
add_executable(game ${SOURCES})
target_link_libraries(game
engine
SDL2 SDL2_image SDL2_ttf SDL2_mixer)
#### Custom Commands ####
# Copy assets folder to build
add_custom_command(TARGET game POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${PROJECT_ASSETS_DIR} ${CMAKE_BINARY_DIR}/assets)