Skip to content

Commit 87884e7

Browse files
mjvankampenprince-chrismcuilianries
authored
(#7394) Adds rapidcheck gtest/catch integrations
* Adds rapidcheck boost/gtest/catch integrations * Fixes bad alias * Fixes tools.cross_building * Fixes package names * Fixes typo * Fixes older versions * Removes redundant includes Co-authored-by: Chris Mc <[email protected]> * Links in gtest and catch when necessary * Fixes older versions * Fixes requirements * Renames core to be more in line with the rest * Update recipes/rapidcheck/all/conanfile.py Co-authored-by: Uilian Ries <[email protected]> Co-authored-by: Chris Mc <[email protected]> Co-authored-by: Uilian Ries <[email protected]>
1 parent 77ee8b4 commit 87884e7

File tree

6 files changed

+89
-10
lines changed

6 files changed

+89
-10
lines changed

recipes/rapidcheck/all/conandata.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,13 @@ sources:
88
"cci.20200131":
99
url: "https://github.com/emil-e/rapidcheck/archive/258d907da00a0855f92c963d8f76eef115531716.zip"
1010
sha256: "87bfbdceaa09e7aaaf70b2efd0078e93323dd8abdad48c57e9f23bfd84174a75"
11+
patches:
12+
"cci.20210702":
13+
- patch_file: "patches/0001-gtest-catch-integration.patch"
14+
base_path: "source_subfolder"
15+
"cci.20210107":
16+
- patch_file: "patches/0001-gtest-catch-integration-20210107.patch"
17+
base_path: "source_subfolder"
18+
"cci.20200131":
19+
- patch_file: "patches/0001-gtest-catch-integration-20200131.patch"
20+
base_path: "source_subfolder"

recipes/rapidcheck/all/conanfile.py

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,24 @@ class RapidcheckConan(ConanFile):
1313
homepage = "https://github.com/emil-e/rapidcheck"
1414
license = "BSD-2-Clause"
1515
topics = "quickcheck", "testing", "property-testing"
16-
exports_sources = "CMakeLists.txt"
17-
generators = "cmake"
16+
exports_sources = ["CMakeLists.txt", "patches/**"]
17+
generators = ["cmake", "cmake_find_package"]
1818
settings = "os", "arch", "compiler", "build_type"
1919
options = {
2020
"shared": [True, False],
2121
"fPIC": [True, False],
2222
"enable_rtti": [True, False],
23+
"enable_catch": [True, False],
24+
"enable_gmock": [True, False],
25+
"enable_gtest": [True, False]
2326
}
2427
default_options = {
2528
"shared": False,
2629
"fPIC": True,
2730
"enable_rtti": True,
31+
"enable_catch": False,
32+
"enable_gmock": False,
33+
"enable_gtest": False
2834
}
2935

3036
_cmake = None
@@ -51,6 +57,12 @@ def validate(self):
5157
if self.settings.compiler == "Visual Studio" and self.options.shared:
5258
raise ConanInvalidConfiguration("shared is not supported using Visual Studio")
5359

60+
def requirements(self):
61+
if self.options.enable_catch:
62+
self.requires("catch2/2.13.7")
63+
if self.options.enable_gmock or self.options.enable_gtest:
64+
self.requires("gtest/1.11.0")
65+
5466
def source(self):
5567
tools.get(**self.conan_data["sources"][self.version],
5668
destination=self._source_subfolder, strip_root=True)
@@ -62,10 +74,17 @@ def _configure_cmake(self):
6274
self._cmake.definitions["RC_ENABLE_RTTI"] = self.options.enable_rtti
6375
self._cmake.definitions["RC_ENABLE_TESTS"] = False
6476
self._cmake.definitions["RC_ENABLE_EXAMPLES"] = False
77+
self._cmake.definitions["RC_ENABLE_CATCH"] = self.options.enable_catch
78+
self._cmake.definitions["RC_ENABLE_GMOCK"] = self.options.enable_gmock
79+
self._cmake.definitions["RC_ENABLE_GTEST"] = self.options.enable_gtest
6580
self._cmake.configure(build_folder=self._build_subfolder)
6681
return self._cmake
6782

6883
def build(self):
84+
if self.options.enable_gmock and not self.deps_cpp_info["gtest"].build_gmock:
85+
raise ConanInvalidConfiguration("The option `rapidcheck:enable_gmock` requires gtest:build_gmock=True`")
86+
for patch in self.conan_data["patches"][self.version]:
87+
tools.patch(**patch)
6988
cmake = self._configure_cmake()
7089
cmake.build()
7190

@@ -76,7 +95,10 @@ def package(self):
7695
tools.rmdir(os.path.join(self.package_folder, "share"))
7796
self._create_cmake_module_alias_targets(
7897
os.path.join(self.package_folder, self._module_file_rel_path),
79-
{"rapidcheck": "rapidcheck::rapidcheck"}
98+
{"rapidcheck": "rapidcheck::rapidcheck",
99+
"rapidcheck_catch":"rapidcheck::rapidcheck_catch",
100+
"rapidcheck_gmock": "rapidcheck::rapidcheck_gmock",
101+
"rapidcheck_gtest": "rapidcheck::rapidcheck_gtest"}
80102
)
81103

82104
@staticmethod
@@ -103,15 +125,23 @@ def _module_file_rel_path(self):
103125
def package_info(self):
104126
self.cpp_info.names["cmake_find_package"] = "rapidcheck"
105127
self.cpp_info.names["cmake_find_package_multi"] = "rapidcheck"
106-
self.cpp_info.builddirs.append(self._module_subfolder)
107-
self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path]
108-
self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path]
109-
self.cpp_info.libs = ["rapidcheck"]
110128

