WSL/SLF GitLab Repository

CMakeLists.txt 20.7 KB
Newer Older
1
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
2
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/tools/cmake/")
3

4
PROJECT(meteoio)
5
6
# Version of library
SET(VERSION_MAJOR 2 CACHE INTERNAL "")
7
SET(VERSION_MINOR 5 CACHE INTERNAL "")
8
SET(VERSION_PATCH 1 CACHE INTERNAL "")
9
10
11

SET(LIBPREFIX "lib") #make sure ALL plugins are libXXX for ALL plateforms
SET(CMAKE_IMPORT_LIBRARY_PREFIX "lib") #for Visual C++ import libraries
12
13

###########################################################
14
#platform specific. First, compiler specific flags, then system specific flags
15
16
17
18
19
20
OPTION(BUILD_SHARED_LIBS "Set to ON to build dynamic libraries" ON)
IF(WIN32)
	SET(BUILD_STATIC_LIBS ON) #otherwise the lib files are not generated
ELSE(WIN32)
	OPTION(BUILD_STATIC_LIBS "Set to ON to build static libraries" OFF)
ENDIF(WIN32)
21
INCLUDE("${CMAKE_SOURCE_DIR}/tools/cmake/BuildVersion.cmake")
22
BuildVersion()
23

24
IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
25
	#SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "limited configs"  FORCE)
26
	SET(WARNINGS "/W4 /D_CRT_SECURE_NO_WARNINGS /EHsc") #Za: strict ansi EHsc: handle c++ exceptions
27
28
29
30
31
32
	#SET(EXTRA_WARNINGS "/Wp64") #/Wall
	SET(OPTIM "/O2 /DNDEBUG /MD /DNOSAFECHECKS")
	SET(ARCH_OPTIM "/arch:SSE2")
	SET(ARCH_SAFE "")
	SET(DEBUG "/Z7 /Od /D__DEBUG /MDd")
	SET(_VERSION "/D_VERSION=\\\"${_versionString}\\\"")
33
34
35
	IF(BUILD_SHARED_LIBS)
		ADD_DEFINITIONS(/DMIO_DLL)
	ENDIF(BUILD_SHARED_LIBS)
36
37
38
	IF(GUI_EXCEPTIONS)
		SET(MSG_BOX "/DMESG_BOX")
	ENDIF(GUI_EXCEPTIONS)
39
ELSE()
40
	#we consider that all other compilers support "-" options and silently ignore what they don't know
41
	SET(WARNINGS "-Wall -Wno-long-long  -Wswitch")
Mathias Bavay's avatar
Mathias Bavay committed
42
	SET(DEEP_WARNINGS "-Wunused-value -Wshadow -Wpointer-arith -Wconversion -Winline -Wdisabled-optimization -Wctor-dtor-privacy") #-Wfloat-equal -Wpadded
43
44
	SET(EXTRA_WARNINGS "-Wextra -pedantic -Weffc++ ${DEEP_WARNINGS}")
	SET(OPTIM "-g -O3 -DNDEBUG -DNOSAFECHECKS")
