File: CMakeLists.txt

package info (click to toggle)
pktools 2.6.7.6+ds-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 9,040 kB
  • sloc: cpp: 33,451; xml: 10,955; python: 1,601; makefile: 142; sh: 58; ansic: 24
file content (411 lines) | stat: -rw-r--r-- 15,305 bytes parent folder | download
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
###############################################################################
#
# CMake build scripts for PKTOOLS
#
#
# History
# 2010/12/14 - Created by Peter Bunting for SPDLib
# 2012/02/07 - Edited by Peter Bunting for PKTOOLS
# 2014/11/22 - Edited by Peter Bunting for pktools
# 2015/12/10 - Edited by Pieter Kempeneers and Kris Vanhoof
# 2018/08/18 - Patch bug 53725 by Bas Couwenberg
# Change log
# Find package lib
# Boost: disable auto linking: add_definitions("-DBOOST_ALL_NO_LIB")
# add cmake env variable Boost_COMPILER -vc110
# FANN: create library CMake: add ADD_DEFINITIONS(-DFANN_DLL_EXPORTS)
# GDAL: disabled macro for Visual Studio 2015
#if defined(_MSC_VER) && (_MSC_VER < 1900)
#  define snprintf _snprintf
#endif
#set CMAKE_INSTALL_PREFIX to C:/OSGeo4W64;C:/Users/kempenep/Downloads/FANN-2.2.0-Source/FANN-2.2.0-Source/install;C:/Users/kempenep/Downloads/armadillo-6.200.4/install;C:\Users\kempenep\Downloads\nlopt-2.4.2-dll64
#
###############################################################################
cmake_minimum_required(VERSION 2.6.0)
#cmake_minimum_required(VERSION 2.8)
###############################################################################
# Set Project name and version
project (PKTOOLS)

set (PROJECT_BINARY_DIR bin)
set (PROJECT_LIBRARY_DIR lib)
set (PROJECT_INCLUDE_DIR include/pktools)
set (PROJECT_DOC_DIR doc)
set (PROJECT_SOURCE_DIR src)

# The version number.
set (PKTOOLS_VERSION_MAJOR 2)
set (PKTOOLS_VERSION_MINOR 6)
set (PKTOOLS_VERSION_PATCH 7.6)
set (PKTOOLS_VERSION "${PKTOOLS_VERSION_MAJOR}.${PKTOOLS_VERSION_MINOR}.${PKTOOLS_VERSION_PATCH}")
set (PKTOOLS_PACKAGE_VERSION "${PKTOOLS_VERSION_MAJOR}.${PKTOOLS_VERSION_MINOR}.${PKTOOLS_VERSION_PATCH}")
set (PKTOOLS_PACKAGE_STRING "PKTOOLS ${PKTOOLS_VERSION_MAJOR}.${PKTOOLS_VERSION_MINOR}.${PKTOOLS_VERSION_PATCH}")
set (PKTOOLS_PACKAGE_BUGREPORT "kempenep@gmail.com")
set (PKTOOLS_PACKAGE "pktools")
set (PKTOOLS_COPYRIGHT_YEAR 2016)

set (PKTOOLS_BASE_VERSION_MAJOR 1)
set (PKTOOLS_BASE_VERSION_MINOR 6)
set (PKTOOLS_BASE_VERSION_PATCH 1)
set (PKTOOLS_BASE_VERSION "${PKTOOLS_BASE_VERSION_MAJOR}.${PKTOOLS_BASE_VERSION_MINOR}.${PKTOOLS_BASE_VERSION_PATCH}")
set (PKTOOLS_BASE_SOVERSION 1)

set (PKTOOLS_ALGORITHMS_VERSION_MAJOR 1)
set (PKTOOLS_ALGORITHMS_VERSION_MINOR 6)
set (PKTOOLS_ALGORITHMS_VERSION_PATCH 1)
set (PKTOOLS_ALGORITHMS_VERSION "${PKTOOLS_ALGORITHMS_VERSION_MAJOR}.${PKTOOLS_ALGORITHMS_VERSION_MINOR}.${PKTOOLS_ALGORITHMS_VERSION_PATCH}")
set (PKTOOLS_ALGORITHMS_SOVERSION 1)

