-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
238 lines (179 loc) · 6.55 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
cmake_policy(VERSION 2.8)
if (NOT CMAKE_VERSION VERSION_LESS "3.1")
cmake_policy(SET CMP0054 NEW)
endif()
project(microbench)
enable_testing()
#CMAKE_BUILD_TOOL
if(CMAKE_CURRENT_SOURCE_DIR EQUAL CMAKE_CURRENT_BINARY_DIR)
message(FATAL_ERROR "Source and binary directories must be different")
endif(CMAKE_CURRENT_SOURCE_DIR EQUAL CMAKE_CURRENT_BINARY_DIR)
if(MSVC)
set(BINARY_DIRECTORY build)
endif()
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") AND UNIX))
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
set(CMAKE_CXX_FLAGS "-std=c++11")
endif()
option(OGL_SAMPLES_IN_SOURCE_BUILD "OGL_SAMPLES_IN_SOURCE_BUILD" OFF)
if(OGL_SAMPLES_IN_SOURCE_BUILD)
add_definitions(-DOGL_SAMPLES_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
add_definitions(-DOGL_SAMPLES_BINARY_DIR="../")
else()
add_definitions(-DOGL_SAMPLES_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
add_definitions(-DOGL_SAMPLES_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}")
endif()
################################
# Add GLEW
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external)
add_definitions(-DGLEW_STATIC)
################################
# Add GLFW
set(GLFW_DIRECTORY glfw-3.1.1)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/${GLFW_DIRECTORY}/include)
set(GLFW_INSTALL OFF CACHE STRING "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE STRING "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE STRING "" FORCE)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/${GLFW_DIRECTORY})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/${GLFW_DIRECTORY}/include)
################################
# Add freeimage
if(MSVC AND NOT CMAKE_CL_64)
set(FREEIMAGE_BINARY_DIRECTORY "win32")
endif()
if(MSVC AND CMAKE_CL_64)
set(FREEIMAGE_BINARY_DIRECTORY "win64")
endif()
if(APPLE)
set(FREEIMAGE_BINARY_DIRECTORY "macosx")
endif()
if(UNIX AND NOT APPLE AND CMAKE_CL_64)
set(FREEIMAGE_BINARY_DIRECTORY "linux64")
endif()
if(UNIX AND NOT APPLE AND NOT CMAKE_CL_64)
set(FREEIMAGE_BINARY_DIRECTORY "linux64")
endif()
set(FREEIMAGE_DIRECTORY FreeImage-3.15.4)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/${FREEIMAGE_DIRECTORY})
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/${FREEIMAGE_DIRECTORY}/${FREEIMAGE_BINARY_DIRECTORY})
if(MSVC)
set(FREEIMAGE_LIBRARY FreeImage.lib)
set(FREEIMAGE_BINARY_FILE FreeImage.dll)
else()
add_definitions(-DFREEIMAGE_LIB)
set(FREEIMAGE_LIBRARY freeimage)
set(FREEIMAGE_BINARY_FILE freeimage)
endif()
set(FREEIMAGE_BIN_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external/${FREEIMAGE_DIRECTORY}/${FREEIMAGE_BINARY_DIRECTORY}/${FREEIMAGE_BINARY_FILE})
################################
# Add external library
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external)
################################
# Add GLO
set(GLO_DIRECTORY glo-0.1.0.0)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/${GLO_DIRECTORY})
################################
# Add GLU
set(GLU_DIRECTORY glu-0.1.0.0)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/${GLU_DIRECTORY})
################################
# Add OpenGL ES
set(ES_DIRECTORY gles-2.0)
if(MSVC AND NOT CMAKE_CL_64)
set(ES_BINARY_DIRECTORY "win32-vc")
endif(MSVC AND NOT CMAKE_CL_64)
if(MSVC AND CMAKE_CL_64)
set(ES_BINARY_DIRECTORY "win64-vc")
endif(MSVC AND CMAKE_CL_64)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/${ES_DIRECTORY})
if(WIN32)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/${ES_DIRECTORY}/lib/${ES_BINARY_DIRECTORY})
endif()
set(ES_LIBRARY libGLESv2)
################################
# Add EGL
set(EGL_DIRECTORY egl-1.4)
if(MSVC AND NOT CMAKE_CL_64)
set(EGL_BINARY_DIRECTORY "win32-vc")
endif(MSVC AND NOT CMAKE_CL_64)
if(MSVC AND CMAKE_CL_64)
set(EGL_BINARY_DIRECTORY "win64-vc")
endif(MSVC AND CMAKE_CL_64)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/${EGL_DIRECTORY})
if(WIN32)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/${EGL_DIRECTORY}/lib/${EGL_BINARY_DIRECTORY})
endif()
set(EGL_LIBRARY libEGL)
################################
# Add libraries to executables
set(BINARY_FILES glfw ${GLFW_LIBRARIES} ${FREEIMAGE_LIBRARY})
################################
# Add output directory
if(MSVC)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/build/)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(COPY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/build/Debug/ )
else(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(COPY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/build/Release/ )
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
else(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/build/Debug )
else(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/build/Release )
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
endif(MSVC)
################################
# Add options
option(OGL_SAMPLES_AUTOMATED_TESTS "OGL_SAMPLES_AUTOMATED_TESTS" OFF)
if(OGL_SAMPLES_AUTOMATED_TESTS)
add_definitions(-DAUTOMATED_TESTS)
endif()
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
if (NOT APPLE)
add_definitions(-fpermissive)
endif()
endif()
################################
# Add definitions
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif(MSVC)
################################
# Add framework
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/framework)
add_subdirectory(framework)
################################
# Copy binary
if(MSVC)
set(COPY_BINARY copy-binary)
add_custom_target(${COPY_BINARY}
COMMAND ${CMAKE_COMMAND} -E copy ${FREEIMAGE_BIN_PATH} ${CMAKE_CURRENT_BINARY_DIR}/samples/${FREEIMAGE_BINARY_FILE}
COMMAND ${CMAKE_COMMAND} -E copy ${FREEIMAGE_BIN_PATH} ${CMAKE_CURRENT_BINARY_DIR}/build/Debug/${FREEIMAGE_BINARY_FILE}
COMMAND ${CMAKE_COMMAND} -E copy ${FREEIMAGE_BIN_PATH} ${CMAKE_CURRENT_BINARY_DIR}/build/Release/${FREEIMAGE_BINARY_FILE})
endif()
################################
# Add subdirectory
add_subdirectory(tests)
################################
# Add install
install (DIRECTORY data DESTINATION .)
# See http://www.vtk.org/Wiki/CMake:CPackPackageGenerators
set (CPACK_PACKAGE_VERSION_MAJOR "4")
set (CPACK_PACKAGE_VERSION_MINOR "5")
set (CPACK_PACKAGE_VERSION_PATCH "4")
# Use current date in YYYYMMDD format as patch number
# cpack mistakenly detects Mingw-w64 as win32
if (MINGW)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set (CPACK_SYSTEM_NAME win64)
endif ()
endif ()
if (WIN32)
set (CPACK_GENERATOR "ZIP")
else ()
set (CPACK_GENERATOR "TBZ2")
endif ()
include(CPack)