-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
186 lines (132 loc) · 4.24 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# CMake entry point
cmake_minimum_required (VERSION 3.0)
project (OpenGL)
find_package(OpenGL REQUIRED)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if( CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR )
message( FATAL_ERROR "Please select another Build Directory ! (and give it a clever name, like bin_Visual2012_64bits/)" )
endif()
if( CMAKE_SOURCE_DIR MATCHES " " )
message( "Your Source Directory contains spaces. If you experience problems when compiling, this can be the cause." )
endif()
if( CMAKE_BINARY_DIR MATCHES " " )
message( "Your Build Directory contains spaces. If you experience problems when compiling, this can be the cause." )
endif()
# Compile external dependencies
add_subdirectory (deps)
if(INCLUDE_DISTRIB)
add_subdirectory(distrib)
endif(INCLUDE_DISTRIB)
include_directories(
deps/glfw-3.1.2/include/
deps/glm-0.9.7.1/
deps/glew-1.13.0/include/
deps/stb/include/
.
)
set(ALL_LIBS
${OPENGL_LIBRARY}
glfw
GLEW_1130
)
add_definitions(
-DTW_STATIC
-DTW_NO_LIB_PRAGMA
-DTW_NO_DIRECT3D
-DGLEW_STATIC
-D_CRT_SECURE_NO_WARNINGS
)
SOURCE_GROUP(src REGULAR_EXPRESSION ".*/src/.*" )
SOURCE_GROUP(shaders REGULAR_EXPRESSION ".*/.*shader$" )
###################################################################################
add_executable(triangle
src/01-triangle/main.cpp
src/utils/shader.cpp
src/utils/shader.hpp
src/01-triangle/res/fragment.shader
src/01-triangle/res/vertex.shader
)
target_link_libraries(triangle
${ALL_LIBS}
)
add_custom_command(
TARGET triangle POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/bin/triangle${CMAKE_EXECUTABLE_SUFFIX}" "${CMAKE_CURRENT_SOURCE_DIR}/src/01-triangle/"
)
###################################################################################
add_executable(texture
src/02-texture/main.cpp
src/utils/shader.cpp
src/utils/shader.hpp
src/utils/texture_loader.cpp
src/utils/texture_loader.hpp
src/02-texture/res/fragment.shader
src/02-texture/res/vertex.shader
)
target_link_libraries(texture
${ALL_LIBS}
)
add_custom_command(
TARGET texture POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/bin/texture${CMAKE_EXECUTABLE_SUFFIX}" "${CMAKE_CURRENT_SOURCE_DIR}/src/02-texture/"
)
###################################################################################
add_executable(multi-texture
src/03-multi-texture/main.cpp
src/utils/shader.cpp
src/utils/shader.hpp
src/utils/texture_loader.cpp
src/utils/texture_loader.hpp
src/03-multi-texture/res/fragment.shader
src/03-multi-texture/res/vertex.shader
)
target_link_libraries(multi-texture
${ALL_LIBS}
)
add_custom_command(
TARGET multi-texture POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/bin/multi-texture${CMAKE_EXECUTABLE_SUFFIX}" "${CMAKE_CURRENT_SOURCE_DIR}/src/03-multi-texture/"
)
###################################################################################
add_executable(controls
src/04-controls/main.cpp
src/utils/shader.cpp
src/utils/shader.hpp
src/utils/texture_loader.cpp
src/utils/texture_loader.hpp
src/utils/controls.cpp
src/utils/controls.hpp
src/04-controls/res/fragment.shader
src/04-controls/res/vertex.shader
)
target_link_libraries(controls
${ALL_LIBS}
)
add_custom_command(
TARGET controls POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/bin/controls${CMAKE_EXECUTABLE_SUFFIX}" "${CMAKE_CURRENT_SOURCE_DIR}/src/04-controls/"
)
###################################################################################
add_executable(3d-model
src/05-3d-model/main.cpp
src/utils/shader.cpp
src/utils/shader.hpp
src/utils/3Dcontrols.cpp
src/utils/3Dcontrols.cpp
src/utils/obj_loader.cpp
src/utils/obj_loader.hpp
src/utils/dds_loader.cpp
src/utils/dds_loader.hpp
src/05-3d-model/res/fragment.shader
src/05-3d-model/res/vertex.shader
)
target_link_libraries(3d-model
${ALL_LIBS}
)
add_custom_command(
TARGET 3d-model POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/bin/3d-model${CMAKE_EXECUTABLE_SUFFIX}" "${CMAKE_CURRENT_SOURCE_DIR}/src/05-3d-model/"
)
###################################################################################