diff --git a/recipes/rapidcheck/all/conandata.yml b/recipes/rapidcheck/all/conandata.yml index 8da55e3fd71a1..d2e9cdaceb7da 100644 --- a/recipes/rapidcheck/all/conandata.yml +++ b/recipes/rapidcheck/all/conandata.yml @@ -8,3 +8,13 @@ sources: "cci.20200131": url: "https://github.com/emil-e/rapidcheck/archive/258d907da00a0855f92c963d8f76eef115531716.zip" sha256: "87bfbdceaa09e7aaaf70b2efd0078e93323dd8abdad48c57e9f23bfd84174a75" +patches: + "cci.20210702": + - patch_file: "patches/0001-gtest-catch-integration.patch" + base_path: "source_subfolder" + "cci.20210107": + - patch_file: "patches/0001-gtest-catch-integration-20210107.patch" + base_path: "source_subfolder" + "cci.20200131": + - patch_file: "patches/0001-gtest-catch-integration-20200131.patch" + base_path: "source_subfolder" diff --git a/recipes/rapidcheck/all/conanfile.py b/recipes/rapidcheck/all/conanfile.py index 88b9e3ebce22c..0e41ed0c926ad 100644 --- a/recipes/rapidcheck/all/conanfile.py +++ b/recipes/rapidcheck/all/conanfile.py @@ -13,18 +13,24 @@ class RapidcheckConan(ConanFile): homepage = "https://github.com/emil-e/rapidcheck" license = "BSD-2-Clause" topics = "quickcheck", "testing", "property-testing" - exports_sources = "CMakeLists.txt" - generators = "cmake" + exports_sources = ["CMakeLists.txt", "patches/**"] + generators = ["cmake", "cmake_find_package"] settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "enable_rtti": [True, False], + "enable_catch": [True, False], + "enable_gmock": [True, False], + "enable_gtest": [True, False] } default_options = { "shared": False, "fPIC": True, "enable_rtti": True, + "enable_catch": False, + "enable_gmock": False, + "enable_gtest": False } _cmake = None @@ -51,6 +57,12 @@ def validate(self): if self.settings.compiler == "Visual Studio" and self.options.shared: raise ConanInvalidConfiguration("shared is not supported using Visual Studio") + def requirements(self): + if self.options.enable_catch: + self.requires("catch2/2.13.7") + if self.options.enable_gmock or self.options.enable_gtest: + self.requires("gtest/1.11.0") + def source(self): tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) @@ -62,10 +74,17 @@ def _configure_cmake(self): self._cmake.definitions["RC_ENABLE_RTTI"] = self.options.enable_rtti self._cmake.definitions["RC_ENABLE_TESTS"] = False self._cmake.definitions["RC_ENABLE_EXAMPLES"] = False + self._cmake.definitions["RC_ENABLE_CATCH"] = self.options.enable_catch + self._cmake.definitions["RC_ENABLE_GMOCK"] = self.options.enable_gmock + self._cmake.definitions["RC_ENABLE_GTEST"] = self.options.enable_gtest self._cmake.configure(build_folder=self._build_subfolder) return self._cmake def build(self): + if self.options.enable_gmock and not self.deps_cpp_info["gtest"].build_gmock: + raise ConanInvalidConfiguration("The option `rapidcheck:enable_gmock` requires gtest:build_gmock=True`") + for patch in self.conan_data["patches"][self.version]: + tools.patch(**patch) cmake = self._configure_cmake() cmake.build() @@ -76,7 +95,10 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "share")) self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), - {"rapidcheck": "rapidcheck::rapidcheck"} + {"rapidcheck": "rapidcheck::rapidcheck", + "rapidcheck_catch":"rapidcheck::rapidcheck_catch", + "rapidcheck_gmock": "rapidcheck::rapidcheck_gmock", + "rapidcheck_gtest": "rapidcheck::rapidcheck_gtest"} ) @staticmethod @@ -103,15 +125,23 @@ def _module_file_rel_path(self): def package_info(self): self.cpp_info.names["cmake_find_package"] = "rapidcheck" self.cpp_info.names["cmake_find_package_multi"] = "rapidcheck" - self.cpp_info.builddirs.append(self._module_subfolder) - self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] - self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] - self.cpp_info.libs = ["rapidcheck"] + self.cpp_info.components["rapidcheck_rapidcheck"].set_property("cmake_target_name", "rapidcheck") + self.cpp_info.components["rapidcheck_rapidcheck"].builddirs.append(self._module_subfolder) + self.cpp_info.components["rapidcheck_rapidcheck"].set_property("cmake_build_modules", [self._module_file_rel_path]) + self.cpp_info.components["rapidcheck_rapidcheck"].libs = ["rapidcheck"] version = self.version[4:] if tools.Version(version) < "20201218": if self.options.enable_rtti: - self.cpp_info.defines.append("RC_USE_RTTI") + self.cpp_info.components["rapidcheck_rapidcheck"].defines.append("RC_USE_RTTI") else: if not self.options.enable_rtti: - self.cpp_info.defines.append("RC_DONT_USE_RTTI") + self.cpp_info.components["rapidcheck_rapidcheck"].defines.append("RC_DONT_USE_RTTI") + + if self.options.enable_catch: + self.cpp_info.components["rapidcheck_catch"].requires = ["rapidcheck_rapidcheck", "catch2::catch2"] + if self.options.enable_gmock: + self.cpp_info.components["rapidcheck_gmock"].requires = ["rapidcheck_rapidcheck", "gtest::gtest"] + if self.options.enable_gtest: + self.cpp_info.components["rapidcheck_gtest"].requires = ["rapidcheck_rapidcheck", "gtest::gtest"] + diff --git a/recipes/rapidcheck/all/patches/0001-gtest-catch-integration-20200131.patch b/recipes/rapidcheck/all/patches/0001-gtest-catch-integration-20200131.patch new file mode 100644 index 0000000000000..000892c7e9c5d --- /dev/null +++ b/recipes/rapidcheck/all/patches/0001-gtest-catch-integration-20200131.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 92bc63c7df2cb87b5e5672a7651dbb4eafa3aaa7..14000896cd4e6ebcde3f2154b85caf4f5cca056b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -106,8 +106,6 @@ if(RC_ENABLE_RTTI) + target_compile_definitions(rapidcheck PUBLIC RC_USE_RTTI) + endif() + +-add_subdirectory(ext) +- + if(RC_ENABLE_TESTS) + enable_testing() + add_subdirectory(test) diff --git a/recipes/rapidcheck/all/patches/0001-gtest-catch-integration-20210107.patch b/recipes/rapidcheck/all/patches/0001-gtest-catch-integration-20210107.patch new file mode 100644 index 0000000000000..ea5f3774d8053 --- /dev/null +++ b/recipes/rapidcheck/all/patches/0001-gtest-catch-integration-20210107.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 9f583afc171fab0a6894ffd64a0c787fd806bbaa..ea31145f55fe1010fe36739c17a655309db552f1 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -106,8 +106,6 @@ if(NOT RC_ENABLE_RTTI) + target_compile_definitions(rapidcheck PUBLIC RC_DONT_USE_RTTI) + endif() + +-add_subdirectory(ext) +- + if(RC_ENABLE_TESTS) + enable_testing() + add_subdirectory(test) diff --git a/recipes/rapidcheck/all/patches/0001-gtest-catch-integration.patch b/recipes/rapidcheck/all/patches/0001-gtest-catch-integration.patch new file mode 100644 index 0000000000000..5b6a9b2d92e33 --- /dev/null +++ b/recipes/rapidcheck/all/patches/0001-gtest-catch-integration.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 15c46d01288dce235179b791770187f5a38230ab..1805354a744931086622c41fa5a640c283142adc 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -111,8 +111,6 @@ if(NOT RC_ENABLE_RTTI) + target_compile_definitions(rapidcheck PUBLIC RC_DONT_USE_RTTI) + endif() + +-add_subdirectory(ext) +- + if(RC_ENABLE_TESTS) + enable_testing() + add_subdirectory(test) diff --git a/recipes/rapidcheck/all/test_package/conanfile.py b/recipes/rapidcheck/all/test_package/conanfile.py index 7e2dfe859bb27..49a3a66ea5bad 100644 --- a/recipes/rapidcheck/all/test_package/conanfile.py +++ b/recipes/rapidcheck/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True)