45
46
47
	IF("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "AMD64")
		SET(ARCH_SAFE  "-march=nocona -mtune=nocona")
	ENDIF()
48
	SET(DEBUG "-g3 -O0 -D__DEBUG")
49
	SET(_VERSION "-D_VERSION=\\\"${_versionString}\\\"")
50
51
52
	#IF(BUILD_SHARED_LIBS)
	#	ADD_DEFINITIONS(-DMIO_DLL)
	#ENDIF(BUILD_SHARED_LIBS)
53
54

	IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
55
		SET(PROFILING "-pg -fprofile-arcs") #add ${PROFILING} to the CFLAGS when necessary
Mathias Bavay's avatar
Mathias Bavay committed
56
		SET(EXTRA_WARNINGS "${EXTRA_WARNINGS} -Wunsafe-loop-optimizations -Wvector-operation-performance")
57
58
59
60
61
62
63
64
65
66
67
68
		IF(NOT ANDROID)
			SET(EXTRA_WARNINGS "${EXTRA_WARNINGS} -ansi")
			IF(WIN32) #for gcc on windows
				SET(CMAKE_SHARED_LINKER_FLAGS "--enable-auto-import")
				SET(CMAKE_EXE_LINKER_FLAGS "--enable-auto-import")
			ENDIF(WIN32)
		ENDIF(NOT ANDROID)
		EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
		IF(GCC_VERSION VERSION_GREATER 4.2 OR GCC_VERSION VERSION_EQUAL 4.2)
			SET(ARCH_OPTIM  "-march=native -mtune=native")
		ENDIF()
		IF(GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
69
70
71
			IF(NOT WIN32)
				SET(OPTIM "${OPTIM} -flto") #for gcc>4.5, but first implementations were slow, so it is safe to enforce 4.8
			ENDIF(NOT WIN32)
72
			# if set to ON, all binaries depending on the library have to be compiled the same way.
73
			#Then, do an "export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.4" and run with "ASAN_OPTIONS=symbolize=1"
74
			SET(LEAKS_CHECK OFF CACHE BOOL "Set to ON to dynamically check for memory corruption (and do the same for applications linked with MeteoIO)")
75
76
77
78
			IF (LEAKS_CHECK)
				SET(EXTRA "${EXTRA} -fsanitize=address -fno-omit-frame-pointer")
			ENDIF(LEAKS_CHECK)
		ENDIF()
79
80
81
82
83
	ENDIF()
	IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
		SET(PROFILING "-pg") #add ${PROFILING} to the CFLAGS when necessary
		SET(EXTRA "${EXTRA} -fcolor-diagnostics") #-fapple-pragma-pack does not seems necessary; -ftrapv should be replaced by sanitize=integer
		SET(OPTIM "${OPTIM} -flto")
84
		SET(WARNINGS "${WARNINGS} -Weverything -Wno-date-time -Wno-float-equal -Wno-documentation -Wno-documentation-unknown-command -Wno-old-style-cast -Wno-padded -Wno-missing-noreturn -Wno-weak-vtables -Wno-switch-enum") #obviously, we should try to fix the warnings! Keeping in mind that some of these W are half buggy...
85
86
87
88
89
90
91
92
93
		SET(DEEP_WARNINGS "${DEEP_WARNINGS} -Rpass=.*")
		SET(LEAKS_CHECK OFF CACHE BOOL "Set to ON to dynamically check for memory corruption (and do the same for applications linked with MeteoIO)")
			IF (LEAKS_CHECK)
				SET(EXTRA "${EXTRA} -ftrapv -fno-omit-frame-pointer") #-fsanitize=address,undefined,integer,undefined-trap but this is currently not supported by Apple
			ENDIF(LEAKS_CHECK)
		SET(ARCH_OPTIM  "-march=native")
	ENDIF()

ENDIF()
94

95
96
#The following pre-processor variables are automatically defined:
# __linux, __GNUC__, __CYGWIN__, _WIN32, __MINGW32__, __APPLE__
97
98
IF(UNIX)
	IF(APPLE)
99
		SET(DLL_EXT "dylib*")
100
		SET(STAT_EXT "a")
101
102
		SET(EXTRA_WARNINGS "${EXTRA_WARNINGS} -Wno-sign-conversion") #for now, keep clang quiet
		SET(CMAKE_SHARED_LINKER_FLAGS "-framework CoreFoundation")
103
104
		#set(CMAKE_OSX_SYSROOT iphoneos2.2.1) #for IOS
		#set(CMAKE_OSX_ARCHITECTURES $(ARCHS_STANDARD_32_BIT)) #for IOS
105

106
107
		#set a full rpath for both build & install tree
		SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
108
		SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
109
110
111
112
113
		SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")

		# add the automatically determined parts of the RPATH
		# which point to directories outside the build tree to the install RPATH
		SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
114

115
116
117
118
119
		# the RPATH to be used when installing, but only if it's not a system directory
		LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
		IF("${isSystemDir}" STREQUAL "-1")
			SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
		ENDIF("${isSystemDir}" STREQUAL "-1")
120
	ELSE(APPLE)
121
		SET(DLL_EXT "so*")
122
		SET(STAT_EXT "a")
123
124
125
	ENDIF(APPLE)
ELSE(UNIX)
	IF(WIN32)
126
127
		SET(DLL_EXT "dll")
		SET(STAT_EXT "a")
128
129
130
	ENDIF(WIN32)
ENDIF(UNIX)

131
IF(NOT CMAKE_BUILD_TYPE)
132
	SET(CMAKE_BUILD_TYPE "release" CACHE STRING "Choose the type of build, options are: debug release coverage cxxflags" FORCE)
133
134
	SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE})
