Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds rapidcheck gtest/catch integrations #7394

Merged
merged 12 commits into from
Sep 28, 2021
52 changes: 45 additions & 7 deletions recipes/rapidcheck/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,21 @@ class RapidcheckConan(ConanFile):
"shared": [True, False],
"fPIC": [True, False],
"enable_rtti": [True, False],
"enable_catch": [True, False],
"enable_gmock": [True, False],
"enable_gtest": [True, False],
"enable_boost": [True, False],
"enable_boost_test": [True, False]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be one option?

Suggested change
"enable_catch": [True, False],
"enable_gmock": [True, False],
"enable_gtest": [True, False],
"enable_boost": [True, False],
"enable_boost_test": [True, False]
"enable_framework": [False, "catch", "gmock", "gtest", "boost", "boost_test"],

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I don't think so as you can enable multiple integrations at the same time.

}
default_options = {
"shared": False,
"fPIC": True,
"enable_rtti": True,
"enable_catch": False,
"enable_gmock": False,
"enable_gtest": False,
"enable_boost": False,
"enable_boost_test": False
}

_cmake = None
Expand Down Expand Up @@ -62,6 +72,11 @@ 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.definitions["RC_ENABLE_BOOST"] = self.options.enable_boost
self._cmake.definitions["RC_ENABLE_BOOST_TEST"] = self.options.enable_boost_test
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake

Expand All @@ -76,7 +91,12 @@ 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::catch",
"rapidcheck_gmock": "rapidcheck::gmock",
"rapidcheck_gtest": "rapidcheck::gtest",
"rapidcheck_boost": "rapidcheck::boost",
"rapidcheck_boost_test": "rapidcheck::boost_test"}
)

@staticmethod
Expand All @@ -103,15 +123,33 @@ 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["core"].set_property("cmake_target_name", "rapidcheck")
self.cpp_info.components["core"].builddirs.append(self._module_subfolder)
self.cpp_info.components["core"].set_property("cmake_build_modules", [self._module_file_rel_path])
self.cpp_info.components["core"].libs = ["rapidcheck"]
self.cpp_info.components["core"].includedirs = ["include"]
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["core"].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["core"].defines.append("RC_DONT_USE_RTTI")

if(self.options.enable_catch):
self.cpp_info.components["catch"].requires = ["core"]
self.cpp_info.components["catch"].includedirs = ["include"]
if(self.options.enable_gmock):
self.cpp_info.components["gmock"].requires = ["core"]
self.cpp_info.components["gmock"].includedirs = ["include"]
if(self.options.enable_gtest):
self.cpp_info.components["gtest"].requires = ["core"]
self.cpp_info.components["gtest"].includedirs = ["include"]
if(self.options.enable_boost):
self.cpp_info.components["boost"].requires = ["core"]
self.cpp_info.components["boost"].includedirs = ["include"]
if(self.options.enable_boost_test):
self.cpp_info.components["boost_test"].requires = ["core"]
self.cpp_info.components["boost_test"].includedirs = ["include"]
mjvankampen marked this conversation as resolved.
Show resolved Hide resolved

2 changes: 1 addition & 1 deletion recipes/rapidcheck/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)