-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
268 lines (216 loc) · 8.57 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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# CMake file for BlendInt project
#
cmake_minimum_required(VERSION 2.8.11)
project (BlendInt)
set(CMAKE_BUILD_TYPE_INIT "Debug")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(BLENDINT_VERSION_FULL "0.1")
set(BLENDINT_LIB_NAME "blendint")
# Check the system and define BLENDINT_SYSTEM_NAME to:
# 0 - Linux
# 1 - OS X
# 2 - Windows (not supported currently)
# These values are also defined in include/blendint/config.hpp.in
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(OS_LINUX TRUE)
add_definitions(-DGL_GLEXT_PROTOTYPES)
set(BLENDINT_SYSTEM_NAME 0)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(OS_APPLE TRUE)
set(BLENDINT_SYSTEM_NAME 1)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
message(FATAL_ERROR "BlendInt does not support Windows yet!")
set(OS_WINDOWS TRUE)
set(BLENDINT_SYSTEM_NAME 2)
endif()
# start of options
option(BUILD_STATIC_LIBRARY "Build static library instead of shared" OFF)
option(ENABLE_OPENCV "Enable OpenCV Support" OFF)
option(WITH_GPERFTOOLS "Build with Google perftools option" OFF)
option(WITH_ALL_DEMOS "Build all demo programs" OFF)
option(WITH_GLFW3_DEMO "Build GLFW3 demo program" OFF)
option(WITH_GLUT_DEMO "Build GLUT demo program" OFF)
option(WITH_QT5_DEMO "Build Qt5 demo program" OFF)
option(WITH_UNIT_TEST "Build unit test code" OFF)
option(BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentation" OFF)
# end of options
configure_file("${PROJECT_SOURCE_DIR}/include/blendint/config.hpp.in"
"${PROJECT_BINARY_DIR}/include/blendint/config.hpp" @ONLY)
# Check if compiler support C++11:
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no
C++11 support. Please use a different C++ compiler.")
endif()
# to find the config header:
include_directories("${PROJECT_BINARY_DIR}/include")
# for cppevent:
include_directories("${PROJECT_SOURCE_DIR}/include/blendint")
if(OS_APPLE)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /usr/local/lib)
endif()
find_package(OpenGL REQUIRED)
if(OPENGL_FOUND)
include_directories(${OPENGL_INCLUDE_DIR})
set(LIBS ${LIBS} ${OPENGL_LIBRARIES})
endif()
find_package(Freetype REQUIRED)
if(FREETYPE_FOUND)
include_directories(${FREETYPE_INCLUDE_DIRS})
set(LIBS ${LIBS} ${FREETYPE_LIBRARIES})
endif()
find_package(FontConfig REQUIRED)
if(FONTCONFIG_FOUND)
include_directories(${FONTCONFIG_INCLUDE_DIR})
set(LIBS ${LIBS} ${FONTCONFIG_LIBRARY})
endif()
#find_package(GLEW REQUIRED)
#if(GLEW_FOUND)
# include_directories(${GLEW_INCLUDE_DIRS})
# set(LIBS ${LIBS} ${GLEW_LIBRARIES})
#endif()
find_package(Boost REQUIRED COMPONENTS filesystem system)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Boost_LIBRARIES})
#message(STATUS "Use the Boost libraries: ${Boost_LIBRARIES}")
#message(STATUS "Use the Boost libraries in: ${Boost_LIBRARY_DIRS}")
message(STATUS "boost lib dir: ${Boost_LIBRARY_DIRS}")
if(OS_APPLE)
string(REGEX MATCH "libboost_system.*[.]dylib" BOOST_SYSTEM_LIB_NAME "${Boost_SYSTEM_LIBRARY}")
string(REGEX REPLACE "^lib" "" BOOST_SYSTEM_LIB_NAME "${BOOST_SYSTEM_LIB_NAME}")
string(REGEX REPLACE "[.]dylib$" "" BOOST_SYSTEM_LIB_NAME "${BOOST_SYSTEM_LIB_NAME}")
message(STATUS "Use boost_system: ${BOOST_SYSTEM_LIB_NAME}")
string(REGEX MATCH "libboost_filesystem.*[.]dylib" BOOST_FILESYSTEM_LIB_NAME "${Boost_FILESYSTEM_LIBRARY}")
string(REGEX REPLACE "^lib" "" BOOST_FILESYSTEM_LIB_NAME "${BOOST_FILESYSTEM_LIB_NAME}")
string(REGEX REPLACE "[.]dylib$" "" BOOST_FILESYSTEM_LIB_NAME "${BOOST_FILESYSTEM_LIB_NAME}")
message(STATUS "Use boost_filesystem: ${BOOST_FILESYSTEM_LIB_NAME}")
# string(REGEX MATCH "libboost_thread.*[.]dylib" BOOST_THREAD_LIB_NAME "${Boost_THREAD_LIBRARY}")
# string(REGEX REPLACE "^lib" "" BOOST_THREAD_LIB_NAME "${BOOST_THREAD_LIB_NAME}")
# string(REGEX REPLACE "[.]dylib$" "" BOOST_THREAD_LIB_NAME "${BOOST_THREAD_LIB_NAME}")
# message(STATUS "Use boost_thread: ${BOOST_THREAD_LIB_NAME}")
elseif(OS_LINUX)
string(REGEX MATCH "libboost_system.*[.]so.*" BOOST_SYSTEM_LIB_NAME "${Boost_SYSTEM_LIBRARY}")
string(REGEX REPLACE "^lib" "" BOOST_SYSTEM_LIB_NAME "${BOOST_SYSTEM_LIB_NAME}")
string(REGEX REPLACE "[.]so.*$" "" BOOST_SYSTEM_LIB_NAME "${BOOST_SYSTEM_LIB_NAME}")
message(STATUS "Use boost_system: ${BOOST_SYSTEM_LIB_NAME}")
string(REGEX MATCH "libboost_filesystem.*[.]so.*" BOOST_FILESYSTEM_LIB_NAME "${Boost_FILESYSTEM_LIBRARY}")
string(REGEX REPLACE "^lib" "" BOOST_FILESYSTEM_LIB_NAME "${BOOST_FILESYSTEM_LIB_NAME}")
string(REGEX REPLACE "[.]so.*$" "" BOOST_FILESYSTEM_LIB_NAME "${BOOST_FILESYSTEM_LIB_NAME}")
message(STATUS "Use boost_filesystem: ${BOOST_FILESYSTEM_LIB_NAME}")
# string(REGEX MATCH "libboost_thread.*[.]so.*" BOOST_THREAD_LIB_NAME "${Boost_THREAD_LIBRARY}")
# string(REGEX REPLACE "^lib" "" BOOST_THREAD_LIB_NAME "${BOOST_THREAD_LIB_NAME}")
# string(REGEX REPLACE "[.]so.*$" "" BOOST_THREAD_LIB_NAME "${BOOST_THREAD_LIB_NAME}")
# message(STATUS "Use boost_thread: ${BOOST_THREAD_LIB_NAME}")
else() # WIN
endif()
endif()
# add OpenImageIO link
find_package(OpenImageIO REQUIRED)
if(OPENIMAGEIO_FOUND)
include_directories(${OPENIMAGEIO_INCLUDE_DIR})
set(LIBS ${LIBS} ${OPENIMAGEIO_LIBRARY})
endif()
# search pkg-config
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
configure_file("${PROJECT_SOURCE_DIR}/lib/pkgconfig/blendint.pc.in"
"${PROJECT_BINARY_DIR}/lib/pkgconfig/blendint.pc" @ONLY)
endif()
# configure glfw
find_package(GLFW REQUIRED)
if(GLFW_FOUND)
include_directories(${GLFW_INCLUDE_DIR})
set(LIBS ${LIBS} ${GLFW_LIBRARIES})
endif()
if(OS_APPLE)
add_definitions(-DGLFW_INCLUDE_GLCOREARB)
add_definitions(-DGLFW_INCLUDE_GLEXT)
endif()
# glm
find_package(GLM REQUIRED)
if(GLM_FOUND)
include_directories(${GLM_INCLUDE_DIRS})
add_definitions(-DGLM_FORCE_RADIANS)
endif()
if(ENABLE_OPENCV)
find_package(OpenCV REQUIRED)
add_definitions(-D__USE_OPENCV__)
set(LIBS ${LIBS} ${OpenCV_LIBS})
endif()
include_directories(${BlendInt_SOURCE_DIR}/include)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR
CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
add_definitions(-DDEBUG)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -p -pg")
endif()
if(WITH_GPERFTOOLS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
set(LIBS ${LIBS} profiler)
endif()
endif()
if(MSVC)
# Force to always compile with W4
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# Update if necessary
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()
# add rapidxml header files
include_directories(${BlendInt_SOURCE_DIR}/extern/rapidxml)
if(OS_APPLE)
# more settings for OS X OS X RPATH:
# http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH
set(CMAKE_MACOSX_RPATH 1)
set(LIBS ${LIBS} pthread)
endif()
add_subdirectory(lib)
add_subdirectory(editor)
add_subdirectory(data)
if(BUILD_STATIC_LIBRARY)
set(LIBS ${LIBS} pthread)
endif()
if(BUILD_DOCUMENTATION)
add_subdirectory(doc)
endif()
if(WITH_UNIT_TEST)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-variadic-macros")
if(EXISTS "${BlendInt_SOURCE_DIR}/test")
add_subdirectory(test)
endif()
endif()
if(WITH_ALL_DEMOS)
set(WITH_GLFW3_DEMO TRUE)
set(WITH_GLUT_DEMO TRUE)
set(WITH_QT5_DEMO TRUE)
endif()
if(EXISTS "${BlendInt_SOURCE_DIR}/demo")
add_subdirectory(demo)
endif()
# ----------------------------------------------------------------------------
# Uninstall
# ----------------------------------------------------------------------------
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
# ----------------------------------------------------------------------------
# Summary:
# ----------------------------------------------------------------------------
message(STATUS "")
message(STATUS " config.hpp is in: ${PROJECT_BINARY_DIR}/include/blendint")
message(STATUS " Install path: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "")