-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
59 lines (44 loc) · 1.83 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.10)
set(PROJECT_VERSION "1.0.0")
project(engine VERSION ${PROJECT_VERSION} DESCRIPTION "game engine")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
find_package(SDL2 2.0.8 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ext/glad)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ext/glm)
file(GLOB_RECURSE SRC
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.h"
)
file(GLOB_RECURSE SRC_SHADERS
"${CMAKE_CURRENT_SOURCE_DIR}/media/shaders/*.glsl"
)
file(GLOB_RECURSE SRC_EXTERNALS
"${CMAKE_CURRENT_SOURCE_DIR}/ext/glad/*.c"
)
add_library(${PROJECT_NAME} SHARED
${SRC}
${SRC_SHADERS}
${SRC_EXTERNALS})
source_group("Sources" FILES ${SRC})
source_group("Shaders" FILES ${SRC_SHADERS})
source_group("Externals" FILES ${SRC_EXTERNALS})
# This will name engine output .so files "libsomething.1.0.0" which is pretty useful
set_target_properties(${PROJECT_NAME}
PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION})
target_link_libraries(${PROJECT_NAME} PRIVATE ${SDL2_LIBRARY})
target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMENT "Copy engine resources and dependencies"
COMMAND cmake -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/media
${CMAKE_BINARY_DIR}/media)