Skip to content

Commit cd288b7

Browse files
togeuilianries
authored andcommitted
(conan-io#14509) cassandra-cpp-driver: add version 2.16.2, support conan v2
* cassandra-cpp-driver: add version 2.16.2, support conan v2 * fix library name, specify C++11 * add transitive_headers=True * update dependencies * fix compilation error on msvc * update dependencies, improve patch file * enable C++11, include type_traits --------- Co-authored-by: Uilian Ries <[email protected]>
1 parent f61468d commit cd288b7

File tree

14 files changed

+491
-171
lines changed

14 files changed

+491
-171
lines changed

recipes/cassandra-cpp-driver/all/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,36 @@
11
sources:
2+
"2.16.2":
3+
url: "https://github.com/datastax/cpp-driver/archive/2.16.2.tar.gz"
4+
sha256: "de60751bd575b5364c2c5a17a24a40f3058264ea2ee6fef19de126ae550febc9"
25
"2.15.3":
3-
url: "https://github.com/datastax/cpp-driver/archive/2.15.3.zip"
4-
sha256: "494b35418f1eaa86d80572a4254b7fae88a1341dcda83788ed038ce4f39117cb"
6+
url: "https://github.com/datastax/cpp-driver/archive/2.15.3.tar.gz"
7+
sha256: "eccb53c5151621c3b647fc83781a542cfb93e76687b4178ebce418fc4c817293"
58
patches:
9+
"2.16.2":
10+
- patch_file: "patches/2.16.2/fix-cmake.patch"
11+
patch_description: "use cci package"
12+
patch_type: "conan"
13+
- patch_file: "patches/2.15.3/fix-rapidjson.patch"
14+
patch_description: "fix include path for cci package"
15+
patch_type: "conan"
16+
- patch_file: "patches/2.15.3/fix-atomic.patch"
17+
patch_description: "Adapt MemoryOrder definition for C++ 20"
18+
patch_type: "portability"
19+
patch_source: "https://github.com/datastax/cpp-driver/pull/533"
20+
- patch_file: "patches/2.15.3/remove-attribute-for-msvc.patch"
21+
patch_description: "remove attribute for msvc"
22+
patch_type: "portability"
623
"2.15.3":
7-
- base_path: "source_subfolder"
8-
patch_file: "patches/2.15.3/fix-cmake.patch"
9-
- base_path: "source_subfolder"
10-
patch_file: "patches/2.15.3/fix-rapidjson.patch"
24+
- patch_file: "patches/2.15.3/fix-cmake.patch"
25+
patch_description: "use cci package"
26+
patch_type: "conan"
27+
- patch_file: "patches/2.15.3/fix-rapidjson.patch"
28+
patch_description: "fix include path for cci package"
29+
patch_type: "conan"
30+
- patch_file: "patches/2.15.3/fix-atomic.patch"
31+
patch_description: "Adapt MemoryOrder definition for C++ 20"
32+
patch_type: "portability"
33+
patch_source: "https://github.com/datastax/cpp-driver/pull/533"
34+
- patch_file: "patches/2.15.3/remove-attribute-for-msvc.patch"
35+
patch_description: "remove attribute for msvc"
36+
patch_type: "portability"

recipes/cassandra-cpp-driver/all/conanfile.py

Lines changed: 70 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
from conans import ConanFile, CMake, tools
2-
from conans.errors import ConanInvalidConfiguration
1+
from conan import ConanFile
2+
from conan.errors import ConanInvalidConfiguration
3+
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, replace_in_file, rm
4+
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
5+
from conan.tools.build import check_min_cppstd
36
import os
47

5-
required_conan_version = ">=1.33.0"
6-
8+
required_conan_version = ">=1.53.0"
79

810
class CassandraCppDriverConan(ConanFile):
911
name = "cassandra-cpp-driver"
12+
description = "DataStax C/C++ Driver for Apache Cassandra and DataStax Products"
1013
license = "Apache-2.0"
1114
url = "https://github.com/conan-io/conan-center-index"
1215
homepage = "https://docs.datastax.com/en/developer/cpp-driver/"
13-
description = "DataStax C/C++ Driver for Apache Cassandra and DataStax Products"
14-
topics = ("cassandra", "cpp-driver", "database", "conan-recipe")
15-
16-
settings = "os", "compiler", "build_type", "arch"
16+
topics = ("cassandra", "cpp-driver", "database",)
17+
settings = "os", "arch", "compiler", "build_type"
1718
options = {
1819
"shared": [True, False],
1920
"fPIC": [True, False],
@@ -34,19 +35,14 @@ class CassandraCppDriverConan(ConanFile):
3435
"with_kerberos": False,
3536
"use_timerfd": True,
3637
}
37-
3838
short_paths = True
39-
generators = "cmake"
40-
exports_sources = [
41-
"CMakeLists.txt",
42-
"patches/*"
43-
]
44-
45-
_cmake = None
4639

4740
@property
48-
def _source_subfolder(self):
49-
return "source_subfolder"
41+
def _min_cppstd(self):
42+
return 11
43+
44+
def export_sources(self):
45+
export_conandata_patches(self)
5046

5147
def config_options(self):
5248
if self.settings.os == "Windows":
@@ -55,24 +51,30 @@ def config_options(self):
5551

5652
def configure(self):
5753
if self.options.shared:
58-
del self.options.fPIC
54+
self.options.rm_safe("fPIC")
55+
56+
def layout(self):
57+
cmake_layout(self, src_folder="src")
5958

6059
def requirements(self):
61-
self.requires("libuv/1.44.1")
60+
self.requires("libuv/1.46.0")
6261
self.requires("http_parser/2.9.4")
63-
self.requires("rapidjson/cci.20211112")
62+
self.requires("rapidjson/cci.20220822")
6463

6564
if self.options.with_openssl:
66-
self.requires("openssl/1.1.1q")
65+
self.requires("openssl/[>=1.1 <4]")
6766

6867
if self.options.with_zlib:
69-
self.requires("minizip/1.2.12")
70-
self.requires("zlib/1.2.12")
68+
self.requires("minizip/1.2.13")
69+
self.requires("zlib/1.2.13")
7170

7271
if self.options.use_atomic == "boost":
73-
self.requires("boost/1.79.0")
72+
self.requires("boost/1.82.0")
7473

7574
def validate(self):
75+
if self.info.settings.compiler.cppstd:
76+
check_min_cppstd(self, self._min_cppstd)
77+
7678
if self.options.use_atomic == "boost":
7779
# Compilation error on Linux
7880
if self.settings.os == "Linux":
@@ -84,69 +86,69 @@ def validate(self):
8486
"Kerberos is not supported at the moment")
8587

