Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
107 lines (84 loc) · 2.36 KB
/
Copy pathCMakeLists.txt
File metadata and controls
107 lines (84 loc) · 2.36 KB
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
cmake_minimum_required(VERSION 2.8)
project(OpenglDevTemplate)
###
### Options
###
# Unsed previous parameters from cache for the sake of dynamism
unset(KITGL_SUPPORT_GLFW CACHE)
unset(KITGL_SUPPORT_GLAD CACHE)
unset(KITGL_SUPPORT_GLEW CACHE)
unset(KITGL_SUPPORT_FREEGLUT CACHE)
# Enable desired libs
option(KITGL_SUPPORT_GLFW "Set ON/OFF to enable/disable GLFW support." ON)
option(KITGL_SUPPORT_GLAD "Set ON/OFF to enable/disable GLAD support." ON)
option(KITGL_SUPPORT_GLEW "Set ON/OFF to enable/disable GLEW support." ON)
option(KITGL_SUPPORT_FREEGLUT "Set ON/OFF to enable/disable FreeGLUT support." ON)
###
### Initialization
###
# Project parameters
set(PROJ_LINK_LIBS)
set(PROJ_SRC)
# Add all files/folders under src folder automatically to the project
file(GLOB_RECURSE PROJ_SRC src/*.h src/*.cpp)
###
### Compiler settings
###
add_definitions(
-fPIC
)
###
### GLFW
###
if(KITGL_SUPPORT_GLFW)
# Disable internal builds
unset(GLFW_BUILD_EXAMPLES CACHE)
unset(GLFW_BUILD_TESTS CACHE)
unset(GLFW_BUILD_DOCS CACHE)
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF)
option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF)
option(GLFW_BUILD_DOCS "Build the GLFW documentation" OFF)
add_subdirectory(libs/glfw)
include_directories(libs/glfw/include)
include_directories(libs/glfw/deps)
list(APPEND PROJ_LINK_LIBS glfw)
endif(KITGL_SUPPORT_GLFW)
###
### GLAD
###
if(KITGL_SUPPORT_GLAD)
include_directories(libs/glfw/deps)
list(APPEND PROJ_SRC
libs/glfw/deps/glad_gl.c
)
endif(KITGL_SUPPORT_GLAD)
###
### GLEW
###
if(KITGL_SUPPORT_GLEW)
# Disable internal builds
unset(BUILD_UTILS CACHE)
option(BUILD_UTILS "utilities" OFF)
add_subdirectory(libs/glew/build/cmake)
include_directories(libs/glew/include)
list(APPEND PROJ_LINK_LIBS glew)
endif(KITGL_SUPPORT_GLEW)
###
### FreeGLUT
###
if(KITGL_SUPPORT_FREEGLUT)
# Disable internal builds
unset(FREEGLUT_BUILD_DEMOS CACHE)
option(FREEGLUT_BUILD_DEMOS "Build FreeGLUT demos." OFF)
add_subdirectory(libs/freeglut)
include_directories(libs/freeglut/include)
list(APPEND PROJ_LINK_LIBS freeglut)
endif(KITGL_SUPPORT_FREEGLUT)
###
### Generating the project files
###
add_executable(${PROJECT_NAME} ${PROJ_SRC})
###
### Linking to the project
###
target_link_libraries(${PROJECT_NAME} ${PROJ_LINK_LIBS})