source: CMakeLists.txt

Last change on this file was 2db0d31, checked in by www-data <www-data@…>, 5 weeks ago

ticket:000 - update version to 9.5

  • Property mode set to 100644
File size: 14.9 KB
Line 
1# This file is part of rasdaman community.
2#
3# Rasdaman community is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation, either version 3 of the License, or
6# (at your option) any later version.
7#
8# Rasdaman community is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with rasdaman community.  If not, see <http://www.gnu.org/licenses/>.
15#
16# Copyright 2003 - 2016 Peter Baumann /
17# rasdaman GmbH.
18#
19# For more information please see <http://www.rasdaman.org>
20# or contact Peter Baumann via <baumann@rasdaman.com>.
21#
22
23cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
24
25#Set cmake policies for compatibility
26cmake_policy(SET CMP0012 NEW)
27cmake_policy(SET CMP0009 NEW)
28cmake_policy(SET CMP0048 NEW)
29
30project(rasdaman VERSION 9.5.0
31        LANGUAGES C CXX)
32
33# no rebuild dependency when make install
34# https://cmake.org/Wiki/CMake_Useful_Variables#Various_Options
35set(CMAKE_SKIP_RULE_DEPENDENCY TRUE)
36set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)
37
38################################################################################
39# CMake configuration options
40################################################################################
41# This sets the folder from which cmake modules can be loaded.
42# When find_package(X) is called, the module path is search of a FindX.cmake
43SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
44SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH})
45
46set(CMAKE_VERBOSE_OUTPUT OFF CACHE BOOL "Enable  this if you need detailed output from the make process.")
47if (CMAKE_VERBOSE_OUTPUT)
48    set(CMAKE_VERBOSE_MAKEFILE ON)
49endif ()
50
51################################################################################
52# Override CMake defaults
53################################################################################
54# Override the default installation directory
55if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
56    set(CMAKE_INSTALL_PREFIX "/opt/rasdaman" CACHE PATH "Installation directory." FORCE)
57endif ()
58
59# Add make unit-check target. Running make unit-check will run the unit tests.
60include(CTest)
61add_custom_target(unit-check COMMAND ${CMAKE_CTEST_COMMAND})
62
63# Add make format target. This will format all the files in the source tree.
64include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ExtraTargets.cmake)
65AddFormatTarget("${CMAKE_SOURCE_DIR}/third_party" "*.cc *.hh")
66
67include(CheckLibraryExists)
68
69# Include the custom functions and macros so that they are available in the subdirs
70include(cmake/Functions.cmake)
71
72# Check for functions and symbols needed by rasdaman
73include(cmake/CheckForRequiredSymbols.cmake)
74
75# Options for selecting the network protocol
76set(NETWORK_PROTOCOL rasnet CACHE STRING "Set the network protocol used in rasdaman (rasnet or rnp).")
77set_property(CACHE NETWORK_PROTOCOL PROPERTY STRINGS rasnet rnp)
78
79# Enable C++11 for rasnet.
80include(CheckCXXCompilerFlag)
81
82CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
83CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
84if (COMPILER_SUPPORTS_CXX11)
85    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
86elseif (COMPILER_SUPPORTS_CXX0X)
87    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
88else ()
89    message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
90endif ()
91
92message("Building rasdaman with the ${NETWORK_PROTOCOL} protocol.")
93if (${NETWORK_PROTOCOL} STREQUAL rasnet)
94    set(RMANRASNET 1)
95    set(DISABLE_PROTOBUF_WARNINGS_FLAGS " -Wno-sign-conversion -Wno-shadow -Wno-pedantic -Wno-undef ")   
96else ()
97    set(RMANRASNET 0)
98endif ()
99
100set(USE_HDF4 OFF CACHE BOOL "This feature enables the inclusion of HDF4 library during installation.")
101if (USE_HDF4)
102    # Flag used in config-cmake.h
103    set(HAVE_HDF ON)
104endif ()
105
106set(USE_NETCDF OFF CACHE BOOL "This feature enables the inclusion of netCDF library during installation.")
107if (USE_NETCDF)
108    # Flag used in config-cmake.h
109    set(HAVE_NETCDF ON)
110endif ()
111
112set(USE_GDAL ON CACHE BOOL "This feature enables the inclusion of GDAL library during installation.")
113if (USE_GDAL)
114    # Flag used in config-cmake.h
115    set(HAVE_GDAL ON)
116endif ()
117
118set(USE_GRIB OFF CACHE BOOL "This feature enables the inclusion of GRIB library during installation.")
119if (USE_GRIB)
120    # Flag used in config-cmake.h
121    set(HAVE_GRIB ON)
122endif ()
123
124set(GENERATE_PIC ON CACHE BOOL "Generate position independent code (PIC)")
125if (GENERATE_PIC)
126    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
127    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
128endif ()
129
130set(PETASCOPEDB "postgresql" CACHE STRING "Default DBMS used by petascope is: postgresql")
131set_property(CACHE PETASCOPEDB PROPERTY STRINGS postgresql)
132
133set(ENABLE_JAVA ON CACHE BOOL
134        "Enable or disable compilation and installation of Java-based components, including rasj and petascope.")
135if (ENABLE_JAVA)
136    # This variable is necessary to allow the Java components to be built.
137    # Petascope depends on rasj being built to this directory.
138    set(RASJ_TARGET_DIR "${CMAKE_BINARY_DIR}/java/target")
139    file(MAKE_DIRECTORY ${RASJ_TARGET_DIR})
140
141    find_package(Java COMPONENTS Runtime REQUIRED)
142    find_package(Java COMPONENTS Development REQUIRED)
143    # Check if gdal-java library is installed as package
144    find_library(GDAL_JAVA NAMES libgdaljni.so
145                 PATHS /usr/lib/java/gdal
146                       /usr/lib/jni/)
147    if (NOT GDAL_JAVA)
148        message(FATAL_ERROR "gdal-java package not found.")
149    else ()
150        get_filename_component(GDAL_JAVA_DIR ${GDAL_JAVA} DIRECTORY)
151        message("-- Found gdal-java: ${GDAL_JAVA_DIR}")
152    endif()
153    set(GDAL_JAVA_DIR ${GDAL_JAVA_DIR})
154
155    set(ENABLE_R OFF CACHE BOOL "Compile and install R package.")
156endif ()
157
158set(DEFAULT_BASEDB "sqlite" CACHE STRING "Change the default Base DBMS (sqlite, postgresql)")
159set_property(CACHE DEFAULT_BASEDB PROPERTY STRINGS sqlite postgresql)
160
161find_library(NSL_LIBRARY nsl DOC "The NSL library.")
162mark_as_advanced(NSL_LIBRARY)
163
164set(BASEDB_LIBRARIES ${NSL_LIBRARY})
165set(BASEDB_INCLUDE_DIR "")
166
167set(POSTGRESQL_MIN_VERSION 9.1.0)
168if (${DEFAULT_BASEDB} STREQUAL sqlite)
169    find_package(Sqlite REQUIRED)
170    # For config-cmake.h
171    set(BASEDB_SQLITE 1)
172    set(BASEDBSTRING sqlite)
173
174    # Used in subdirectories
175    set(EMBEDDEDSQL_EXT sc)
176    set(EMBEDDEDSQL_OUT cc)
177
178    set(EMBEDDEDSQLPRECOMPILER cp)
179    set(EMBEDDEDSQLPRECOMPILER_FLAGS "-a")
180
181    set(BASEDB_LIBRARIES ${BASEDB_LIBRARIES} ${SQLITE_LIBRARIES})
182    set(BASEDB_INCLUDE_DIR ${BASEDB_INCLUDE_DIR} ${SQLITE_INCLUDE_DIR})
183
184    if (${ENABLE_JAVA} AND ${PETASCOPEDB} STREQUAL postgresql)
185        find_package(PostgreSQL REQUIRED)
186        check_library_exists(pq PQexec "" HAVE_LIBPQ)
187        check_library_exists(pgtypes PGTYPESnumeric_add "" HAVE_LIBPGTYPES)
188
189        if ((NOT ${HAVE_LIBPQ}) OR (NOT ${HAVE_LIBPGTYPES}))
190            message(FATAL_ERROR "Library not found! Please install...")
191        endif ()
192
193        if (${PostgreSQL_VERSION_STRING} VERSION_LESS ${POSTGRESQL_MIN_VERSION})
194            message(FATAL_ERROR "Could not find the minimum version of PostgreSQL. Minimum version is ${POSTGRESQL_MIN_VERSION}" )
195        endif ()
196
197        find_library(ECPG_LIBARY ecpg DOC "The ECPG library.")
198        mark_as_advanced(ECPG_LIBARY)
199
200        find_package(ZLIB REQUIRED)
201
202        set(BASEDB_LIBRARIES ${BASEDB_LIBRARIES} ${PostgreSQL_LIBRARIES} ${ZLIB_LIBRARIES} ${ECPG_LIBARY})
203        set(BASEDB_INCLUDE_DIR ${BASEDB_INCLUDE_DIR} ${PostgreSQL_INCLUDE_DIRS})
204    endif ()
205elseif (${DEFAULT_BASEDB} STREQUAL postgresql)
206    # Used in config-cmake.h
207    set(BASEDB_PGSQL 1)
208    set(BASEDBSTRING pgsql)
209
210    # Used in subdirectories
211    set(EMBEDDEDSQL_EXT pgc)
212    set(EMBEDDEDSQL_OUT cc)
213
214    find_package(PostgreSQL REQUIRED)
215    check_library_exists(pq PQexec "" HAVE_LIBPQ)
216    check_library_exists(pgtypes PGTYPESnumeric_add "" HAVE_LIBPGTYPES)
217
218    if ((NOT ${HAVE_LIBPQ}) OR (NOT ${HAVE_LIBPGTYPES}))
219        message(FATAL_ERROR "Library not found! Please install...")
220    endif ()
221
222    if (${PostgreSQL_VERSION_STRING} VERSION_LESS ${POSTGRESQL_MIN_VERSION})
223        message(FATAL_ERROR "Could not find the minimum version of PostgreSQL. Minimum version is ${POSTGRESQL_MIN_VERSION}")
224    endif ()
225
226    find_program(ECPG ecpg
227            DOC "A precompiler for PostgreSQL embedded code.")
228    set(EMBEDDEDSQLPRECOMPILER "${ECPG}")
229    set(EMBEDDEDSQLPRECOMPILER_FLAGS  "-o")
230
231    find_library(ECPG_LIBARY ecpg DOC "The ECPG library.")
232    find_package(ZLIB REQUIRED)
233
234    set(BASEDB_LIBRARIES ${BASEDB_LIBRARIES} ${PostgreSQL_LIBRARIES} ${ZLIB_LIBRARIES} ${ECPG_LIBARY})
235    set(BASEDB_INCLUDE_DIR ${BASEDB_INCLUDE_DIR} ${PostgreSQL_INCLUDE_DIRS})
236else ()
237    message(FATAL_ERROR "Unsupported base DBMS.")
238endif ()
239
240set(JAVA_SERVER "external" CACHE STRING "Set the Java application deployment mode (external or embedded)")
241set_property(CACHE JAVA_SERVER PROPERTY STRINGS external embedded)
242if (${JAVA_SERVER} STREQUAL external)
243    set(JAVA_SERVER_EXTERNAL true)
244elseif (${JAVA_SERVER} STREQUAL embedded)
245    set(JAVA_SERVER_EMBEDDED true)
246else ()
247    message(FATAL_ERROR "Invalid JAVA_SERVER option.")
248endif ()
249
250set(ENABLE_DEBUG OFF CACHE BOOL "Enable debug symbols and define RMANDEBUG and DEBUG. If you do not need RMANDEBUG, only create a Debug build using CMake.")
251if (ENABLE_DEBUG)
252    set(RMANDEBUG ${ENABLE_DEBUG})
253    set(DEBUG ${ENABLE_DEBUG})
254
255    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g3 -gdwarf-2 -rdynamic")
256else ()
257    #TODO:Double check if these are used and remove them if not
258    set(_DISABLE_TRACE_LOGS 1)
259    # Used by some performance implementation of math libraries.
260    set(__NO_MATH_INLINES 1)
261endif ()
262
263set(ENABLE_BENCHMARK OFF CACHE BOOL "This feature enables generation of binaries that contain extra code for benchmark output.")
264if (ENABLE_BENCHMARK)
265    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DRMANBENCHMARK")
266endif ()
267
268set(ENABLE_PROFILING OFF CACHE BOOL "This feature enables profiling of queries with google-perftools..")
269if (ENABLE_PROFILING)
270    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_PROFILING")
271endif ()
272
273set(ENABLE_STRICT OFF CACHE BOOL "Enable compiling in strict mode: warnings terminate compilation.")
274if (ENABLE_STRICT)
275    # list from http://stackoverflow.com/a/9862800
276    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Werror -Wall -Wextra -Wshadow -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Woverloaded-virtual -Wredundant-decls -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused -Wno-long-long -Wno-format-nonliteral ")
277endif ()
278
279set(GENERATE_DOCS OFF CACHE BOOL
280        "Generate doxygen documentation during build.")
281
282########################################
283# Begin backward compatibility section
284########################################
285#TODO: The following variables could be factored out with some care
286#Enable the standard library
287set(CPPSTDLIB 1)
288
289# The name of the architecture for which the system is compiling.
290set(RASARCHITECTURE "X86")
291# Compile for a X86 based system.
292set(X86 1)
293set(EARLY_TEMPLATE 1)
294set(NOPRE 1)
295set(NO_in_addr_t 1)
296
297set(RASSCHEMAVERSION 5)
298
299include(TestBigEndian)
300
301test_big_endian(IS_BIG_ENDIAN)
302
303if (NOT ${IS_BIG_ENDIAN})
304    set(IS_LITTLE_ENDIAN 1)
305endif ()
306
307########################################
308# End backward compatibility section
309########################################
310set(INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include")
311set(LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
312set(BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin")
313set(CONF_DIR "${CMAKE_INSTALL_PREFIX}/etc")
314
315set(SHARE_DIR "${CMAKE_INSTALL_PREFIX}/share")
316set(SHARE_DATA_DIR "${SHARE_DIR}/rasdaman")
317
318set(LOG_DIR "${CMAKE_INSTALL_PREFIX}/log" CACHE STRING "The path where the servers will store their logs.")
319
320install(DIRECTORY DESTINATION ${LOG_DIR})
321
322set(FILE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data" CACHE STRING "The path where the server stores blobs as files.")
323
324set(WAR_DIR "${SHARE_DATA_DIR}/war" CACHE STRING "The path where the war files should be installed.")
325
326
327#Directories used in the source-code
328add_definitions(-DCONFDIR="${CONF_DIR}/")
329add_definitions(-DBINDIR="${BIN_DIR}/")
330add_definitions(-DLOGDIR="${LOG_DIR}/")
331add_definitions(-DINCLUDE_DIR="${INCLUDE_DIR}/")
332add_definitions(-DSHARE_DATA_DIR="${SHARE_DATA_DIR}/")
333add_definitions(-DFILEDATADIR="${FILE_DATA_DIR}/")
334
335#Definition added for use of protobuf libraries. In particular, the protobuf libraries (correctly)
336# assume that when a variable x is not defined, it is assumed false (i.e. !x = 1); however, when
337# compiling with -Werror and -Wunused, the warning for this turns into an error, and it cannot be suppressed
338# with a pragma.
339add_definitions(-DPROTOBUF_INLINE_NOT_IN_HEADERS=0)
340add_definitions(-DCOMPDATE="2017-08-24")
341
342#TODO: These do not seem safe but are kept because the old code requires them
343set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-stack-protector -fno-strict-overflow")
344
345GetVersionInformation(RMANVERSION GCCVERSION GCCTARGET)
346# Generate the configuration header files.
347configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config-cmake.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h")
348configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/version.h")
349
350# Execute the 3rd party CMakeLists.txt
351include(third_party/CMakeLists.txt)
352
353include_directories(${CMAKE_SOURCE_DIR})
354include_directories(${CMAKE_SOURCE_DIR}/include)
355include_directories(${CMAKE_SOURCE_DIR}/debug)
356
357# All the generated files should be placed in the binary dir. We add this to the include path so that the compiler can
358# find the files.
359include_directories(${CMAKE_BINARY_DIR})
360
361add_subdirectory(applications)
362add_subdirectory(bin)
363add_subdirectory(catalogmgr)
364add_subdirectory(clientcomm)
365add_subdirectory(commline)
366add_subdirectory(common)
367add_subdirectory(conversion)
368add_subdirectory(httpserver)
369add_subdirectory(include)
370add_subdirectory(indexmgr)
371add_subdirectory(java)
372add_subdirectory(lockmgr)
373add_subdirectory(manuals_and_examples)
374add_subdirectory(mddmgr)
375add_subdirectory(mymalloc)
376add_subdirectory(network)
377add_subdirectory(qlparser)
378add_subdirectory(rascontrol)
379add_subdirectory(rascontrol_x)
380add_subdirectory(rasdl)
381add_subdirectory(raslib)
382add_subdirectory(rasmgr)
383add_subdirectory(rasmgr_x)
384add_subdirectory(rasnet)
385add_subdirectory(rasodmg)
386add_subdirectory(rasserver_x)
387add_subdirectory(reladminif)
388add_subdirectory(relblobif)
389add_subdirectory(relcatalogif)
390add_subdirectory(relindexif)
391add_subdirectory(relmddif)
392add_subdirectory(relstorageif)
393add_subdirectory(server)
394add_subdirectory(servercomm)
395add_subdirectory(storagemgr)
396add_subdirectory(systemtest)
397add_subdirectory(tilemgr)
398
399#  This folder MUST be refactored. It does not need to produce any library.
400## add_subdirectory(rasnetprotocol)
401## add_subdirectory(rnprotocol)
Note: See TracBrowser for help on using the repository browser.