8688
def source(self):
87-
tools.get(**self.conan_data["sources"][self.version],
88-
destination=self._source_subfolder, strip_root=True)
89-
90-
def _patch_sources(self):
91-
for patch in self.conan_data.get("patches", {}).get(self.version, []):
92-
tools.patch(**patch)
93-
tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"),
94-
"\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Clang\"",
95-
"\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Clang\" OR \"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"AppleClang\"")
96-
97-
def _configure_cmake(self):
98-
if self._cmake:
99-
return self._cmake
100-
101-
self._cmake = CMake(self)
102-
self._cmake.definitions["VERSION"] = self.version
103-
self._cmake.definitions["CASS_BUILD_EXAMPLES"] = False
104-
self._cmake.definitions["CASS_BUILD_INTEGRATION_TESTS"] = False
105-
self._cmake.definitions["CASS_BUILD_SHARED"] = self.options.shared
106-
self._cmake.definitions["CASS_BUILD_STATIC"] = not self.options.shared
107-
self._cmake.definitions["CASS_BUILD_TESTS"] = False
108-
self._cmake.definitions["CASS_BUILD_UNIT_TESTS"] = False
109-
self._cmake.definitions["CASS_DEBUG_CUSTOM_ALLOC"] = False
110-
self._cmake.definitions["CASS_INSTALL_HEADER_IN_SUBDIR"] = self.options.install_header_in_subdir
111-
self._cmake.definitions["CASS_INSTALL_PKG_CONFIG"] = False
89+
get(self, **self.conan_data["sources"][self.version], strip_root=True)
90+
91+
def generate(self):
92+
tc = CMakeToolchain(self)
93+
tc.variables["VERSION"] = self.version
94+
tc.variables["CASS_BUILD_EXAMPLES"] = False
95+
tc.variables["CASS_BUILD_INTEGRATION_TESTS"] = False
96+
tc.variables["CASS_BUILD_SHARED"] = self.options.shared
97+
tc.variables["CASS_BUILD_STATIC"] = not self.options.shared
98+
tc.variables["CASS_BUILD_TESTS"] = False
99+
tc.variables["CASS_BUILD_UNIT_TESTS"] = False
100+
tc.variables["CASS_DEBUG_CUSTOM_ALLOC"] = False
101+
tc.variables["CASS_INSTALL_HEADER_IN_SUBDIR"] = self.options.install_header_in_subdir
102+
tc.variables["CASS_INSTALL_PKG_CONFIG"] = False
112103

113104
if self.options.use_atomic == "boost":
114-
self._cmake.definitions["CASS_USE_BOOST_ATOMIC"] = True
115-
self._cmake.definitions["CASS_USE_STD_ATOMIC"] = False
105+
tc.variables["CASS_USE_BOOST_ATOMIC"] = True
106+
tc.variables["CASS_USE_STD_ATOMIC"] = False
116107

117108
elif self.options.use_atomic == "std":
118-
self._cmake.definitions["CASS_USE_BOOST_ATOMIC"] = False
119-
self._cmake.definitions["CASS_USE_STD_ATOMIC"] = True
109+
tc.variables["CASS_USE_BOOST_ATOMIC"] = False
110+
tc.variables["CASS_USE_STD_ATOMIC"] = True
120111
else:
121-
self._cmake.definitions["CASS_USE_BOOST_ATOMIC"] = False
122-
self._cmake.definitions["CASS_USE_STD_ATOMIC"] = False
112+
tc.variables["CASS_USE_BOOST_ATOMIC"] = False
113+
tc.variables["CASS_USE_STD_ATOMIC"] = False
123114

