forked from cubicool/osgpango
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
291 lines (246 loc) · 8.84 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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
PROJECT(osgPairo)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
#########################################################################################
# Set up default build type as Release
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
#########################################################################################
# Set up the binary and lib directories as build tagets for the libs and executables
SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin)
SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
IF(WIN32)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
ELSE(WIN32)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
ENDIF(WIN32)
FOREACH(CONF ${CMAKE_CONFIGURATION_TYPES}) # For each configuration (Debug, Release, MinSizeRel... and/or anything the user chooses)
STRING(TOUPPER "${CONF}" CONF) # Go uppercase (DEBUG, RELEASE...)
SET("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_LIBDIR}")
SET("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_BINDIR}")
IF(WIN32)
SET("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_BINDIR}")
ELSE()
SET("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_LIBDIR}")
ENDIF()
ENDFOREACH()
#
# Helper macro for setting up link libraries
#
MACRO(OSGPAIRO_HAS_LIBRARY VAR ALT)
IF(${VAR})
TARGET_LINK_LIBRARIES(${OSGPAIRO_LIBRARY_NAME} ${${VAR}})
ELSE(${VAR})
TARGET_LINK_LIBRARIES(${OSGPAIRO_LIBRARY_NAME}
debug ${ALT}
optimized ${ALT}
)
ENDIF(${VAR})
ENDMACRO(OSGPAIRO_HAS_LIBRARY VAR LIB)
# Use a debug postfix to distinguish build products. Mostly important on
# Windows, because linking a debug library into a release executable (or
# vice-versa, or just mixing C++ runtime versions) on Windows will lead
# to crashes if the libraries use the C++ runtime.
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Add a postfix, usually d on windows")
# On GCC, we need to set these compiler flags.
IF(NOT WIN32)
SET(CMAKE_CXX_FLAGS "-W -Wall -Wno-unused")
ENDIF(NOT WIN32)
###############################################################################
# Find all the packages that osgRoad depends upon
IF(NOT WIN32)
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(CAIRO REQUIRED cairo)
PKG_CHECK_MODULES(PANGO REQUIRED pango)
PKG_CHECK_MODULES(PANGOCAIRO REQUIRED pangocairo)
ELSE(NOT WIN32)
FIND_PACKAGE(Win32GTKBundle)
ENDIF(NOT WIN32)
FIND_PACKAGE(OpenThreads)
FIND_PACKAGE(osg)
FIND_PACKAGE(osgDB)
FIND_PACKAGE(osgGA)
FIND_PACKAGE(osgUtil)
FIND_PACKAGE(osgText)
FIND_PACKAGE(osgViewer)
################################################################################
# Installation stuff
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
SET(CMAKE_RELWITHDEBINFO_POSTFIX "rd" CACHE STRING "add a postfix, usually empty on windows")
SET(CMAKE_MINSIZEREL_POSTFIX "s" CACHE STRING "add a postfix, usually empty on windows")
# Set the build postfix extension according to what configuration is being built.
IF (CMAKE_BUILD_TYPE MATCHES "Release")
SET(CMAKE_BUILD_POSTFIX "${CMAKE_RELEASE_POSTFIX}")
ELSEIF (CMAKE_BUILD_TYPE MATCHES "MinSizeRel")
SET(CMAKE_BUILD_POSTFIX "${CMAKE_MINSIZEREL_POSTFIX}")
ELSEIF(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
SET(CMAKE_BUILD_POSTFIX "${CMAKE_RELWITHDEBINFO_POSTFIX}")
ELSEIF(CMAKE_BUILD_TYPE MATCHES "Debug")
SET(CMAKE_BUILD_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
ELSE()
SET(CMAKE_BUILD_POSTFIX "")
ENDIF()
SET(SRC_FILES
"src/core/Context.cpp"
"src/core/DistanceFieldText.cpp"
"src/core/Glyph.cpp"
"src/core/GlyphLayerInterface.cpp"
"src/core/GlyphLayer.cpp"
"src/core/GlyphRenderer.cpp"
"src/core/ShaderGenerator.cpp"
"src/core/ShaderManager.cpp"
"src/core/Text.cpp"
"src/core/TextTransform.cpp"
"src/core/Util.cpp"
"src/core/VerticalText.cpp"
"src/core/Image.cpp"
"src/core/ReadFile.cpp"
)
SET(SRC_LAYER_FILES
"src/layers/Bitmap.cpp"
"src/layers/Bevel.cpp"
"src/layers/DistanceField.cpp"
"src/layers/Outline.cpp"
"src/layers/ShadowBlur.cpp"
"src/layers/ShadowInset.cpp"
"src/layers/Shadow.cpp"
)
SET(SRC_RENDERER_FILES
"src/renderers/Default.cpp"
"src/renderers/DistanceField.cpp"
"src/renderers/Outline.cpp"
"src/renderers/ShadowBlur.cpp"
"src/renderers/ShadowInset.cpp"
"src/renderers/Shadow.cpp"
)
SET(SRC_SERIALIZER_FILES
"src/serializers/Glyph.cpp"
"src/serializers/GlyphRenderer.cpp"
"src/serializers/LibraryWrapper.cpp"
"src/serializers/renderers/Default.cpp"
"src/serializers/renderers/Outline.cpp"
"src/serializers/renderers/Shadow.cpp"
)
SET(CAIROROCKS_INCLUDE_DIRS "src/cairorocks/")
SET(SRC_CAIROROCKS_FILES
"src/cairorocks/distance-field.cpp"
"src/cairorocks/emboss.cpp"
"src/cairorocks/gaussian-blur.cpp"
"src/cairorocks/invert.cpp"
"src/cairorocks/map-path-onto.cpp"
"src/cairorocks/rounded.cpp"
)
SET(HEADER_DIR ${osgPairo_SOURCE_DIR}/include/osgPairo)
SET(HEADER_FILES
"${HEADER_DIR}/Context"
"${HEADER_DIR}/Export"
"${HEADER_DIR}/Glyph"
"${HEADER_DIR}/GlyphLayerInterface"
"${HEADER_DIR}/GlyphLayer"
"${HEADER_DIR}/GlyphRenderer"
"${HEADER_DIR}/Serialize"
"${HEADER_DIR}/ShaderGenerator"
"${HEADER_DIR}/ShaderManager"
"${HEADER_DIR}/String"
"${HEADER_DIR}/Text"
"${HEADER_DIR}/TextTransform"
"${HEADER_DIR}/Util"
"${HEADER_DIR}/Version"
"${HEADER_DIR}/VerticalText"
"${HEADER_DIR}/Image"
"${HEADER_DIR}/ReadFile"
)
SOURCE_GROUP("Header Files" FILES ${HEADER_FILES})
SOURCE_GROUP("Source Files" FILES ${SRC_FILES})
SOURCE_GROUP("Source Files\\Layers" FILES ${SRC_LAYER_FILES})
SOURCE_GROUP("Source Files\\Renderers" FILES ${SRC_RENDERER_FILES})
SOURCE_GROUP("Source Files\\Serializers" FILES ${SRC_SERIALIZER_FILES})
SOURCE_GROUP("Source Files\\Cairrocks" FILES ${SRC_CAIROROCKS_FILES})
INCLUDE_DIRECTORIES(include
${OSG_INCLUDE_DIR}
${CAIRO_INCLUDE_DIRS}
${PANGOCAIRO_INCLUDE_DIRS}
${GLIB_INCLUDE_DIRS}
${GLIBCONFIG_INCLUDE_DIRS}
${FONTCONFIG_INCLUDE_DIRS}
${CAIRO_INCLUDE_DIRS}
${CAIROROCKS_INCLUDE_DIRS}
)
LINK_DIRECTORIES(
${OSG_LIB_DIR}
${PANGOCAIRO_LIBRARY_DIRS}
)
SET(OSGPAIRO_LIBRARY_NAME "osgPairo" CACHE STRING "base name for osgPairo library")
ADD_LIBRARY(${OSGPAIRO_LIBRARY_NAME} SHARED
${SRC_FILES}
${SRC_LAYER_FILES}
${SRC_RENDERER_FILES}
${SRC_SERIALIZER_FILES}
${SRC_CAIROROCKS_FILES}
${HEADER_FILES}
)
OSGPAIRO_HAS_LIBRARY(CAIRO_LIBRARY cairo)
OSGPAIRO_HAS_LIBRARY(PANGO_LIBRARY pango-1.0)
OSGPAIRO_HAS_LIBRARY(PANGOCAIRO_LIBRARY pangocairo-1.0)
OSGPAIRO_HAS_LIBRARY(GOBJECT_LIBRARY gobject-2.0)
OSGPAIRO_HAS_LIBRARY(GLIB_LIBRARY glib-2.0)
IF(NOT WIN32)
OSGPAIRO_HAS_LIBRARY(FONTCONFIG_LIBRARY fontconfig)
ENDIF(NOT WIN32)
# Add debug postfix to OSG libraries so we link to the right ones in debug.
# Cairo, pango, pangocairo and the gtk libs are C-only libraries so the same
# one (release) can be linked to both debug and release without problems.
TARGET_LINK_LIBRARIES(${OSGPAIRO_LIBRARY_NAME}
${OSG_LIBRARIES} ${OSGUTIL_LIBRARIES} ${OSGDB_LIBRARIES} ${OSGGA_LIBRARIES} ${OSGTEXT_LIBRARIES} ${OSGVIEWER_LIBRARIES} ${OPENTHREADS_LIBRARIES}
)
# The archive/runtime part is so that the lib/dll pair goes into lib and bin
# respectively on Windows.
INSTALL(TARGETS ${OSGPAIRO_LIBRARY_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
)
FOREACH(INCLUDEFILE ${HEADER_FILES})
FILE(RELATIVE_PATH REL_INCLUDEFILE ${osgPairo_SOURCE_DIR}/include/osgPairo ${INCLUDEFILE})
GET_FILENAME_COMPONENT(REL_INCLUDE_PATH ${REL_INCLUDEFILE} PATH)
INSTALL(
FILES ${INCLUDEFILE}
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${OSGPAIRO_LIBRARY_NAME}/${REL_INCLUDE_PATH}
)
ENDFOREACH(INCLUDEFILE)
ADD_SUBDIRECTORY(applications/osgpango-gr-cache)
ADD_SUBDIRECTORY(examples/osgpangoanimation)
ADD_SUBDIRECTORY(examples/osgpangocomplexrenderer)
ADD_SUBDIRECTORY(examples/osgpangodistancefield)
ADD_SUBDIRECTORY(examples/osgpangofonts)
ADD_SUBDIRECTORY(examples/osgpangoglsl)
ADD_SUBDIRECTORY(examples/osgpangosimplerenderer)
ADD_SUBDIRECTORY(examples/osgpangoupdatecb)
ADD_SUBDIRECTORY(examples/osgpangovertical)
ADD_SUBDIRECTORY(examples/osgpangoviewer)
#ADD_SUBDIRECTORY(examples/osgpangoguiviewer)
#ADD_SUBDIRECTORY(examples/osgpangothreaded)
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/etc/uninstall.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
IMMEDIATE @ONLY
)
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
)
# Packaging information.
SET(CPACK_GENERATOR TGZ)
SET(CPACK_SOURCE_GENERATOR TGZ)
SET(CPACK_SOURCE_IGNORE_FILES
"~$"
".*.svn"
".*build/"
".*debug/"
".*release/"
)
SET(OSGPAIRO_VERSION "2.2.0")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "osgPairo-${OSGPAIRO_VERSION}")
INCLUDE(CPack)