Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAlexandr Timofeev2020-10-31 21:53:25 +0300
committerMartin Hořeňovský2020-11-02 15:37:35 +0100
commit3a15433d527269dcb9fc6452f279626173b94f1d (patch)
tree6b2f650db04572297d45ccf5a138f3876588461f
parent67a9561fb5547314c1bd740619e89034450774c1 (diff)
downloadcatch3-3a15433d527269dcb9fc6452f279626173b94f1d.tar.gz
Add support for Components
-rw-r--r--.conan/test_package/CMakeLists.txt15
-rw-r--r--.conan/test_package/conanfile.py5
-rw-r--r--conanfile.py20
3 files changed, 18 insertions, 22 deletions
diff --git a/.conan/test_package/CMakeLists.txt b/.conan/test_package/CMakeLists.txt
index 07e90602..6ee069c0 100644
--- a/.conan/test_package/CMakeLists.txt
+++ b/.conan/test_package/CMakeLists.txt
@@ -1,19 +1,12 @@
cmake_minimum_required(VERSION 3.2.0)
project(test_package CXX)
-# We set it only for the convenience of calling the executable
-# in the package test function
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
+include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
+conan_basic_setup()
find_package(Catch2 REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.cpp)
-# Note: Conan 1.21 doesn't support granular target generation yet.
-# The Main library would be included into the unified target.
-# It's controlled by the `with_main` option in the recipe.
-target_link_libraries(${PROJECT_NAME} Catch2::Catch2)
+
+target_link_libraries(${PROJECT_NAME} Catch2::Catch2WithMain)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14)
diff --git a/.conan/test_package/conanfile.py b/.conan/test_package/conanfile.py
index 9467bb36..069ace61 100644
--- a/.conan/test_package/conanfile.py
+++ b/.conan/test_package/conanfile.py
@@ -6,7 +6,7 @@ import os
class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
- generators = "cmake_find_package_multi"
+ generators = "cmake_find_package_multi", "cmake"
def build(self):
cmake = CMake(self)
@@ -14,6 +14,7 @@ class TestPackageConan(ConanFile):
cmake.build()
def test(self):
- assert os.path.isfile(os.path.join(self.deps_cpp_info["catch2"].rootpath, "licenses", "LICENSE.txt"))
+ assert os.path.isfile(os.path.join(
+ self.deps_cpp_info["catch2"].rootpath, "licenses", "LICENSE.txt"))
bin_path = os.path.join("bin", "test_package")
self.run("%s -s" % bin_path, run_environment=True)
diff --git a/conanfile.py b/conanfile.py
index 304444cf..7c597d49 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
from conans import ConanFile, CMake, tools
-
class CatchConan(ConanFile):
name = "catch2"
description = "A modern, C++-native, framework for unit-tests, TDD and BDD"
@@ -15,9 +14,6 @@ class CatchConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
- options = {"with_main": [True, False]}
- default_options = {"with_main": True}
-
generators = "cmake"
def _configure_cmake(self):
@@ -45,11 +41,17 @@ conan_basic_setup()'''.format(line_to_replace, self.install_folder.replace("\\",
cmake = self._configure_cmake()
cmake.install()
- def package_id(self):
- del self.info.options.with_main
-
def package_info(self):
- self.cpp_info.libs = [
- 'Catch2Main', 'Catch2'] if self.options.with_main else ['Catch2']
self.cpp_info.names["cmake_find_package"] = "Catch2"
self.cpp_info.names["cmake_find_package_multi"] = "Catch2"
+ # Catch2
+ self.cpp_info.components["catch2base"].names["cmake_find_package"] = "Catch2"
+ self.cpp_info.components["catch2base"].names["cmake_find_package_multi"] = "Catch2"
+ self.cpp_info.components["catch2base"].names["pkg_config"] = "Catch2"
+ self.cpp_info.components["catch2base"].libs = ["Catch2"]
+ # Catch2WithMain
+ self.cpp_info.components["catch2main"].names["cmake_find_package"] = "Catch2WithMain"
+ self.cpp_info.components["catch2main"].names["cmake_find_package_multi"] = "Catch2WithMain"
+ self.cpp_info.components["catch2main"].names["pkg_config"] = "Catch2WithMain"
+ self.cpp_info.components["catch2main"].libs = ["Catch2Main"]
+ self.cpp_info.components["catch2main"].requires = ["catch2base"]