124-
self._cmake.definitions["CASS_USE_OPENSSL"] = self.options.with_openssl
125-
self._cmake.definitions["CASS_USE_STATIC_LIBS"] = False
126-
self._cmake.definitions["CASS_USE_ZLIB"] = self.options.with_zlib
127-
self._cmake.definitions["CASS_USE_LIBSSH2"] = False
115+
tc.variables["CASS_USE_OPENSSL"] = self.options.with_openssl
116+
tc.variables["CASS_USE_STATIC_LIBS"] = False
117+
tc.variables["CASS_USE_ZLIB"] = self.options.with_zlib
118+
tc.variables["CASS_USE_LIBSSH2"] = False
128119

129120
# FIXME: To use kerberos, its conan package is needed. Uncomment this when kerberos conan package is ready.
130-
# self._cmake.definitions["CASS_USE_KERBEROS"] = self.options.with_kerberos
121+
# tc.variables["CASS_USE_KERBEROS"] = self.options.with_kerberos
131122

132123
if self.settings.os == "Linux":
133-
self._cmake.definitions["CASS_USE_TIMERFD"] = self.options.use_timerfd
124+
tc.variables["CASS_USE_TIMERFD"] = self.options.use_timerfd
125+
tc.generate()
134126

135-
self._cmake.configure()
136-
return self._cmake
127+
deps = CMakeDeps(self)
128+
deps.generate()
129+
130+
def _patch_sources(self):
131+
apply_conandata_patches(self)
132+
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"),
133+
"\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Clang\"",
134+
"\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Clang\" OR \"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"AppleClang\"")
135+
rm(self, "Findlibssh2.cmake", os.path.join(self.source_folder, "cmake"))
136+
rm(self, "Findlibuv.cmake", os.path.join(self.source_folder, "cmake"))
137+
rm(self, "FindOpenSSL.cmake", os.path.join(self.source_folder, "cmake"))
137138

138139
def build(self):
139140
self._patch_sources()
140-
cmake = self._configure_cmake()
141+
cmake = CMake(self)
142+
cmake.configure()
141143
cmake.build()
142144

143145
def package(self):
144-
self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder)
145-
cmake = self._configure_cmake()
146+
copy(self, pattern="LICENSE.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
147+
cmake = CMake(self)
146148
cmake.install()
147149

148150
def package_info(self):
149-
self.cpp_info.libs = tools.collect_libs(self)
151+
self.cpp_info.libs = ["cassandra" if self.options.shared else "cassandra_static"]
150152

151153
if self.settings.os == "Windows":
152154
self.cpp_info.system_libs.extend(["iphlpapi", "psapi", "wsock32",
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
diff --git a/src/atomic/atomic_std.hpp b/src/atomic/atomic_std.hpp
2+
index 2ad0103..08418a9 100644
3+
--- a/src/atomic/atomic_std.hpp
4+
+++ b/src/atomic/atomic_std.hpp
5+
@@ -18,16 +18,17 @@
6+
#define DATASTAX_INTERNAL_ATOMIC_STD_HPP
7+
8+
#include <atomic>
9+
+#include <type_traits>
10+
11+
namespace datastax { namespace internal {
12+
13+
enum MemoryOrder {
14+
- MEMORY_ORDER_RELAXED = std::memory_order_relaxed,
15+
- MEMORY_ORDER_CONSUME = std::memory_order_consume,
16+
- MEMORY_ORDER_ACQUIRE = std::memory_order_acquire,
17+
- MEMORY_ORDER_RELEASE = std::memory_order_release,
18+
- MEMORY_ORDER_ACQ_REL = std::memory_order_acq_rel,
19+
- MEMORY_ORDER_SEQ_CST = std::memory_order_seq_cst
20+
+ MEMORY_ORDER_RELAXED = static_cast<std::underlying_type<std::memory_order>::type>(std::memory_order_relaxed),
21+
+ MEMORY_ORDER_CONSUME = static_cast<std::underlying_type<std::memory_order>::type>(std::memory_order_consume),
22+
+ MEMORY_ORDER_ACQUIRE = static_cast<std::underlying_type<std::memory_order>::type>(std::memory_order_acquire),
23+
+ MEMORY_ORDER_RELEASE = static_cast<std::underlying_type<std::memory_order>::type>(std::memory_order_release),
24+
+ MEMORY_ORDER_ACQ_REL = static_cast<std::underlying_type<std::memory_order>::type>(std::memory_order_acq_rel),
25+
+ MEMORY_ORDER_SEQ_CST = static_cast<std::underlying_type<std::memory_order>::type>(std::memory_order_seq_cst)
26+
};
27+
28+
template <class T>

0 commit comments

Comments
 (0)