set (PKTOOLS_FILECLASSES_VERSION_MAJOR 1)
set (PKTOOLS_FILECLASSES_VERSION_MINOR 6)
set (PKTOOLS_FILECLASSES_VERSION_PATCH 1)
set (PKTOOLS_FILECLASSES_VERSION "${PKTOOLS_FILECLASSES_VERSION_MAJOR}.${PKTOOLS_FILECLASSES_VERSION_MINOR}.${PKTOOLS_FILECLASSES_VERSION_PATCH}")
set (PKTOOLS_FILECLASSES_SOVERSION 1)

set (PKTOOLS_IMAGECLASSES_VERSION_MAJOR 1)
set (PKTOOLS_IMAGECLASSES_VERSION_MINOR 6)
set (PKTOOLS_IMAGECLASSES_VERSION_PATCH 1)
set (PKTOOLS_IMAGECLASSES_VERSION "${PKTOOLS_IMAGECLASSES_VERSION_MAJOR}.${PKTOOLS_IMAGECLASSES_VERSION_MINOR}.${PKTOOLS_IMAGECLASSES_VERSION_PATCH}")
set (PKTOOLS_IMAGECLASSES_SOVERSION 1)

set (PKTOOLS_LASCLASSES_VERSION_MAJOR 1)
set (PKTOOLS_LASCLASSES_VERSION_MINOR 6)
set (PKTOOLS_LASCLASSES_VERSION_PATCH 1)
set (PKTOOLS_LASCLASSES_VERSION "${PKTOOLS_LASCLASSES_VERSION_MAJOR}.${PKTOOLS_LASCLASSES_VERSION_MINOR}.${PKTOOLS_LASCLASSES_VERSION_PATCH}")
set (PKTOOLS_LASCLASSES_SOVERSION 1)

# Name of C++ library
set(PKTOOLS_BASE_LIB_NAME base)
set(PKTOOLS_ALGORITHMS_LIB_NAME algorithms)
set(PKTOOLS_FILECLASSES_LIB_NAME fileClasses)
set(PKTOOLS_IMAGECLASSES_LIB_NAME imageClasses)
set(PKTOOLS_LASCLASSES_LIB_NAME lasClasses)

option(BUILD_SHARED_LIBS "Build with shared library" OFF)
set(BUILD_WITH_LIBLAS FALSE CACHE BOOL "Choose if pktools is to be built with liblas")
set(BUILD_WITH_FANN FALSE CACHE BOOL "Choose if pktools is to be built with fann")
#set(BUILD_WITH_NLOPT FALSE CACHE BOOL "Choose if pktools is to be built with nlopt")
set(PKTOOLS_WITH_UTILITIES TRUE CACHE BOOL "Choose if pktools utilities should be built")
option(INSTALL_LIBRARY_DIR "Install path for libraries" ${PROJECT_LIBRARY_DIR})

set(GSL_INCLUDE_DIR /usr/include CACHE PATH "Include PATH for GSL")
set(GSL_LIB_PATH /usr/lib CACHE PATH "Library PATH for GSL")

###############################################################################

###############################################################################
# CMake settings
# cmake_minimum_required(VERSION 2.6.0)

IF(NOT CMAKE_BUILD_TYPE)
  #SET(CMAKE_BUILD_TYPE "DEBUG")
  SET(CMAKE_BUILD_TYPE "RELEASE")
  #SET(CMAKE_BUILD_TYPE "RELWITHDEBINFO")
  #SET(CMAKE_BUILD_TYPE "MINSIZEREL")
ENDIF()

set(CMAKE_COLOR_MAKEFILE ON)

# Allow advanced users to generate Makefiles printing detailed commands
mark_as_advanced(CMAKE_VERBOSE_MAKEFILE)

