-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
133 lines (93 loc) · 3.37 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
cmake_minimum_required(VERSION 3.16)
project(kryne_engine)
set(CMAKE_CXX_STANDARD 17)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake")
if (UNIX)
set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -ldl -lpthread")
endif()
# Set up GLFW3
find_package(GLFW3 REQUIRED)
message(STATUS "Found GLFW3 in ${GLFW3_INCLUDE_DIR}")
include_directories(${GLFW3_INCLUDE_DIR})
# Set up GLM
find_package(GLM REQUIRED)
message(STATUS "Found GLM in ${GLM_INCLUDE_DIR}")
include_directories(${GLM_INCLUDE_DIR})
# Set up assimp
find_package(ASSIMP REQUIRED)
message(STATUS "Found assimp in ${ASSIMP_INCLUDE_DIR}")
include_directories(${ASSIMP_INCLUDE_DIR})
# Set up GLAD library
include_directories(external-libs/glad/include)
add_library(glad STATIC external-libs/glad/src/glad.c)
# Set up stb_image library
include_directories(external-libs/stb_image)
add_library(stb_image STATIC external-libs/stb_image/stb_image.cpp)
# Set up Dear IMGUI lib
add_subdirectory(external-libs/imgui)
include_directories(external-libs/imgui)
#Set up the used libs
set(LIBS stb_image glad ${GLFW3_LIBRARY} ${ASSIMP_LIBRARIES} DearIMGUI)
# Set up boost library
if(WIN32)
# Required, or else CMake won't find boost components
set (Boost_USE_STATIC_LIBS 1)
endif()
find_package(Boost REQUIRED COMPONENTS filesystem system)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR})
message(STATUS "Boost include dirs: ${Boost_INCLUDE_DIRS}")
set(LIBS ${LIBS} ${Boost_LIBRARIES})
## Helper functions
# Links a directory to a symbolic link in the target binary directory
function(copyAssetDir TARGET ASSET)
if(${UNIX})
set(SYMLINK_COMMAND ln -s ${CMAKE_SOURCE_DIR}/${ASSET}/ ${CMAKE_CURRENT_BINARY_DIR}/${ASSET})
elseif(${WIN32})
set(SYMLINK_COMMAND mklink /d ${CMAKE_CURRENT_BINARY_DIR}/${ASSET} ${CMAKE_SOURCE_DIR}/${ASSET}/ & exit 0)
endif()
add_custom_command(
TARGET ${TARGET} POST_BUILD
COMMAND ${SYMLINK_COMMAND})
endfunction()
# Links the assets for a provided target
function(copyAssets TARGET)
copyAssetDir(${TARGET} "Resources")
endfunction()
# Duplicate a library
function(duplicateLibrary LIBRARY NEW_LIB_NAME)
get_target_property(sourceFiles ${LIBRARY} SOURCES)
get_target_property(linkLibs ${LIBRARY} LINK_LIBRARIES)
get_target_property(includeDirs ${LIBRARY} INCLUDE_DIRECTORIES)
get_target_property(compileDefinitions ${LIBRARY} COMPILE_DEFINITIONS)
get_target_property(compileOptions ${LIBRARY} COMPILE_OPTIONS)
add_library(${NEW_LIB_NAME} STATIC
${sourceFiles}
)
target_include_directories(${NEW_LIB_NAME} PUBLIC
${includeDirs}
)
list(REMOVE_ITEM linkLibs
originalLibrary
)
target_link_libraries(${NEW_LIB_NAME} PRIVATE
${linkLibs}
)
if (compileOptions)
target_compile_options(${NEW_LIB_NAME} PRIVATE
${compileOptions}
)
endif()
if (compileDefinitions)
target_compile_definitions(${NEW_LIB_NAME} PRIVATE
${compileDefinitions}
)
endif()
endfunction()
# Set up Kryne Engine library
add_subdirectory(kryne-engine)
# Setting up executables
add_subdirectory(Examples/SunLight)
add_subdirectory(Examples/Sphere)
add_subdirectory(Examples/Basic)
add_subdirectory(Examples/BenchmarkThreading)