ENDIF(NOT CMAKE_BUILD_TYPE)
135
136

###########################################################
137
138
#targets providing SETs of compiler options
IF(NOT DEST)
139
	SET(DEST "safe" CACHE STRING "Choose safe or optimized" FORCE)
140
ENDIF(NOT DEST)
141

142
143
144
IF (DEST STREQUAL "safe")
	SET(ARCH  "${ARCH_SAFE}")
ENDIF(DEST STREQUAL "safe")
145
146

IF(DEST STREQUAL "optimized")
147
	SET(ARCH  "${ARCH_OPTIM}")
148
149
ENDIF(DEST STREQUAL "optimized")

150
151
#show exception messages in a graphical message box
SET(GUI_EXCEPTIONS OFF CACHE BOOL "Show a message box with exceptions texts ON or OFF")
152

153
###########################################################
154
#finally, SET compile flags
155

156
SET(CMAKE_CXX_FLAGS "${_VERSION} ${ARCH} ${EXTRA}" CACHE STRING "" FORCE)
157
158
SET(CMAKE_CXX_FLAGS_RELEASE "${OPTIM}" CACHE STRING "" FORCE)
SET(CMAKE_CXX_FLAGS_DEBUG "${DEBUG} ${WARNINGS} ${EXTRA_WARNINGS}" CACHE STRING "" FORCE)
159
160
SET(CMAKE_CXX_FLAGS_CXXFLAGS "$ENV{CXXFLAGS}" CACHE STRING "" FORCE)
MARK_AS_ADVANCED(FORCE CMAKE_CXX_FLAGS_CXXFLAGS)
161
162

#Add subdirectory, so they can inherit all variables defined above
163
ADD_SUBDIRECTORY(meteoio/dataClasses)
164
ADD_SUBDIRECTORY(meteoio/plugins)
165
166
ADD_SUBDIRECTORY(meteoio/meteoLaws)
ADD_SUBDIRECTORY(meteoio/meteoFilters)
167
ADD_SUBDIRECTORY(meteoio)
168
169
###########################################################
#plugins
170
SET(PLUGIN_A3DIO ON CACHE BOOL "Compilation A3DIO ON or OFF")
Mathias Bavay's avatar
Mathias Bavay committed
171
SET(PLUGIN_ALPUG ON CACHE BOOL "Compilation ALPUG ON or OFF")
172
173
174
SET(PLUGIN_ARCIO ON CACHE BOOL "Compilation ARCIO ON or OFF")
SET(PLUGIN_ARPSIO ON CACHE BOOL "Compilation ARPSIO ON or OFF")
SET(PLUGIN_BORMAIO OFF CACHE BOOL "Compilation BORMAIO ON or OFF")
175
SET(PLUGIN_CNRMIO OFF CACHE BOOL "Compilation CNRMIO ON or OFF")
176
SET(PLUGIN_COSMOXMLIO OFF CACHE BOOL "Compilation COSMOXMLIO ON or OFF")
177
178
SET(PLUGIN_GEOTOPIO ON CACHE BOOL "Compilation GEOTOPIO ON or OFF")
SET(PLUGIN_GRASSIO ON CACHE BOOL "Compilation GRASSIO ON or OFF")
179
SET(PLUGIN_GRIBIO OFF CACHE BOOL "Compilation GRIBIO ON or OFF")
180
SET(PLUGIN_GSNIO OFF CACHE BOOL "Compilation GSNIO ON or OFF")
181
SET(PLUGIN_IMISIO OFF CACHE BOOL "Compilation IMISIO ON or OFF")
182
SET(PLUGIN_NETCDFIO OFF CACHE BOOL "Compilation NETCDFIO ON or OFF")
183
184
SET(PLUGIN_PGMIO ON CACHE BOOL "Compilation PGMIO ON or OFF")
SET(PLUGIN_PNGIO OFF CACHE BOOL "Compilation PNGIO ON or OFF")
185
SET(PLUGIN_PSQLIO OFF CACHE BOOL "Compilation PSQLIO ON or OFF")
186
187
SET(PLUGIN_SMETIO ON CACHE BOOL "Compilation SMETIO ON or OFF")
SET(PLUGIN_SNIO ON CACHE BOOL "Compilation SNIO ON or OFF")
188
SET(PLUGIN_SASEIO OFF CACHE BOOL "Compilation SASEIO ON or OFF")
189
SET(PROJ4 OFF CACHE BOOL "Use PROJ4 for the class MapProj ON or OFF")
190
SET(DATA_QA OFF CACHE BOOL "Data Quality Assurance outputs ON or OFF")
191

