-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
74 lines (61 loc) · 2.06 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
cmake_minimum_required( VERSION 3.25 FATAL_ERROR )
project( gfx
C CXX
)
# cmake modules folder
list( APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_LIST_DIR}/cmake_modules"
)
# C++ options
set( CMAKE_CXX_STANDARD 20 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_CXX_EXTENSIONS OFF )
# force to release build if nothing else is defined
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Force to set Release build" FORCE)
endif()
add_compile_definitions(
$<IF:$<CONFIG:DEBUG>,_DEBUG,NDEBUG>
)
# set MSVC warning C4996 to "off"
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
# place all artefacts into one folder
# NOTE: (please don't do this in real projects)
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin" )
# list of supported APIs
if( LINUX OR WIN32 )
set( SUPPORT_VULKAN true )
endif()
if( LINUX OR WIN32 )
set( SUPPORT_OPENGL true )
endif()
if( WIN32 )
set( SUPPORT_DIRECTX true )
endif()
# options
option( GFX_TUTORIALS "All graphical API tutorials" ON )
option( GFX_SAMPLES "All graphical API samples" ON )
if( SUPPORT_OPENGL )
option( OPENGL2_TUTORIAL "OpenGL2 Fixed Functional pipeline tutorial" ON )
option( OPENGL2_SAMPLES "OpenGL2 Fixed Functional pipeline samples" OFF )
option( OPENGL4_TUTORIAL "OpenGL4 Programmable pipeline tutorial" ON )
option( OPENGL2_SAMPLES "OpenGL4 Programmable pipeline samples" OFF )
endif()
# if Vulkan is suppoted by the target system - fetch latest headers first
# this is needed to use non system vulkan headers for all targets on any target system
if( SUPPORT_VULKAN )
include( vulkan_headers )
fetch_vulkan_headers()
endif()
# OpenGL tutorials and samples will use Glad for runtime initialization of OpenGL
# and the same way Vulkan tutorials and samples will use Volk loader
# the main difference is that Glad source files will be stored in the repository
# and Volk will be downloaded from GitHub
add_subdirectory( extensions )
# fetch GLFW from GitHub
include( glfw )
fetch_glfw()
# tutorials
if( GFX_TUTORIALS )
add_subdirectory( tutorials )
endif()