forked from ossimlabs/ossim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
302 lines (256 loc) · 11.8 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
292
293
294
295
296
297
298
299
300
301
302
PROJECT(ossim)
SET(CMAKE_MODULE_PATH "${${PROJECT_NAME}_SOURCE_DIR}/cmake/CMakeModules;${CMAKE_MODULE_PATH}")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
Message("################## Setting up OSSIM core library #########################")
IF(NOT OSSIM_BUILD_ADDITIONAL_OSSIM_DIRECTORIES)
SET(OSSIM_BUILD_ADDITIONAL_OSSIM_DIRECTORIES "" CACHE PATH "Specify full paths separated by ; to additional OSSIM applications you wish to include into the ossim build framework. These will have variables setup for the ossim includes" FORCE)
ENDIF(NOT OSSIM_BUILD_ADDITIONAL_OSSIM_DIRECTORIES)
cmake_minimum_required(VERSION 2.8)
SET(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/ossim/cmake/CMakeModules" ${CMAKE_MODULE_PATH})
include(CMakeDetermineSystem)
INCLUDE(OssimVersion)
INCLUDE(OssimCommonVariables)
# Expose some build options
set(LIB_NAME ossim CACHE STRING "Name of ossim libray (default is ossim).")
OPTION(BUILD_OSSIM_FREETYPE_SUPPORT "Set to ON to build OSSIM with freetype support. Use OFF to turn off freetype support." ON)
OPTION(BUILD_OSSIM_MPI_SUPPORT "Set to ON to build OSSIM with MPI support. Use OFF to turn off MPI support." OFF)
OPTION(BUILD_OSSIM_ID_SUPPORT "Set to ON to build OSSIM GIT ID support into the library. Use OFF to turn off ID support." ON)
OPTION(BUILD_OSSIM_APPS "Set to ON to build OSSIM applications." ON)
OPTION(BUILD_OSSIM_CURL_APPS "Set to ON to build ossim curl dependent apps. Use ON to enable." OFF)
OPTION(BUILD_OSSIM_TESTS "Set to ON to build OSSIM unit/functional tests." ON)
###################################################################################
# Include the Utilities in the root make
###################################################################################
INCLUDE(OssimUtilities)
INCLUDE(CheckIncludeFile)
CHECK_INCLUDE_FILE("dirent.h" CMAKE_HAVE_DIRENT_H)
CHECK_INCLUDE_FILE("unistd.h" CMAKE_HAVE_UNISTD_H)
CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
CHECK_INCLUDE_FILE("fcntl.h" CMAKE_HAVE_FCNTL_H)
CHECK_INCLUDE_FILE("dbmalloc.h" CMAKE_HAVE_DBMALLOC_H)
CHECK_INCLUDE_FILE("malloc.h" CMAKE_HAVE_MALLOC_H)
CHECK_INCLUDE_FILE("dlfcn.h" CMAKE_HAVE_DLFCN_H)
# Set our include paths:
include_directories( ${PROJECT_SOURCE_DIR}/include )
include_directories( ${PROJECT_BINARY_DIR}/include )
include_directories( ${OSSIM_INCLUDE_DIR} )
# Stores list of libs to link with. Initialized throughout.
set( ossimDependentLibs )
#---
# Find required and optional packages and add their include paths and libraries:
#---
# GEOS - Required:
find_package( GEOS )
if( GEOS_FOUND )
include_directories( ${GEOS_INCLUDE_DIR} )
set( ossimDependentLibs ${ossimDependentLibs} ${GEOS_LIBRARY} )
else( GEOS_FOUND )
message( FATAL_ERROR "Could not find required geos package!" )
endif( GEOS_FOUND )
# GEOFIFF - Required:
set( OSSIM_HAS_GEOTIFF 0 )
find_package( GEOTIFF )
if( GEOTIFF_FOUND )
include_directories( ${GEOTIFF_INCLUDE_DIR} )
set( ossimDependentLibs ${ossimDependentLibs} ${GEOTIFF_LIBRARY} )
set( OSSIM_HAS_GEOTIFF 1 )
else( GEOTIFF_FOUND )
message( FATAL_ERROR "Could not find required geotiff package!" )
endif( GEOTIFF_FOUND )
# GEOTRANS - Required: (GeoTrans 3.4.x port future...)
# find_package( Geotrans )
# if( GEOTRANS_FOUND )
# include_directories( ${GEOTRANS_INCLUDE_DIR} )
# set( ossimDependentLibs ${ossimDependentLibs} ${GEOTRANS_LIBRARY} )
# else( GEOTRANS_FOUND )
# message( FATAL_ERROR "Could not find required geotrans package!" )
# endif( GEOTRANS_FOUND )
# JPEG - Required package:
find_package( JPEG )
if( JPEG_FOUND )
include_directories( ${JPEG_INCLUDE_DIR} )
set( ossimDependentLibs ${ossimDependentLibs} ${JPEG_LIBRARY} )
else( JPEG_FOUND )
message( FATAL_ERROR "Could not find required jpeg package!" )
endif( JPEG_FOUND )
# TIFF - Required:
find_package( TIFF )
if( TIFF_FOUND )
include_directories( ${TIFF_INCLUDE_DIR} )
set( ossimDependentLibs ${ossimDependentLibs} ${TIFF_LIBRARY} )
else( TIFF_FOUND )
message( FATAL_ERROR "Could not find required tiff package!" )
endif( TIFF_FOUND )
# JSONCPP - Required:
find_package( JsonCpp )
if( JSONCPP_FOUND )
include_directories( ${JSONCPP_INCLUDE_DIR} )
set( ossimDependentLibs ${ossimDependentLibs} ${JSONCPP_LIBRARY} )
message("Found JsonCpp" )
else( JSONCPP_FOUND )
message( FATAL_ERROR "Could not find required JsonCpp package!" )
endif( JSONCPP_FOUND )
# This caused a core dump on ossim executables running in jenins pipeline (ossim-test-dev)
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
find_library( DL_LIBRARY dl )
if ( DL_LIBRARY )
set( ossimDependentLibs ${ossimDependentLibs} ${DL_LIBRARY} )
else( DL_LIBRARY )
# TODO: Is this required on unix? If so move to the required section.
message( FATAL_ERROR "Could not find dl library!" )
endif( DL_LIBRARY )
endif() # if (CMAKE_SYSTEM_NAME MATCHES "Linux")
#if( UNIX )
# find_library( DL_LIBRARY dl )
# if ( DL_LIBRARY )
# set( ossimDependentLibs ${ossimDependentLibs} ${DL_LIBRARY} )
# else( DL_LIBRARY )
# # TODO: Is this required on unix? If so move to the required section.
# message( FATAL_ERROR "Could not find dl library!" )
# endif( DL_LIBRARY )
#endif( UNIX )
# JSONCPP - Optional:
set( OSSIM_HAS_JSONCPP 0 )
find_package( JsonCpp )
if( JSONCPP_FOUND )
include_directories( ${JSONCPP_INCLUDE_DIR} )
set( ossimDependentLibs ${ossimDependentLibs} ${JSONCPP_LIBRARY} )
set( OSSIM_HAS_JSONCPP 1 )
else( JSONCPP_FOUND )
message("Could not find optional JSONCPP package! Consider installing this as it will soon become a required package." )
endif( JSONCPP_FOUND )
# FREETYPE - Optional:
set( OSSIM_HAS_FREETYPE 0 )
if( BUILD_OSSIM_FREETYPE_SUPPORT )
find_package(Freetype)
if( FREETYPE_FOUND )
include_directories( ${FREETYPE_INCLUDE_DIRS} )
set( ossimDependentLibs ${ossimDependentLibs} ${FREETYPE_LIBRARIES} )
set( OSSIM_HAS_FREETYPE 1 )
else( FREETYPE_FOUND )
message( WARNING "Could not find optional freetype package!" )
endif( FREETYPE_FOUND )
endif( BUILD_OSSIM_FREETYPE_SUPPORT )
# MPI - Optional:
set( OSSIM_HAS_MPI 0 )
if( BUILD_OSSIM_MPI_SUPPORT )
find_package(MPI)
if ( MPI_FOUND )
include_directories( ${MPI_INCLUDE_DIR} )
set( ossimDependentLibs ${ossimDependentLibs} ${MPI_LIBRARY} )
set( OSSIM_HAS_MPI 1 )
else ( MPI_FOUND )
message( WARNING "Could not find optional MPI package!" )
endif ( MPI_FOUND )
endif( BUILD_OSSIM_MPI_SUPPORT )
# ZLIB - Optional:
set( OSSIM_HAS_LIBZ 0 )
find_package( ZLIB )
if ( ZLIB_FOUND )
include_directories( ${ZLIB_INCLUDE_DIR} )
set( ossimDependentLibs ${ossimDependentLibs} ${ZLIB_LIBRARY} )
set( OSSIM_HAS_LIBZ 1 )
else ( ZLIB_FOUND )
message( WARNING "Could not find optional zlib package!" )
endif ( ZLIB_FOUND )
# HDF5 - Optional:
set( OSSIM_HAS_HDF5 0 )
if (BUILD_OSSIM_HDF5_SUPPORT)
message( STATUS "Native HDF5 support requested. Searching for HDF5 library..." )
find_package( HDF5A )
if ( HDF5A_FOUND)
include_directories( ${HDF5A_INCLUDE_DIR} )
set( ossimDependentLibs ${ossimDependentLibs} ${HDF5A_LIBRARIES} )
set( OSSIM_HAS_HDF5 1 )
else ( HDF5A_FOUND )
message( WARNING "Could not find optional HDF5A package. Excluding native support." )
endif ( HDF5A_FOUND )
else (BUILD_OSSIM_HDF5_SUPPORT)
message( STATUS "Native HDF5 support was not requested. If you want HDF5 support, set the environment BUILD_OSSIM_HDF5_SUPPORT=ON..." )
endif ( BUILD_OSSIM_HDF5_SUPPORT )
find_package( Threads )
set( ossimDependentLibs ${ossimDependentLibs} ${CMAKE_THREAD_LIBS_INIT} )
#---
# Call the OSSIM macros in OssimUtilities.cmake
#---
if ( NOT OSSIM_BUILD_DATE )
TODAYS_DATE(OSSIM_BUILD_DATE)
endif( NOT OSSIM_BUILD_DATE )
SET(OSSIM_GIT_REVISION_NUMBER "UNKNOWN")
GET_GIT_REVISION()
if ( NOT ${Project_WC_REVISION} EQUAL 0 )
set( OSSIM_GIT_REVISION_NUMBER ${Project_WC_REVISION} )
endif()
#####################################################################################
# Call the configure files for ossimConfig and ossimVersion setup
#####################################################################################
set(OSSIM_VERSION_NUMBER "\"${OSSIM_VERSION}\"")
set(OSSIM_BUILD_DATE "\"${OSSIM_BUILD_DATE}\"")
set(OSSIM_REVISION "\"${OSSIM_GIT_REVISION_NUMBER}\"")
# Setting of OSSIM_ID to variable expanded $Id$ results. Embedded troughout code.
set(OSSIM_ID_ENABLED 1)
IF(NOT BUILD_OSSIM_ID_SUPPORT)
set(OSSIM_ID_ENABLED 0)
ENDIF(NOT BUILD_OSSIM_ID_SUPPORT)
SET(OSSIM_CONFIGURE_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/include/ossim/ossimConfig.h")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/src/ossimConfig.h.in"
"${OSSIM_CONFIGURE_HEADER}")
SET(OSSIM_VERSION_HEADER_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/src/ossimVersion.h.in")
SET(OSSIM_VERSION_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/include/ossim/ossimVersion.h")
CONFIGURE_FILE("${OSSIM_VERSION_HEADER_CONFIG}"
"${OSSIM_VERSION_HEADER}")
##################################################################################################
# Point to the CMakeLists.txt in the src dir. OLK: Removed unnecessary src/ossim structure and
# replaced with simply src.
##################################################################################################
subdirs(src)
set(TARGET_COMMON_LIBRARIES ossim)
##################################################################################################
#
# Setup install destinations for the shared files:
# 1) Projection CSV files:
#
##################################################################################################
FILE(GLOB ossim_projection_codes_csv ${${PROJECT_NAME}_SOURCE_DIR}/share/ossim/projection/*.csv ${${PROJECT_NAME}_SOURCE_DIR}/share/ossim/projection/*.txt)
INSTALL(FILES ${ossim_projection_codes_csv} DESTINATION share/ossim/projection COMPONENT ossim)
# 2) Utility API JSON files
FILE(GLOB ossim_util_api_json ${${PROJECT_NAME}_SOURCE_DIR}/share/ossim/util/*.json)
INSTALL(FILES ${ossim_util_api_json} DESTINATION share/ossim/util COMPONENT ossim)
# 3) Fonts
FILE(GLOB ossim_fonts ${${PROJECT_NAME}_SOURCE_DIR}/share/ossim/fonts/*.ttf)
INSTALL(FILES ${ossim_fonts} DESTINATION share/ossim/fonts COMPONENT ossim)
###################### OUTPUT GENERAL VARIABLE SETTINGS #######################
MESSAGE( STATUS "OSSIM_REVISION = ${OSSIM_REVISION}" )
MESSAGE( STATUS "FREETYPE_LIBRARY = ${FREETYPE_LIBRARIES}" )
MESSAGE( STATUS "FREETYPE_INCLUDE = ${FREETYPE_INCLUDE_DIRS}" )
MESSAGE( STATUS "GEOTIFF_LIBRARY = ${GEOTIFF_LIBRARIES}" )
MESSAGE( STATUS "GEOTIFF_INCLUDE = ${GEOTIFF_INCLUDE_DIR}" )
MESSAGE( STATUS "GEOTRANS_LIBRARY = ${GEOTRANS_LIBRARY}" )
MESSAGE( STATUS "GEOTRANS_INCLUDE = ${GEOTRANS_INCLUDE_DIR}" )
MESSAGE( STATUS "GEOS_LIBRARY = ${GEOS_LIBRARY}" )
MESSAGE( STATUS "GEOS_INCLUDE = ${GEOS_INCLUDE_DIR}" )
MESSAGE( STATUS "JPEG_LIBRARY = ${JPEG_LIBRARIES}" )
MESSAGE( STATUS "JPEG_INCLUDE = ${JPEG_INCLUDE_DIR}" )
MESSAGE( STATUS "OSSIM DEPENDENT LIBRARIES = ${ossimDependentLibs}" )
MESSAGE( STATUS "OSSIM_HAS_HDF5 = ${OSSIM_HAS_HDF5}" )
MESSAGE( STATUS "OSSIM_HAS_JSONCPP = ${OSSIM_HAS_JSONCPP}" )
#-----------------------------------------------------------------------------
# uninstall target
#-----------------------------------------------------------------------------
#OSSIM_ADD_COMMON_MAKE_UNINSTALL()
IF(BUILD_OSSIM_APPS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/apps ${CMAKE_CURRENT_BINARY_DIR}/apps)
ENDIF()
#---
# Building curl dependant apps optional. default=OFF
#---
if(BUILD_OSSIM_CURL_APPS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/apps/curl_apps)
endif()
IF(BUILD_OSSIM_TESTS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/src ${CMAKE_CURRENT_BINARY_DIR}/test/src)
ENDIF()
message("################## end of OSSIM core library setup #########################\n")