# Path to additional CMake modules
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
###############################################################################

###############################################################################
# Setup configure file
configure_file ( "cmake-config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/base/config.h" @ONLY)
include_directories("${CMAKE_CURRENT_BINARY_DIR}/base")
add_definitions(-DHAVE_CONFIG_H)
###############################################################################

###############################################################################
# Documentation
#file(READ "doc/index.txt" README )
file(WRITE "README.txt" "${README}")
###############################################################################

###############################################################################
# Platform and compiler specific settings

if(WIN32)
    if (MSVC)
        if (MSVC80 OR MSVC90 OR MSVC10)
            add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
            add_definitions(-D_CRT_SECURE_NO_WARNINGS)
            add_definitions(-D_CRT_NONSTDC_NO_WARNING)
            add_definitions(-D_SCL_SECURE_NO_WARNINGS)
        endif()
        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()

        # Generate dot-user file with user-specific settings for Visual Studio project
        set(MSVC_ENVIRONMENT_PATH "" CACHE STRING
            "Custom PATH for Environment property in Visual Studio project configuration")
        mark_as_advanced(MSVC_ENVIRONMENT_PATH)
        set(VCPROJ_USER_ENVIRONMENT_PATH_DEBUG "${ENVIRONMENT_PATH}")
        mark_as_advanced(VCPROJ_USER_ENVIRONMENT_PATH_DEBUG)

    endif()

	set(CMAKE_INCLUDE_PATH c:/osgeo4w/include;$ENV{CMAKE_INCLUDE_PATH})
    set(CMAKE_LIBRARY_PATH c:/osgeo4w/lib;$ENV{CMAKE_LIBRARY_PATH})
else()
  # Recommended C++ compilation flags
  # -Weffc++
  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
  set(PKTOOLS_COMMON_CXX_FLAGS
    "-Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wredundant-decls -Wno-long-long")

  if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)

    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC ${PKTOOLS_COMMON_CXX_FLAGS}")
    if (CMAKE_COMPILER_IS_GNUCXX)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
    endif()

  elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER}" MATCHES "clang")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PKTOOLS_COMMON_CXX_FLAGS}")
  endif()
endif(WIN32)

if (APPLE)
  set(SO_EXT dylib)
 # set(CMAKE_FIND_FRAMEWORK "LAST")
elseif(WIN32)
  set(SO_EXT dll)
else()
  set(SO_EXT so)
endif(APPLE)
###############################################################################

###############################################################################
# Check the required libraries are present

#include_directories(${GDAL_INCLUDE_DIR})
#if (MSVC)
#  set(GDAL_LIBRARIES -LIBPATH:${GDAL_LIB_PATH} gdal_i.lib)
#else()
#  set(GDAL_LIBRARIES -L${GDAL_LIB_PATH} -lgdal)
#endif(MSVC)

find_package(GDAL 1.10 REQUIRED)
if(GDAL_FOUND)
	include_directories(${GDAL_INCLUDE_DIRS})
endif()

find_package(GSL REQUIRED)
if(GSL_FOUND)
  include_directories(${GSL_INCLUDE_DIRS})
  add_definitions(-DGSL_DLL)
endif()

find_package(Armadillo REQUIRED)
if(ARMADILLO_FOUND)
	include_directories(${ARMADILLO_INCLUDE_DIRS})
endif()

if (BUILD_WITH_LIBLAS)
	find_package(LIBLAS)
	if(LIBLAS_FOUND)
	  include_directories(${LIBLAS_INCLUDE_DIRS})
	endif()
	set(Boost_DEBUG 0)
	find_package(Boost COMPONENTS filesystem system)
	if(Boost_FOUND)
		include_directories(${Boost_INCLUDE_DIRS})
		add_definitions("-DBOOST_ALL_NO_LIB")
	endif()
