-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
93 lines (74 loc) · 1.85 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
cmake_minimum_required(VERSION 3.10)
project(graphics)
set(CMAKE_CXX_STANDARD 17)
# OPTIONS
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
option(BACKEND_METAL "Build the Metal backend" ON)
option(BACKEND_OPENGL "Build the OpenGL backend" OFF)
option(BUILD_EXAMPLES "Build the example projects" ON)
# TARGET
add_library(graphics STATIC)
target_include_directories(graphics
PUBLIC
include
PRIVATE
src
)
# BACKENDS
if(BACKEND_METAL)
set_target_properties(graphics
PROPERTIES
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
)
target_compile_options(graphics
PUBLIC
"-fobjc-arc"
)
target_compile_definitions(graphics
PUBLIC
GRAPHICS_USE_METAL=1
)
if(NOT APPLE)
target_sources(graphics
PRIVATE
src/graphics/opengl/glad.c
)
endif()
target_sources(graphics
PRIVATE
src/graphics/metal/context.mm
# src/graphics/metal/convert.mm
src/graphics/metal/rendertarget.mm
src/graphics/metal/state.mm
src/graphics/metal/staticbuffer.mm
src/graphics/metal/dynamicbuffer.mm
src/graphics/metal/texture.mm
)
endif()
if(BACKEND_OPENGL)
target_compile_definitions(graphics
PUBLIC
GRAPHICS_USE_OPENGL=1
)
target_sources(graphics
PRIVATE
src/graphics/opengl/context.cpp
# src/graphics/opengl/convert.cpp
src/graphics/opengl/rendertarget.cpp
src/graphics/opengl/state.cpp
src/graphics/opengl/staticbuffer.cpp
src/graphics/opengl/dynamicbuffer.cpp
src/graphics/opengl/texture.cpp
)
endif()
# EXAMPLES
if(BUILD_EXAMPLES)
if(BACKEND_METAL)
add_subdirectory(examples/hello_metal)
endif()
if(BACKEND_OPENGL AND APPLE)
add_subdirectory(examples/hello_macgl)
endif()
endif()