-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
209 lines (163 loc) · 7.1 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
################### INITIALISATION
message(STATUS "ROK4 C++ library built")
# check the cmake version
cmake_minimum_required(VERSION 3.10)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
################### PARAMÈTRES
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation location")
set(BUILD_VERSION "0.0.0" CACHE STRING "Build version")
set(CEPH_ENABLED 0 CACHE BOOL "Build with ceph storage")
set(KDU_ENABLED 0 CACHE BOOL "Build with kakadu")
set(UNITTEST_ENABLED 1 CACHE BOOL "Unit tests compilation")
set(DOC_ENABLED 1 CACHE BOOL "Documentation compilation")
set(CPACK_SYSTEM_NAME "ubuntu-20.04" CACHE STRING "Building OS, to deduce package format to generate")
set(CPACK_PACKAGE_NAME "librok4-dev" CACHE STRING "Package's name")
set(VERSION ${BUILD_VERSION})
message("Version ${VERSION}")
# Définit le nom du projet
project(rok4
VERSION ${VERSION}
DESCRIPTION "ROK4 library"
LANGUAGES CXX)
configure_file(config.h.in config.h ESCAPE_QUOTES @ONLY)
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)
################### MODE DEBUG
if(DEBUG_BUILD)
set(CMAKE_BUILD_TYPE debugbuild)
set(CMAKE_CXX_FLAGS_DEBUGBUILD "-g -O0")
set(CMAKE_C_FLAGS_DEBUGBUILD "-g")
else(DEBUG_BUILD)
set(CMAKE_BUILD_TYPE specificbuild)
set(CMAKE_CXX_FLAGS_SPECIFICBUILD "-O3")
endif(DEBUG_BUILD)
################### RECHERCHE DES DÉPENDANCES
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
message(STATUS "Modules CMake : ${CMAKE_MODULE_PATH}")
include(cmake/modules/dependencies.cmake)
################### DÉFINITION DES FICHIERS SOURCES ET DES HEADERS
file(GLOB LIBROK4_SRCS
"src/compressors/*.cpp"
"src/datastream/*.cpp"
"src/datasource/*.cpp"
"src/enums/*.cpp"
"src/style/*.cpp"
"src/processors/*.cpp"
"src/storage/*.cpp"
"src/utils/*.cpp"
"src/image/*.cpp"
"src/image/file/*.cpp"
"src/storage/*.cpp"
"src/thirdparty/*.cpp"
)
include_directories(${PROJECT_BINARY_DIR} ${PROJ_INCLUDE_DIR} ${TURBOJPEG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${CURL_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${BOOSTLOG_INCLUDE_DIR})
if(KDU_ENABLED)
message( FATAL_ERROR "Use Kakadu driver to read JPEG2000 is no more available" )
else(KDU_ENABLED)
set(LIBROK4_SRCS ${LIBROK4_SRCS} "src/image/file/openjpeg/LibopenjpegImage.cpp")
include_directories(${OPENJPEG_INCLUDE_DIR})
endif(KDU_ENABLED)
if(CEPH_ENABLED)
set(LIBROK4_SRCS ${LIBROK4_SRCS} "src/storage/ceph/CephPoolContext.cpp")
include_directories(${RADOS_INCLUDE_DIR})
endif(CEPH_ENABLED)
add_library(${PROJECT_NAME} SHARED ${LIBROK4_SRCS})
target_include_directories(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${CMAKE_PROJECT_VERSION_MAJOR})
################### LIEN DES DÉPENDANCES
target_link_libraries(${PROJECT_NAME} PUBLIC proj turbojpeg jpeg zlib curl openssl crypto boostlog jpeg2000 tiff png)
if(CEPH_ENABLED)
target_link_libraries(${PROJECT_NAME} PUBLIC rados)
endif(CEPH_ENABLED)
################### TESTS UNITAIRES
if(UNITTEST_ENABLED)
message("${CPPUNIT_INCLUDE_DIR}")
include_directories(${CPPUNIT_INCLUDE_DIR})
enable_testing()
add_definitions(-DUNITTEST)
file(GLOB UnitTests_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "tests/CppUnit*.cpp" )
add_executable(UnitTester-${PROJECT_NAME} tests/main.cpp ${UnitTests_SRCS} tests/TimedTestListener.cpp tests/XmlTimedTestOutputterHook.cpp )
target_link_libraries(UnitTester-${PROJECT_NAME} cppunit ${PROJECT_NAME})
foreach(test ${UnitTests_SRCS})
message(" - adding test ${test}")
get_filename_component(TestName ${test} NAME_WE)
add_test(${TestName} UnitTester-${PROJECT_NAME} ${TestName})
endforeach(test)
endif(UNITTEST_ENABLED)
################### DOCUMENTATION
if(DOC_ENABLED)
set(DOXYGEN_DOXYFILE_ENCODING UTF-8)
set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/target/docs)
set(DOXYGEN_OUTPUT_LANGUAGE french)
set(DOXYGEN_INPUT_ENCODING UTF-8)
set(DOXYGEN_IMAGE_PATH docs/images)
set(DOXYGEN_RECURSIVE YES)
set(DOXYGEN_GENERATE_HTML YES)
set(DOXYGEN_GENERATE_LATEX NO)
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE docs/main.doxygen.md)
set(DOXYGEN_GENERATE_TREEVIEW YES)
set(DOXYGEN_DISABLE_INDEX NO)
set(DOXYGEN_FULL_SIDEBAR NO)
set(DOXYGEN_HTML_HEADER docs/doxygen/header.html)
set(DOXYGEN_HTML_EXTRA_STYLESHEET ${CMAKE_CURRENT_SOURCE_DIR}/docs/doxygen/doxygen-awesome.css)
set(DOXYGEN_HTML_COLORSTYLE LIGHT)
doxygen_add_docs(doc ${CMAKE_CURRENT_SOURCE_DIR}/src/ ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${CMAKE_CURRENT_SOURCE_DIR}/docs/doxygen/)
endif(DOC_ENABLED)
################### INSTALLATION
# For access to standard installation directory variables (CMAKE_INSTALL_xDIR).
include(GNUInstallDirs)
# Set library shared object and API header file to install.
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/rok4
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
################### PACKAGE CONFIGURATION
message(STATUS "Configuring packages")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BUILD_ARCHITECTURE "amd64")
else()
set(BUILD_ARCHITECTURE "i386")
endif()
set(CPACK_GENERATOR "TGZ")
if(CEPH_ENABLED)
set(CPACK_PACKAGE_FILE_NAME "librok4-ceph-${VERSION}-${CPACK_SYSTEM_NAME}-${BUILD_ARCHITECTURE}")
else(CEPH_ENABLED)
set(CPACK_PACKAGE_FILE_NAME "librok4-base-${VERSION}-${CPACK_SYSTEM_NAME}-${BUILD_ARCHITECTURE}")
endif(CEPH_ENABLED)
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_PACKAGE_VENDOR "IGN")
set(CPACK_PACKAGE_CONTACT "IGN - Géoportail (<tout_rdev@ign.fr>)")
if(CPACK_SYSTEM_NAME AND CPACK_SYSTEM_NAME STREQUAL "ubuntu-20.04" OR CPACK_SYSTEM_NAME STREQUAL "ubuntu-22.04")
set(CPACK_GENERATOR "DEB;TGZ")
# Debian
set(CPACK_DEBIAN_PACKAGE_SECTION "science")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "zlib1g-dev, libcurl4-openssl-dev, libproj-dev, libssl-dev, libturbojpeg0-dev, libjpeg-dev, libc6-dev, libboost-log-dev, libboost-filesystem-dev, libboost-system-dev, libsqlite3-dev, libpng-dev, libtiff5-dev")
if(NOT KDU_ENABLED)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libopenjp2-7-dev")
endif(NOT KDU_ENABLED)
if(CEPH_ENABLED)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, librados-dev")
endif(CEPH_ENABLED)
set(CPACK_BINARY_DEB "ON")
endif()
if(CPACK_SYSTEM_NAME AND CPACK_SYSTEM_NAME STREQUAL "alpine3")
set(CPACK_GENERATOR "TGZ")
endif()
include(CPack)