-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
183 lines (142 loc) · 6.63 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
# CMakeLists.txt
# Ensure to pick up the default triplet from the environment if any. This helps
# driving the vcpkg triplet in the same way either when starting vcpkg directly,
# or when letting CMake start vcpkg at configure/generate time. Note: this logic
# must happen before PROJECT command.
if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
set(VCPKG_TARGET_TRIPLET
"$ENV{VCPKG_DEFAULT_TRIPLET}"
CACHE STRING "The vcpkg triplet")
endif()
cmake_minimum_required(VERSION 3.20)
# Enforce c++11 standard.
set(CMAKE_CXX_STANDARD 11)
project(khiops-s3 LANGUAGES CXX VERSION 0.1.0)
# Exclude googletest from the installation and packages
set(INSTALL_GTEST OFF)
set(INSTALL_GMOCK OFF)
include(GoogleTest)
enable_testing()
# Find dependencies
find_package(fmt CONFIG REQUIRED)
find_package(ZLIB REQUIRED)
find_package(
AWSSDK CONFIG
COMPONENTS s3
REQUIRED)
find_package(spdlog CONFIG REQUIRED)
# Hide symbols in the shared libraries
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
# Set the location of the built artifacts:
#
# * Shared and static library target directory: lib
# * Executable target directory: bin
# * We must use these weird generator expressions to avoid the Debug and Release
# directories in VS
# * More info: https://stackoverflow.com/q/47175912
#
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY $<1:${CMAKE_BINARY_DIR}/lib/>)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY $<1:${CMAKE_BINARY_DIR}/lib/>)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_BINARY_DIR}/bin/>)
message(STATUS "Executables will be stored in ${CMAKE_BINARY_DIR}/bin/")
message(STATUS "Libraries will be stored in ${CMAKE_BINARY_DIR}/lib/")
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND NOT (CMAKE_BUILD_TYPE STREQUAL
"Release"))
message("Build system == Linux, build with sanitizer tools")
add_compile_options(-fsanitize=undefined -fsanitize=address
-fno-sanitize-recover=all)
add_link_options(-fsanitize=undefined -fsanitize=address
-fno-sanitize-recover=all)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules/)
include(CodeCoverage)
set(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_COVERAGE} ${CMAKE_CXX_FLAGS_DEBUG}")
setup_target_for_coverage(${PROJECT_NAME}_coverage basic_test coverage)
setup_target_for_coverage_cobertura(
${PROJECT_NAME}_cobertura basic_test coverage
--gtest_output=xml:coverage.junit.xml)
endif()
add_library(khiopsdriver_file_s3 SHARED src/s3plugin.h src/s3plugin_internal.h
src/s3plugin.cpp)
target_include_directories(khiopsdriver_file_s3 PRIVATE ${AWSSDK_INCLUDE_DIRS}
src/contrib)
target_link_options(khiopsdriver_file_s3 PRIVATE $<$<CONFIG:RELEASE>:-s>
)# stripping
target_link_libraries(khiopsdriver_file_s3 PRIVATE ${AWSSDK_LIBRARIES}
ZLIB::ZLIB spdlog::spdlog)
target_compile_options(
khiopsdriver_file_s3
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:-Wall;/wd4582;/wd4583;/wd4625;/wd4626;/wd4710;/wd4711;/wd4820;/wd4868>
PRIVATE $<$<CXX_COMPILER_ID:AppleClang,Clang,GNU>:-Wall;-Wextra;-pedantic>)
set_target_properties(khiopsdriver_file_s3 PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} VERSION ${PROJECT_VERSION})
option(BUILD_TESTS "Build test programs" OFF)
if(BUILD_TESTS)
add_executable(KhiopsPluginTest src/khiopsplugintest.cpp)
target_link_libraries(KhiopsPluginTest PRIVATE fmt::fmt ${CMAKE_DL_LIBS})
add_executable(drivertest src/drivertest.cpp)
target_link_libraries(drivertest ${CMAKE_DL_LIBS}) # Link to dl
endif(BUILD_TESTS)
add_subdirectory(test)
install(
TARGETS khiopsdriver_file_s3
LIBRARY DESTINATION "lib"
ARCHIVE # lib on windows
RUNTIME # dll on windows
)
set(CPACK_PACKAGE_VENDOR Orange)
set(CPACK_PACKAGE_HOMEPAGE_URL https://khiops.org)
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VENDOR "Orange")
set(CPACK_PACKAGE_CONTACT "Khiops Team <[email protected]>")
set(CPACK_SOURCE_IGNORE_FILES .git)
set(CPACK_PACKAGE_DESCRIPTION "This driver allows Khiops to access the Amazon S3 Cloud storage.")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "S3 driver for the Khiops tool")
set(CPACK_PACKAGE_NAME "khiops-driver-s3")
set(CPACK_VERBATIM_VARIABLES YES)
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/packages")
# set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/")
# ########### ARCHIVE Generator #############################
# One package per component
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
# user friendly archive names
set(CPACK_ARCHIVE_FILE_NAME khiops-driver-s3-${PROJECT_VERSION})
# ########### DEB Generator #############################
# Package release ("This is the numbering of the DEB package itself, i.e. the version of the packaging and not the
# version of the content")
set(CPACK_DEBIAN_PACKAGE_RELEASE 1)
# package name for deb.
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
# Packages version: the full KHIOPS_VERSION (N.N.N_aN) instead of the PROJECT_VERSION (N.N.N)
# set(CPACK_DEBIAN_PACKAGE_VERSION ${KHIOPS_VERSION})
set(CPACK_DEB_COMPONENT_INSTALL YES)
set(CPACK_DEBIAN_PACKAGE_SECTION "math")
# runtime path setting
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON)
# binaries in deb building will search shared library in the build tree. We should use directly
# CMAKE_LIBRARY_OUTPUT_DIRECTORY but it produces a bug in dpkg-shlibdeps
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS ${CMAKE_BINARY_DIR}/lib/)
# packages recommends
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "khiops")
# packages posinst and triggers set(CPACK_DEBIAN_KNI_PACKAGE_CONTROL_EXTRA
# ${PROJECT_SOURCE_DIR}/packaging/linux/debian/kni/triggers")
# set(CPACK_DEBIAN_PACKAGE_DEBUG ON)
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
# ########### RPM Generator #############################
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_RPM_PACKAGE_LICENSE BSD-3-Clause)
set(CPACK_RPM_PACKAGE_GROUP "Applications/Engineering")
set(CPACK_RPM_PACKAGE_VENDOR Orange)
set(CPACK_RPM_KHIOPS_PACKAGE_AUTOREQ ON)
# Packages version set(CPACK_RPM_PACKAGE_VERSION ${PROJECT_VERSION})
# packages names set(CPACK_RPM_PACKAGE_NAME khiops)
# default file name e.g. khiops-10.0.0-1.x86_64.rpm
set(CPACK_RPM_FILE_NAME RPM-DEFAULT)
# packages summary set(CPACK_RPM_PACKAGE_SUMMARY "Khiops tools")
# packages post/postun install scripts set(CPACK_RPM_KNI_POST_INSTALL_SCRIPT_FILE
# "${PROJECT_SOURCE_DIR}/packaging/linux/redhat/kni.post") set(CPACK_RPM_KNI_POSTUN_INSTALL_SCRIPT_FILE
# "${PROJECT_SOURCE_DIR}/packaging/linux/redhat/kni.postun")
include(CPack)