-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
54 lines (40 loc) · 1.67 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
cmake_minimum_required(VERSION 3.16.3)
project(gl VERSION 0.1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED true)
# for clangd
set(CMAKE_EXPORT_COMPILE_COMMANDS true)
### Directory paths ###
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
set(VENDOR_DIR ${CMAKE_SOURCE_DIR}/vendor)
set(DEPS_DIR ${CMAKE_SOURCE_DIR}/deps)
### Dependencies ###
add_subdirectory(${VENDOR_DIR}/glfw ${DEPS_DIR}/glfw)
set(GLFW_BUILD_EXAMPLES false)
set(GLFW_BUILD_TESTS false)
set(GLFW_BUILD_DOCS false)
add_subdirectory(${VENDOR_DIR}/glad ${DEPS_DIR}/glad)
set(GLAD_PROFILE "core")
set(GLAD_GENERATOR "cpp")
add_subdirectory(${VENDOR_DIR}/glm ${DEPS_DIR}/glm)
### Compile flags ###
set(DEBUG_COMPILE_OPTIONS "-g3" "-ggdb" "-DNDEBUG")
set(RELEASE_COMPILE_OPTIONS)
### Application ###
add_executable(${CMAKE_PROJECT_NAME})
include(sources)
if(MSVC)
target_compile_options(${CMAKE_PROJECT_NAME} PUBLIC "/Wall")
else()
# "-save-temps" required for dseight/vscode-disasexpl
# https://stackoverflow.com/questions/34948142/gcc-wall-pedantic-wextra-in-visual-studio
target_compile_options(${CMAKE_PROJECT_NAME} PUBLIC "-save-temps" "-Wall" "-Wextra" "-pedantic-errors")
target_compile_options(${CMAKE_PROJECT_NAME} PUBLIC "$<$<CONFIG:DEBUG>:${DEBUG_COMPILE_OPTIONS}>")
target_compile_options(${CMAKE_PROJECT_NAME} PUBLIC "$<$<CONFIG:RELEASE>:${RELEASE_COMPILE_OPTIONS}>")
endif()
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC glfw glad glm)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
${CMAKE_SOURCE_DIR}/src
${VENDOR_DIR}/glfw/include
${DEPS_DIR}/glad/include)
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_CXX_FLAGS})