forked from jklimke/libcitygml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
237 lines (197 loc) · 10.7 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0 FATAL_ERROR)
PROJECT ( libcitygml )
set(META_VERSION_MAJOR "2")
set(META_VERSION_MINOR "0")
set(META_VERSION_PATCH "3")
set(META_VERSION "${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}")
SET( CMAKE_MODULE_PATH "${libcitygml_SOURCE_DIR}/CMakeModules/;${CMAKE_MODULE_PATH}" )
IF(WIN32)
IF(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
# More MSVC specific compilation flags
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
ENDIF(MSVC)
# Both Cygwin and Msys need -DNOMINMAX ???
IF(UNIX)
ADD_DEFINITIONS(-DNOMINMAX)
ENDIF(UNIX)
########################################################################################################
# the foolowing options are MSVC specific,
# the first OSG_MSVC_VERSIONED_DLL activate a custom build-time layout that should allow to run examples and application
# fron bin folder without requiring installation step.
# it also prepend "osg${OPENSCENEGRAPH_SOVERSION}-" to only .dll files, leaving .lib files untouched in lib
# it also use a hack to get rid of Debug and Release folder in MSVC projects
# all the .dll and .pdb are in bin and all the .lib and .exp are in lib
#
# the second option disable incremental linking in debug build , that is enabled by default by CMake
##########################################################################################################
IF(MSVC)
# IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
# MESSAGE("Warning: disabling versioned options 2.4.6 exibits inconsintencies in .pdb naming, at least under MSVC, suggested upgrading at least to 2.4.7")
# SET(OSG_MSVC_VERSIONED_DLL OFF)
# SET(OSG_MSVC_DEBUG_INCREMENTAL_LINK ON)
# ELSE(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
OPTION(LIBCITYGML_MSVC_VERSIONED_DLL "Set to ON to build libcitygml with versioned dll names" ON)
MARK_AS_ADVANCED(LIBCITYGML_MSVC_VERSIONED_DLL)
OPTION(LIBCITYGML_MSVC_DEBUG_INCREMENTAL_LINK "Set to OFF to build libcitygml without incremental linking in debug (release is off by default)" ON)
MARK_AS_ADVANCED(LIBCITYGML_MSVC_DEBUG_INCREMENTAL_LINK)
IF(NOT LIBCITYGML_MSVC_DEBUG_INCREMENTAL_LINK)
SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
ENDIF(NOT LIBCITYGML_MSVC_DEBUG_INCREMENTAL_LINK)
# ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
ENDIF(MSVC)
ENDIF(WIN32)
if(UNIX)
if(APPLE)
MESSAGE(STATUS "APPLE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
else(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
MESSAGE(STATUS "Setting UNIX compile flags: ${CMAKE_CXX_FLAGS}")
endif(APPLE)
endif(UNIX)
IF(MSVC_IDE)
# From CMake 2.8.2, new way to manage output generation dirs !
# SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../")
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/bin)
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/bin)
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/lib)
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/lib)
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/bin)
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/bin)
ENDIF(MSVC_IDE)
SET(CMAKE_DEBUG_POSTFIX "d")
# Dynamic vs Static Linking
OPTION(LIBCITYGML_DYNAMIC "Set to ON to build libcitygml for dynamic linking. Use OFF for static." ON)
IF (LIBCITYGML_DYNAMIC)
SET(LIBCITYGML_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED")
ELSE (LIBCITYGML_DYNAMIC)
SET(LIBCITYGML_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC")
ENDIF(LIBCITYGML_DYNAMIC)
SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin)
MAKE_DIRECTORY(${OUTPUT_BINDIR})
SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR})
SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib)
MAKE_DIRECTORY(${OUTPUT_LIBDIR})
SET(LIBRARY_OUTPUT_PATH ${OUTPUT_LIBDIR})
if(NOT DEFINED BIN_INSTALL_DIR)
set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
endif(NOT DEFINED BIN_INSTALL_DIR)
if(NOT DEFINED LIB_INSTALL_DIR)
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
endif(NOT DEFINED LIB_INSTALL_DIR)
if(NOT DEFINED DATA_INSTALL_DIR)
set(DATA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share")
endif(NOT DEFINED DATA_INSTALL_DIR)
if(NOT DEFINED INCLUDE_INSTALL_DIR)
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/citygml")
endif(NOT DEFINED INCLUDE_INSTALL_DIR)
if(NOT DEFINED MAN_INSTALL_DIR)
set(MAN_INSTALL_DIR "${DATA_INSTALL_DIR}/man")
endif(NOT DEFINED MAN_INSTALL_DIR)
if(NOT DEFINED RESOURCE_INSTALL_DIR)
set(RESOURCE_INSTALL_DIR "${DATA_INSTALL_DIR}/libcitygml${META_VERSION_MAJOR}/resource/")
endif(NOT DEFINED RESOURCE_INSTALL_DIR)
if(NOT DEFINED LOCALE_INSTALL_DIR)
set(LOCALE_INSTALL_DIR "${DATA_INSTALL_DIR}/locale/")
endif(NOT DEFINED LOCALE_INSTALL_DIR)
# IF( DEBUG_BUILD )
# SET( CMAKE_BUILD_TYPE "Debug" )
# ELSE( DEBUG_BUILD )
# SET( CMAKE_BUILD_TYPE "Release" )
# ENDIF( DEBUG_BUILD )
OPTION(LIBCITYGML_STATIC_CRT "Set to ON to link libcitygml with the multithread CRT static library (instead of DLL)." ON)
# gdal library
OPTION(LIBCITYGML_USE_GDAL "Set to ON to build libcitygml with GDAL library so that it supports coordinates transformations." ON)
FIND_PACKAGE( Xerces REQUIRED )
IF( LIBCITYGML_USE_GDAL )
FIND_PACKAGE( GDAL REQUIRED )
ADD_DEFINITIONS( -DUSE_GDAL )
ELSE( LIBCITYGML_USE_GDAL )
SET( GDAL_INCLUDE_DIR "" )
SET( GDAL_LIBRARY "" )
ENDIF( LIBCITYGML_USE_GDAL )
FIND_PACKAGE( OpenGL REQUIRED )
#FIND_PACKAGE( GLU REQUIRED ) # deprecated, GLU is now found with FindOpenGL
IF( COMMAND cmake_policy )
cmake_policy( SET CMP0003 NEW )
ENDIF( COMMAND cmake_policy )
IF( MSVC AND LIBCITYGML_STATIC_CRT )
#We statically link to reduce dependancies
FOREACH( flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO )
IF( ${flag_var} MATCHES "/MD" )
string( REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}" )
ENDIF( ${flag_var} MATCHES "/MD" )
IF( ${flag_var} MATCHES "/MDd" )
string( REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}" )
ENDIF( ${flag_var} MATCHES "/MDd" )
ENDFOREACH( flag_var )
ENDIF( MSVC AND LIBCITYGML_STATIC_CRT )
# core
ADD_SUBDIRECTORY( sources )
# osg plugin
OPTION(LIBCITYGML_OSGPLUGIN "Set to ON to build libcitygml osgplugin programs." OFF)
IF (LIBCITYGML_OSGPLUGIN)
ADD_SUBDIRECTORY( osgplugin )
ENDIF(LIBCITYGML_OSGPLUGIN)
# test
OPTION(LIBCITYGML_TESTS "Set to ON to build libcitygml tests programs." ON)
IF (LIBCITYGML_TESTS)
ADD_SUBDIRECTORY( test )
ENDIF(LIBCITYGML_TESTS)
#-----------------------------------------------------------------------------
### uninstall target
#-----------------------------------------------------------------------------
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
# Create debian package
option(BUILD_DEBIAN_PACKAGE "Creates a debian package" ON)
if(BUILD_DEBIAN_PACKAGE)
# set project description for packaging
set(META_PROJECT_NAME "libcitygml")
set(META_PROJECT_SUMMARY "Open source C++ library for parsing CityGML files")
set(META_PROJECT_DESCRIPTION "libcitygml is a small and easy to use open source C++ library for parsing
CityGML files in such a way that data can be easily exploited by 3D
rendering applications (geometry data are tesselated and optimized for
rendering during parsing). For instance, it can be used to develop readers
of CityGML files in many 3D based applications (OpenGL, OpenSceneGraph, ...)
Most metadata are not lost, they are available through a per-node hashmap.
CityGML (City Geography Markup Language) is an XML-based schema for the
modelling and exchange of georeferenced 3D city and landscape models that
is quickly being adopted on an international level.")
set(META_AUTHOR_ORGANIZATION "3D Content Logistics")
set(META_AUTHOR_DOMAIN "https://github.com/jklimke/libcitygml.git")
set(META_AUTHOR_MAINTAINER "Marcel Pursche <[email protected]>")
# Package information
string(TOLOWER ${META_PROJECT_NAME} package_name) # Package name
set(CPACK_PACKAGE_NAME "${META_PROJECT_NAME}")
set(CPACK_PACKAGE_VENDOR "${META_AUTHOR_ORGANIZATION}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${META_PROJECT_SUMMARY}")
set(CPACK_PACKAGE_DESCRIPTION "${META_PROJECT_DESCRIPTION}")
set(CPACK_PACKAGE_VERSION "${META_VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR "${META_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${META_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${META_VERSION_PATCH}")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_RELOCATABLE OFF)
# Debian package information
set(CPACK_DEBIAN_PACKAGE_NAME "${package_name}")
set(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${META_AUTHOR_MAINTAINER}")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
set(CPACK_DEBIAN_PACKAGE_SECTION "Development")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libgdal1h (>= 1.10.1), libxerces-c3.1 (>= 3.1.1-5)")
set(CPACK_DEBIAN_PACKAGE_CONFLICTS "libcitygml0, libcitygml0-dev")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${META_AUTHOR_DOMAIN}")
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/debian_scripts/postinst;")
set(CPACK_GENERATOR "DEB")
include(CPack)
endif()