192
193
###########################################################
#for the install target
194
FILE(GLOB hfiles "meteoio/*.h")
195
FILE(GLOB hdatafiles "meteoio/dataClasses/*.h")
196
FILE(GLOB hpluginfiles "meteoio/plugins/*.h")
197
198
199
200
201
202
FILE(GLOB hlawsfiles "meteoio/meteoLaws/*.h")
FILE(GLOB hfilterfiles "meteoio/meteoFilters/*.h")
FILE(GLOB hstatsfiles "meteoio/meteoStats/*.h")

INSTALL(FILES ${hfiles} DESTINATION include/meteoio COMPONENT headers)
INSTALL(FILES ${hdatafiles} DESTINATION include/meteoio/dataClasses COMPONENT headers)
203
INSTALL(FILES ${hpluginfiles} DESTINATION include/meteoio/plugins COMPONENT headers)
204
205
206
INSTALL(FILES ${hlawsfiles} DESTINATION include/meteoio/meteoLaws COMPONENT headers)
INSTALL(FILES ${hfilterfiles} DESTINATION include/meteoio/meteoFilters COMPONENT headers)
INSTALL(FILES ${hstatsfiles} DESTINATION include/meteoio/meteoStats COMPONENT headers)
207

208
ADD_CUSTOM_TARGET(distclean make clean
209
	COMMAND cmake -E remove CMakeCache.txt CPackSourceConfig.cmake CPackConfig.cmake CTestTestfile.cmake DartConfiguration.tcl cmake_install.cmake cmake_uninstall.cmake install_manifest.txt Makefile
210
	COMMAND cmake -E remove "lib/libmeteo*.${DLL_EXT}" "lib/libmeteo*.${STAT_EXT}" "lib/libmeteo*.lib"
211
212
	COMMAND cmake -E remove */CMakeCache.txt */CTestTestfile.cmake */cmake_install.cmake
	COMMAND cmake -E remove */*/CMakeCache.txt */*/CTestTestfile.cmake */*/cmake_install.cmake
213
	COMMAND cmake -E remove_directory CMakeFiles
214
	COMMAND cmake -E remove_directory Testing
215
	COMMAND cmake -E remove_directory meteoio/CMakeFiles
216
217
218
	COMMAND cmake -E remove_directory meteoio/dataClasses/CMakeFiles
	COMMAND cmake -E remove_directory meteoio/meteoFilters/CMakeFiles
	COMMAND cmake -E remove_directory meteoio/meteoLaws/CMakeFiles
219
	COMMAND cmake -E remove_directory meteoio/plugins/gsn/CMakeFiles
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
	COMMAND cmake -E remove_directory meteoio/plugins/CMakeFiles
	COMMAND cmake -E remove_directory tests/CMakeFiles
	COMMAND cmake -E remove_directory tests/Testing
	COMMAND cmake -E remove_directory tests/meteo_reading_interpol/CMakeFiles
	COMMAND cmake -E remove_directory tests/meteo_reading_interpol/Testing
	COMMAND cmake -E remove_directory tests/meteo_reading_no_interpol/CMakeFiles
	COMMAND cmake -E remove_directory tests/meteo_reading_no_interpol/Testing
	COMMAND cmake -E remove_directory tests/sun/CMakeFiles
	COMMAND cmake -E remove_directory tests/sun/Testing
	COMMAND cmake -E remove tests/sun/generated_results.txt
	COMMAND cmake -E remove_directory tests/dem_reading/CMakeFiles
	COMMAND cmake -E remove_directory tests/dem_reading/Testing
	COMMAND cmake -E remove tests/dem_reading/AZI.asc tests/dem_reading/DEM.asc tests/dem_reading/SLOPE.asc
	COMMAND cmake -E remove_directory tests/2D_interpolations/CMakeFiles
	COMMAND cmake -E remove_directory tests/2D_interpolations/Testing
	COMMAND cmake -E remove tests/2D_interpolations/2009-01-19T12.00_HNW.asc tests/2D_interpolations/2009-01-19T12.00_RH.asc tests/2D_interpolations/2009-01-19T12.00_RSWR.asc tests/2D_interpolations/2009-01-19T12.00_TA.asc
)

238
239
240
###########################################################
#for the uninstall target
CONFIGURE_FILE(
241
242
243
	"${PROJECT_SOURCE_DIR}/tools/cmake/cmake_uninstall.cmake.in"
	"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
	IMMEDIATE @ONLY)
244

245
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
246
247

#Build the documentation if doxygen is found
248
INCLUDE(FindDoxygen)
249
250
FIND_PACKAGE(Doxygen)
if (DOXYGEN_FOUND)
251
	ADD_CUSTOM_TARGET(doc "doxygen" ${PROJECT_SOURCE_DIR}/meteoio/config.dox)
252
ENDIF (DOXYGEN_FOUND)
253
#Install the documentation if the user desires it
254
255
256
257
258
259
260
SET(INSTALL_DOC OFF CACHE BOOL "Install documentation ON or OFF")
IF(INSTALL_DOC)
	IF(WIN32)
		SET(DOC_PATH "doc")
	ELSE(WIN32)
		SET(DOC_PATH "share/doc/${CMAKE_PROJECT_NAME}")
	ENDIF(WIN32)
261
	SET(DOC_FILES License.txt meteoio/icons/icon.ico doc/SMET_specifications.pdf)
262
263
	IF (DOXYGEN_FOUND)
		INSTALL(DIRECTORY doc/html DESTINATION ${DOC_PATH} COMPONENT documentation)
264
		LIST(APPEND DOC_FILES doc/MeteoIO_doc.html)
265
266
267
	ELSE (DOXYGEN_FOUND)
		MESSAGE("Doxygen has not been found and is needed to build online documentation. Please either install doxygen or download a documentation-only package!")
	ENDIF (DOXYGEN_FOUND)
268

269
	INSTALL(FILES ${DOC_FILES} DESTINATION ${DOC_PATH} COMPONENT documentation)
Mathias Bavay's avatar
Mathias Bavay committed
270
	INSTALL(DIRECTORY "doc/examples" DESTINATION ${DOC_PATH} COMPONENT examples PATTERN ".svn" EXCLUDE)
271
ENDIF(INSTALL_DOC)
272

273
274
###########################################################
## CPACK section
275
###########################################################
276
277
SET(CPACK_PACKAGE_DESCRIPTION "Meteorological preprocessing library")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Meteorological Input/Output preprocessing library: it covers data retrieval, data filtering, data transformations and spatial interpolations. Please refer to the included documentation and the included code examples!")
278
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/Welcome.txt")
279
SET(CPACK_PACKAGE_NAME "MeteoIO")
280
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "MeteoIO")
281
SET(CPACK_PACKAGE_CONTACT "Mathias Bavay <Mathias.Bavay@wsl.ch>")
282
283
284
SET(CPACK_PACKAGE_VENDOR "WSL Institute for Snow and Avalanche Research")
SET(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/meteoio/icons\\\\icon.ico")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/License.txt")
285
286
SET(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/Welcome.txt")
SET(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/Readme.txt")
287
288
289
290
291

SET(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
SET(VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
292
293
SET(CPACK_ARCH "${CMAKE_SYSTEM_PROCESSOR}")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${VERSION}-${CPACK_ARCH}")
294
295

#installation by components for formats that support it
296
#SET(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE 1)
297
SET(CPACK_COMPONENTS_ALL libraries headers documentation examples)
298
299
300
301
302
303
304
SET(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "MeteoIO library")
SET(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "The MeteoIO library itself")
SET(CPACK_COMPONENT_LIBRARIES_GROUP Runtime)
SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "Header files")
SET(CPACK_COMPONENT_HEADERS_DESCRIPTION "Necessary C++ header files for developing applications using MeteoIO")
SET(CPACK_COMPONENT_HEADERS_GROUP Development)
SET(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
305
306
307
IF(INSTALL_DOC)
	SET(CPACK_COMPONENT_DOCUMENTATION_DISPLAY_NAME "Documentation")
	SET(CPACK_COMPONENT_DOCUMENTATION_DESCRIPTION "Documentation of the MeteoIO usage and API both for the end user and the developer using MeteoIO in his/her application")
308
	SET(CPACK_COMPONENT_DOCUMENTATION_GROUP Docs)
309
310
311
	SET(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Examples")
	SET(CPACK_COMPONENT_EXAMPLES_DESCRIPTION "C++ Source code of various simple examples of applications with their example data")
	SET(CPACK_COMPONENT_EXAMPLES_DEPENDS libraries headers)
312
313
314
	SET(CPACK_COMPONENT_EXAMPLES_GROUP Docs)
	SET(CPACK_COMPONENT_DOCS_GROUP "Documentation")
	SET(CPACK_COMPONENT_GROUP_DOCS_DESCRIPTION "How to use MeteoIO as an end user and as a developer")
315
ENDIF(INSTALL_DOC)
316
317
318
319
320

SET(CPACK_COMPONENT_RUNTIME_GROUP "Runtime")
SET(CPACK_COMPONENT_GROUP_RUNTIME_DESCRIPTION "What you need to run an application based on MeteoIO")
SET(CPACK_COMPONENT_DEVELOPMENT_GROUP "Development")
SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION "What you need to develop an application based on MeteoIO")
321

322
323
IF(UNIX)
	IF(APPLE)
324
325
326
327
328
329
		SET(CPACK_GENERATOR "DragNDrop")
		SET(CPACK_PACKAGING_INSTALL_PREFIX "/${CPACK_PACKAGE_NAME}")
		SET(CPACK_DMG_FORMAT "UDBZ")
		#SET(CPACK_GENERATOR "Bundle")
		SET(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/tools/meteoio.plist")
		SET(MACOSX_BUNDLE_INFO_STRING "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
330
		SET(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/meteoio/icons/icon.icns")
331
332
333
334
335
336
337
338
339
340
		SET(MACOSX_BUNDLE_ICON_FILE "${CPACK_BUNDLE_ICON}")
		SET(MACOSX_BUNDLE_GUI_IDENTIFIER "${CPACK_PACKAGE_DESCRIPTION}")
		SET(MACOSX_BUNDLE_LONG_VERSION_STRING "${VERSION}")
		SET(CPACK_BUNDLE_NAME "${CPACK_PACKAGE_NAME}")
		SET(MACOSX_BUNDLE_BUNDLE_NAME "${CPACK_PACKAGE_NAME}")
		SET(MACOSX_BUNDLE_SHORT_VERSION_STRING "${VERSION}")
		SET(MACOSX_BUNDLE_BUNDLE_VERSION "0")
		SET(MACOSX_BUNDLE_COPYRIGHT "${CPACK_PACKAGE_VENDOR}")
		#SET(CPACK_PACKAGING_INSTALL_PREFIX "/Applications/${CPACK_PACKAGE_NAME}")
		SET(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/meteoio/icons/icon.icns")
341
		SET_SOURCE_FILES_PROPERTIES(${CPACK_BUNDLE_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
342
	ELSE(APPLE)
343
		SET(CPACK_GENERATOR "DEB;RPM;TGZ")
344
		SET(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
345
346
		SET(CPACK_DEBIAN_PACKAGE_NAME "meteoio")
		SET(CPACK_DEBIAN_PACKAGE_SECTION "devel")
347
		SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libstdc++6") #objdump -p lib/libmeteoio.so | grep NEEDED | tr -s ' ' | cut -d' ' -f3 | tr '\n' ','
348
349
350
351
352
353
		#SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386") #dpkg --print-architecture
		IF("${CPACK_ARCH}" STREQUAL "x86_64")
			SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
		ELSE("${CPACK_ARCH}" STREQUAL "x86_64")
			SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_ARCH}")
		ENDIF("${CPACK_ARCH}" STREQUAL "x86_64")
354
355
		SET(CPACK_RPM_PACKAGE_NAME "meteoio")
		SET(CPACK_RPM_PACKAGE_LICENSE "LPGLv3")
356
		SET(CPACK_RPM_PACKAGE_REQUIRES "libstdc++6") #simply libproj for OpenSuse
357
		SET(CPACK_RPM_PACKAGE_ARCHITECTURE "${CPACK_ARCH}")
358
		SET(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
359
360
361
	ENDIF(APPLE)
ELSE(UNIX)
	IF(WIN32)
362
363
		SET(CPACK_GENERATOR "NSIS")
		SET(CPACK_NSIS_MUI_ICON "${CPACK_PACKAGE_ICON}")
364
		SET(CPACK_PACKAGE_ICON "${CPACK_PACKAGE_ICON}")
365
		SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
Mathias Bavay's avatar
Mathias Bavay committed
366
		SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME}")
367
368
369
370
		IF(INSTALL_DOC)
			SET(CPACK_NSIS_MENU_LINKS
				"${DOC_PATH}/MeteoIO_doc.html" "MeteoIO documentation"
				"${DOC_PATH}/examples" "MeteoIO examples"
371
				"https://models.slf.ch/p/meteoio/" "MeteoIO Home page")
372
373
		ELSEIF(INSTALL_DOC)
			SET(CPACK_NSIS_MENU_LINKS
374
				"https://models.slf.ch/p/meteoio/" "MeteoIO Home page")
375
		ENDIF(INSTALL_DOC)
376
		#info for the add/uninstall software administration
377
		SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_NAME}-${VERSION}")
378
		SET(CPACK_NSIS_INSTALLED_ICON_NAME "doc\\\\icon.ico")
379
		SET(CPACK_NSIS_URL_INFO_ABOUT "http://www.slf.ch")
380
381
		SET(CPACK_NSIS_HELP_LINK "https://models.slf.ch/p/meteoio")
		SET(CPACK_NSIS_CONTACT "${CPACK_PACKAGE_CONTACT}")
382
		SET(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
383
384
385
386
	ENDIF(WIN32)
ENDIF(UNIX)


387
388
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${VERSION}" CACHE INTERNAL "tarball basename")
SET(CPACK_SOURCE_GENERATOR TGZ)
389
390
391
# The following components are regex's to match anywhere (unless anchored)
# in absolute path + filename to find files or directories to be excluded
# from source tarball.
392
SET(CPACK_SOURCE_IGNORE_FILES
393
394
395
396
397
398
399
400
401
402
403
404
405
	"~$"
	"\\\\.svn/"
	"/CMakeFiles/"
	"/CMakeCache*"
	"/cmake_install\\\\.cmake$"
	"/cmake_uninstall\\\\.cmake$"
	"^_CPack_.*/"
	"/CPack*"
	"\\\\.o$"
	"/m4/"
)