129+
self.cpp_info.components["rapidcheck_rapidcheck"].set_property("cmake_target_name", "rapidcheck")
130+
self.cpp_info.components["rapidcheck_rapidcheck"].builddirs.append(self._module_subfolder)
131+
self.cpp_info.components["rapidcheck_rapidcheck"].set_property("cmake_build_modules", [self._module_file_rel_path])
132+
self.cpp_info.components["rapidcheck_rapidcheck"].libs = ["rapidcheck"]
111133
version = self.version[4:]
112134
if tools.Version(version) < "20201218":
113135
if self.options.enable_rtti:
114-
self.cpp_info.defines.append("RC_USE_RTTI")
136+
self.cpp_info.components["rapidcheck_rapidcheck"].defines.append("RC_USE_RTTI")
115137
else:
116138
if not self.options.enable_rtti:
117-
self.cpp_info.defines.append("RC_DONT_USE_RTTI")
139+
self.cpp_info.components["rapidcheck_rapidcheck"].defines.append("RC_DONT_USE_RTTI")
140+
141+
if self.options.enable_catch:
142+
self.cpp_info.components["rapidcheck_catch"].requires = ["rapidcheck_rapidcheck", "catch2::catch2"]
143+
if self.options.enable_gmock:
144+
self.cpp_info.components["rapidcheck_gmock"].requires = ["rapidcheck_rapidcheck", "gtest::gtest"]
145+
if self.options.enable_gtest:
146+
self.cpp_info.components["rapidcheck_gtest"].requires = ["rapidcheck_rapidcheck", "gtest::gtest"]
147+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 92bc63c7df2cb87b5e5672a7651dbb4eafa3aaa7..14000896cd4e6ebcde3f2154b85caf4f5cca056b 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -106,8 +106,6 @@ if(RC_ENABLE_RTTI)
6+
target_compile_definitions(rapidcheck PUBLIC RC_USE_RTTI)
7+
endif()
8+
9+
-add_subdirectory(ext)
10+
-
11+
if(RC_ENABLE_TESTS)
12+
enable_testing()
13+
add_subdirectory(test)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 9f583afc171fab0a6894ffd64a0c787fd806bbaa..ea31145f55fe1010fe36739c17a655309db552f1 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -106,8 +106,6 @@ if(NOT RC_ENABLE_RTTI)
6+
target_compile_definitions(rapidcheck PUBLIC RC_DONT_USE_RTTI)
7+
endif()
8+
9+
-add_subdirectory(ext)
10+
-
11+
if(RC_ENABLE_TESTS)
12+
enable_testing()
13+
add_subdirectory(test)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 15c46d01288dce235179b791770187f5a38230ab..1805354a744931086622c41fa5a640c283142adc 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -111,8 +111,6 @@ if(NOT RC_ENABLE_RTTI)
6+
target_compile_definitions(rapidcheck PUBLIC RC_DONT_USE_RTTI)
7+
endif()
8+
9+
-add_subdirectory(ext)
10+
-
11+
if(RC_ENABLE_TESTS)
12+
enable_testing()
13+
add_subdirectory(test)

recipes/rapidcheck/all/test_package/conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ def build(self):
1212
cmake.build()
1313

1414
def test(self):
15-
if not tools.cross_building(self.settings):
15+
if not tools.cross_building(self):
1616
bin_path = os.path.join("bin", "test_package")
1717
self.run(bin_path, run_environment=True)

0 commit comments

Comments
 (0)