#	include_directories(${BOOST_INCLUDE_DIR})
#	if (MSVC)
#		set(BOOST_LIBRARIES -LIBPATH:${BOOST_LIB_PATH} libboost_filesystem-vc100-mt-1_56.lib libboost_system-vc100-mt-1_56.lib)
#	else()
#		set(BOOST_LIBRARIES -L${BOOST_LIB_PATH} -lboost_filesystem -lboost_system)
#	endif(MSVC)
endif(BUILD_WITH_LIBLAS)

if (BUILD_WITH_FANN)
	find_package(FANN)
	if(FANN_FOUND)
		include_directories(${FANN_INCLUDE_DIRS})
		add_definitions(-DFANN_DLL)
	endif()
endif(BUILD_WITH_FANN)

# if (BUILD_WITH_NLOPT)
#   find_package(NLOPT)
#   if(NLOPT_FOUND)
#     include_directories(${NLOPT_INCLUDE_DIRS})
#     add_definitions(-DNLOPT_DLL)
#   endif()
# endif(BUILD_WITH_NLOPT)
###############################################################################

###############################################################################
# Build libraries
include_directories("${PROJECT_SOURCE_DIR}")
add_subdirectory ("${PROJECT_SOURCE_DIR}")
###############################################################################

###############################################################################
# Build executables

#configure_file ( "cmake-config.in" "${PROJECT_BINARY_DIR}/pktools-config" @ONLY )
#test
configure_file ( "cmake-config.in" "${CMAKE_CURRENT_BINARY_DIR}/pktools-config" @ONLY )
configure_file ( "cmake.pc.in" "pktools.pc"  @ONLY)


set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(PKLIBS ${PKTOOLS_BASE_LIB_NAME} ${PKTOOLS_IMAGECLASSES_LIB_NAME} ${PKTOOLS_FILECLASSES_LIB_NAME} ${PKTOOLS_ALGORITHMS_LIB_NAME} ${GDAL_LIBRARIES} ${GSL_LIBRARIES} ${Boost_LIBRARIES})

set(PKUTILITIES
  pkinfo
  pkcrop
  pkdiff
  pkgetmask
  pksetmask
  pkcreatect
  pkdumpimg
  pkdumpogr
  pksieve
  pkstat
  pkstatascii
  pkstatogr
  pkstatprofile
  pkegcs
  pkextractimg
  pkextractogr
  pkfillnodata
  pkfilter
  pkfilterdem
  pkfilterascii
  pkdsm2shadow
  pkcomposite
  pkpolygonize
  pkascii2img
  pksvm
  pksvmogr
  pkfssvm
  pkoptsvm
  pkascii2ogr
  pkreclass
  pkreclassogr
  pkkalman
  )

set(PKLASUTILITIES
	pklas2img
)

set(PKFANNUTILITIES
	pkann
	pkannogr
	pkfsann
	pkregann
)

# set(PKNLOPTUTILITIES
# 	pkoptsvm
# )