INCLUDE(CPack)
406
407
408
409
410
411
412
413

###########################################################
## CTest section
###########################################################

## Special build type configuration for Covarage Testing.
# Attantion: Coverage testing right now only works with g++ (or comercial tools)
## Add the tests itselfs
414
OPTION(BUILD_TESTING "Build the tests" OFF)
415
416
417
418
IF(BUILD_TESTING)

	# Coverage statistic rign now only supportet with GCC (GNUGXX)
	IF(CMAKE_COMPILER_IS_GNUCXX)
419
		OPTION(BUILD_TESTING_WITH_COVERAGE "Use gcc flags to make coverage tests" OFF)
420

421
422
423
424
		IF(BUILD_TESTING_WITH_COVERAGE)
			# force the correct flags to make coverage trought a build type
			SET(CMAKE_BUILD_TYPE coverage)
			SET(CMAKE_CXX_FLAGS_COVERAGE "-Wall -O0 -ftest-coverage -fprofile-arcs" CACHE STRING "" FORCE)
425
			MARK_AS_ADVANCED(FORCE CMAKE_CXX_FLAGS_COVERAGE)
426

427
428
429
			# Force debug mode, so that no optimisation is made to get "Correct" results of coverage testing
			SET(CMAKE_BUILD_TYPE "coverage" CACHE STRING "Choose the type of build, options are: debug release coverage " FORCE)
			SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE})
430

431
432
433
434
435
436
		ENDIF(BUILD_TESTING_WITH_COVERAGE)
	ENDIF(CMAKE_COMPILER_IS_GNUCXX)

	INCLUDE(CTest) # This makes ENABLE_TESTING() and gives support for Dashboard
	ADD_SUBDIRECTORY(tests)
ENDIF(BUILD_TESTING)