forked from he4rt/scylladb-php-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
180 lines (150 loc) · 5.72 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
cmake_minimum_required(VERSION 3.24)
project(php-ext-scylladb LANGUAGES C CXX)
# if build type is not set, default to debug
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Debug")
endif ()
include(GNUInstallDirs)
include(CheckSymbolExists)
include(CheckIncludeFile)
include(CMakePackageConfigHelpers)
include(cmake/CPM.cmake)
include(cmake/TargetOptimizations.cmake)
include(cmake/ScyllaDBPHPLibrary.cmake)
set(PHP_SCYLLADB_VERSION_MAJOR 1)
set(PHP_SCYLLADB_VERSION_MINOR 3)
set(PHP_SCYLLADB_VERSION_PATCH 9)
set(PHP_SCYLLADB_STABILITY "devel")
set(PHP_SCYLLADB_VERSION_FULL "${PHP_SCYLLADB_VERSION_MAJOR}.${PHP_SCYLLADB_VERSION_MINOR}.${PHP_SCYLLADB_VERSION_PATCH}-${PHP_SCYLLADB_STABILITY}")
set(PHP_SCYLLADB_VERSION "${PHP_SCYLLADB_VERSION_MAJOR}.${PHP_SCYLLADB_VERSION_MINOR}.${PHP_SCYLLADB_VERSION_PATCH}-dev")
set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake" "${PROJECT_SOURCE_DIR}/third-party/sanitizers-cmake/cmake")
option(PHP_SCYLLADB_ENABLE_SANITIZERS "Enable sanitizers" OFF)
option(PHP_SCYLLADB_ENABLE_COVERAGE "Enable coverage" OFF)
option(PHP_SCYLLADB_OPTIMISE_FOR_CURRENT_MACHINE "Optimise for current machine" OFF)
option(PHP_SCYLLADB_LIBUV_STATIC "Statically link libuv" OFF)
option(PHP_SCYLLADB_LIBSCYLLADB_STATIC "Statically link libscylladb" OFF)
find_package(PHPConfig REQUIRED)
find_package(PHP REQUIRED)
find_package(Sanitizers REQUIRED)
if (PHP_SCYLLADB_LIBUV_STATIC)
set(LIBUV_BUILD_SHARED OFF)
else ()
set(LIBUV_BUILD_SHARED ON)
endif ()
CPMAddPackage(
NAME libuv
VERSION 1.44.2
URL https://github.com/libuv/libuv/tarball/v1.44.2
URL_HASH MD5=3e22e24d53aab67252907dfa004a6b53
OPTIONS
"BUILD_TESTING OFF"
"BUILD_BENCHMARKS OFF"
"LIBUV_BUILD_SHARED ${LIBUV_BUILD_SHARED}"
"CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -fPIC"
"CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fPIC"
)
set(LIBUV_ROOT_DIR ${libuv_BINARY_DIR})
if (PHP_SCYLLADB_LIBUV_STATIC)
set(LIBUV_LIBRARY "${libuv_BINARY_DIR}/libuv_a.a")
else ()
set(LIBUV_LIBRARY "${libuv_BINARY_DIR}/libuv.so")
endif ()
if (PHP_SCYLLADB_LIBSCYLLADB_STATIC)
set(CASS_BUILD_STATIC ON)
set(CASS_BUILD_SHARED OFF)
else ()
set(CASS_BUILD_STATIC OFF)
set(CASS_BUILD_SHARED ON)
endif ()
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
CPMAddPackage(
NAME libscylladb
VERSION 2.16.2
URL https://github.com/scylladb/cpp-driver/tarball/2.16.2b
URL_HASH MD5=67e6c74cdd6c9692b2745bfc28dccdaa
OPTIONS
"CASS_CPP_STANDARD 17"
"CASS_BUILD_STATIC ${CASS_BUILD_STATIC}"
"CASS_BUILD_SHARED ${CASS_BUILD_SHARED}"
"CASS_USE_STD_ATOMIC ON"
"CASS_USE_TIMERFD ON"
"CASS_USE_LIBSSH2 ON"
"CASS_USE_ZLIB ON"
"CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -fPIC"
"CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fPIC -Wno-error=redundant-move"
"LIBUV_LIBRARY ${LIBUV_LIBRARY}"
"LIBUV_INCLUDE_DIR ${libuv_SOURCE_DIR}/include"
)
add_subdirectory(ZendCPP)
add_subdirectory(util)
add_subdirectory(src)
add_subdirectory(src/Cluster)
add_subdirectory(src/DateTime)
add_subdirectory(src/Database)
add_subdirectory(src/Numbers)
add_subdirectory(src/Exception)
add_subdirectory(src/RetryPolicy)
add_subdirectory(src/SSLOptions)
add_subdirectory(src/TimestampGenerator)
add_subdirectory(src/Type)
file(GLOB_RECURSE HEADERS_LIST FOLLOW_SYMLINKS include/*.h)
add_library(ext_scylladb SHARED)
scylladb_php_library(ext_scylladb ${PHP_SCYLLADB_ENABLE_SANITIZERS} ${PHP_SCYLLADB_OPTIMISE_FOR_CURRENT_MACHINE} OFF)
target_sources(ext_scylladb PUBLIC FILE_SET headers TYPE HEADERS FILES "${HEADERS_LIST}" "${PROJECT_BINARY_DIR}/config.h")
target_sources(ext_scylladb PRIVATE php_driver.cpp)
target_link_libraries(
ext_scylladb PRIVATE
ext_scylladb::src
ext_scylladb::utils
ext_scylladb::type
ext_scylladb::datetime
ext_scylladb::database
ext_scylladb::numbers
ext_scylladb::ssl_options
ext_scylladb::exceptions
ext_scylladb::cluster::builder
ext_scylladb::retry_policy
ext_scylladb::timestamp_generator
)
if (PHP_SCYLLADB_LIBUV_STATIC)
target_compile_definitions(ext_scylladb PRIVATE -DUV_STATIC)
target_link_libraries(ext_scylladb PRIVATE uv_a)
else ()
target_link_libraries(ext_scylladb PRIVATE uv)
endif ()
if (PHP_SCYLLADB_LIBSCYLLADB_STATIC)
target_compile_definitions(ext_scylladb PRIVATE -DSCYLLADB_STATIC)
target_link_libraries(ext_scylladb PRIVATE cassandra_static)
else ()
target_link_libraries(ext_scylladb PRIVATE "libscylla-cpp-driver.so")
endif ()
check_include_file("dlfcn.h" HAVE_DLFCN_H)
check_include_file("stdio.h" HAVE_STDIO_H)
check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("stdlib.h" HAVE_STDLIB_H)
check_include_file("inttypes.h" HAVE_INTTYPES_H)
check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
check_include_file("string.h" HAVE_STRING_H)
check_include_file("unistd.h" HAVE_UNISTD_H)
set(HAVE_STRINGS_H 0)
configure_file(
config.in
config.h
USE_SOURCE_PERMISSIONS
NEWLINE_STYLE UNIX
)
configure_file(
version.h.in
version.h
USE_SOURCE_PERMISSIONS
NEWLINE_STYLE UNIX
)
target_compile_definitions(ext_scylladb PRIVATE -DCOMPILE_DL_CASSANDRA -DHAVE_CONFIG_H)
set_target_properties(ext_scylladb PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(ext_scylladb PROPERTIES PREFIX "")
set_target_properties(ext_scylladb PROPERTIES OUTPUT_NAME "cassandra")
install(TARGETS ext_scylladb DESTINATION "${PHP_EXTENSION_DIR}")
install(TARGETS ext_scylladb FILE_SET headers DESTINATION "${PHP_INCLUDES_DIR}/ext/cassandra")