if (PKTOOLS_WITH_UTILITIES)
	foreach(UTILITY ${PKUTILITIES})
    add_executable(${UTILITY} src/apps/${UTILITY}.cc)
    target_link_libraries(${UTILITY} ${PKLIBS})
    set_target_properties(${UTILITY} PROPERTIES FOLDER utilities)
	endforeach()

	if (BUILD_WITH_LIBLAS)
		set(PKLIBS ${PKLIBS} ${PKTOOLS_LASCLASSES_LIB_NAME})
		foreach(PKLASUTILITY ${PKLASUTILITIES})
		  add_executable(${PKLASUTILITY} src/apps/${PKLASUTILITY}.cc)
		  target_link_libraries (${PKLASUTILITY} 
		    ${PKLIBS} ${LIBLAS_LIBRARIES})
    	set_target_properties(${PKLASUTILITY} PROPERTIES FOLDER utilities)
		endforeach()
	endif()
	if (BUILD_WITH_FANN)
		set(PKLIBS ${PKLIBS} ${FANN_LIBRARIES})
		foreach(PKFANNUTILITY ${PKFANNUTILITIES})
		  add_executable(${PKFANNUTILITY} src/apps/${PKFANNUTILITY}.cc)
		  # message(${PKLIBS})
		  target_link_libraries (${PKFANNUTILITY} ${PKLIBS})
      set_target_properties(${PKFANNUTILITY} PROPERTIES FOLDER utilities)
	  endforeach()
	endif()
	# if (BUILD_WITH_NLOPT)
	# 	set(PKLIBS ${PKLIBS} ${NLOPT_LIBRARIES})
	# 	foreach(PKNLOPTUTILITY ${PKNLOPTUTILITIES})
	# 	add_executable(${PKNLOPTUTILITY} src/apps/${PKNLOPTUTILITY}.cc)
	# 	message(${PKLIBS})
	# 	target_link_libraries (${PKNLOPTUTILITY} ${PKLIBS})
    	# 	set_target_properties(${PKNLOPTUTILITY} PROPERTIES FOLDER utilities)
	# 	endforeach()
	# endif()
	# add_custom_target(utilities DEPENDS ${PKUTILITIES} ${PKLASUTILITIES} ${PKFANNUTILITIES} ${PKNLOPTUTILITIES})
	add_custom_target(utilities DEPENDS ${PKUTILITIES} ${PKLASUTILITIES} ${PKFANNUTILITIES})
	set_target_properties(utilities PROPERTIES FOLDER
	phony)

endif()


###############################################################################

###############################################################################
# Installation
#install (FILES "${PROJECT_BINARY_DIR}/pktools-config" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
#install (FILES "${PROJECT_BINARY_DIR}/pktools-config" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
#test
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/pktools-config" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install (FILES "pktools.pc" DESTINATION ${INSTALL_LIBRARY_DIR}/pkgconfig PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)


if (PKTOOLS_WITH_UTILITIES)
	install (TARGETS ${PKUTILITIES} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
	if (BUILD_WITH_LIBLAS)
		install (TARGETS ${PKLASUTILITIES} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
	endif(BUILD_WITH_LIBLAS)
	if (BUILD_WITH_FANN)
		install (TARGETS ${PKFANNUTILITIES} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
	endif(BUILD_WITH_FANN)
	# if (BUILD_WITH_NLOPT)
	# 	install (TARGETS ${PKNLOPTUTILITIES} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
	# endif(BUILD_WITH_NLOPT)
endif(PKTOOLS_WITH_UTILITIES)

###############################################################################

###############################################################################
# Create Distribution
SET(CPACK_SOURCE_GENERATOR "TGZ;ZIP;TBZ2")
SET(CPACK_CMAKE_GENERATOR "Unix Makefiles")

set(CPACK_SOURCE_PACKAGE_FILE_NAME
  "${CMAKE_PROJECT_NAME}-${PKTOOLS_VERSION_MAJOR}.${PKTOOLS_VERSION_MINOR}.${PKTOOLS_VERSION_PATCH}")

# Set files to ignore
list(APPEND CPACK_SOURCE_IGNORE_FILES "_CPack_Packages")
list(APPEND CPACK_SOURCE_IGNORE_FILES ".gz")
list(APPEND CPACK_SOURCE_IGNORE_FILES ".bz2")
list(APPEND CPACK_SOURCE_IGNORE_FILES ".zip")
list(APPEND CPACK_SOURCE_IGNORE_FILES ".svn")
list(APPEND CPACK_SOURCE_IGNORE_FILES ".git")
list(APPEND CPACK_SOURCE_IGNORE_FILES "README")
list(APPEND CPACK_SOURCE_IGNORE_FILES "HOWTORELEASE.txt")
list(APPEND CPACK_SOURCE_IGNORE_FILES "CMakeCache.txt")
list(APPEND CPACK_SOURCE_IGNORE_FILES "CPackConfig.cmake")
list(APPEND CPACK_SOURCE_IGNORE_FILES "schemas")
list(APPEND CPACK_SOURCE_IGNORE_FILES "/build/;~$;${CPACK_SOURCE_IGNORE_FILES}")

include(CPack)

add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
###############################################################################