From a606d1dfe6e118199be8a371403717e3e42ad5da Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Wed, 31 Jan 2024 16:16:02 -0500 Subject: [PATCH 1/9] Removed Conan1 build.py file using conan package tools that are no longer supported --- .conan/build.py | 94 ------------------------------------------------- conanfile.py | 46 ++++++++++++++++-------- 2 files changed, 32 insertions(+), 108 deletions(-) delete mode 100644 .conan/build.py mode change 100644 => 100755 conanfile.py diff --git a/.conan/build.py b/.conan/build.py deleted file mode 100644 index e163d5f46d..0000000000 --- a/.conan/build.py +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import re -from cpt.packager import ConanMultiPackager -from cpt.ci_manager import CIManager -from cpt.printer import Printer - - -class BuilderSettings(object): - @property - def username(self): - """ Set catchorg as package's owner - """ - return os.getenv("CONAN_USERNAME", "catchorg") - - @property - def login_username(self): - """ Set Bintray login username - """ - return os.getenv("CONAN_LOGIN_USERNAME", "horenmar") - - @property - def upload(self): - """ Set Catch2 repository to be used on upload. - The upload server address could be customized by env var - CONAN_UPLOAD. If not defined, the method will check the branch name. - Only devel or CONAN_STABLE_BRANCH_PATTERN will be accepted. - The devel branch will be pushed to testing channel, because it does - not match the stable pattern. Otherwise it will upload to stable - channel. - """ - return os.getenv("CONAN_UPLOAD", "https://api.bintray.com/conan/catchorg/catch2") - - @property - def upload_only_when_stable(self): - """ Force to upload when running over tag branch - """ - return os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", "True").lower() in ["true", "1", "yes"] - - @property - def stable_branch_pattern(self): - """ Only upload the package the branch name is like a tag - """ - return os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"v\d+\.\d+\.\d+") - - @property - def reference(self): - """ Read project version from branch create Conan reference - """ - return os.getenv("CONAN_REFERENCE", "catch2/{}".format(self._version)) - - @property - def channel(self): - """ Default Conan package channel when not stable - """ - return os.getenv("CONAN_CHANNEL", "testing") - - @property - def _version(self): - """ Get version name from cmake file - """ - pattern = re.compile(r"project\(Catch2 LANGUAGES CXX VERSION (\d+\.\d+\.\d+)\)") - version = "latest" - with open("CMakeLists.txt") as file: - for line in file: - result = pattern.search(line) - if result: - version = result.group(1) - return version - - @property - def _branch(self): - """ Get branch name from CI manager - """ - printer = Printer(None) - ci_manager = CIManager(printer) - return ci_manager.get_branch() - - -if __name__ == "__main__": - settings = BuilderSettings() - builder = ConanMultiPackager( - reference=settings.reference, - channel=settings.channel, - upload=settings.upload, - upload_only_when_stable=False, - stable_branch_pattern=settings.stable_branch_pattern, - login_username=settings.login_username, - username=settings.username, - test_folder=os.path.join(".conan", "test_package")) - builder.add() - builder.run() diff --git a/conanfile.py b/conanfile.py old mode 100644 new mode 100755 index 7aa27ef599..77611169dc --- a/conanfile.py +++ b/conanfile.py @@ -1,5 +1,8 @@ #!/usr/bin/env python -from conans import ConanFile, CMake, tools +from conan import ConanFile, tools +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools import files + class CatchConan(ConanFile): name = "catch2" @@ -14,30 +17,45 @@ class CatchConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + deps = CMakeDeps(self) + deps.generate() def _configure_cmake(self): cmake = CMake(self) - cmake.definitions["BUILD_TESTING"] = "OFF" - cmake.definitions["CATCH_INSTALL_DOCS"] = "OFF" - cmake.definitions["CATCH_INSTALL_EXTRAS"] = "ON" - cmake.configure(build_folder="build") + + # These are option variables. The toolchain in conan 2 doesn't appear to + # set these correctly so you have to do it in the configure variables. + cmake.configure(variables= { + "BUILD_TESTING": "OFF", + "CATCH_INSTALL_DOCS": "OFF", + "CATCH_INSTALL_EXTRAS": "ON", + } + ) return cmake + def build(self): - # We need this workaround until the toolchains feature - # to inject stuff like MD/MT - line_to_replace = 'list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")' - tools.replace_in_file("CMakeLists.txt", line_to_replace, - '''{} -include("{}/conanbuildinfo.cmake") -conan_basic_setup()'''.format(line_to_replace, self.install_folder.replace("\\", "/"))) +# # We need this workaround until the toolchains feature +# # to inject stuff like MD/MT +# line_to_replace = 'list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")' +# replacement_text = '''{} +# include("{}/conanbuildinfo.cmake") +# conan_basic_setup()'''.format(line_to_replace, self.package_folder.replace("\\", "/")) + +# files.replace_in_file(self, f"{self.source_folder}/CMakeLists.txt", line_to_replace, replacement_text) cmake = self._configure_cmake() cmake.build() def package(self): - self.copy(pattern="LICENSE.txt", dst="licenses") + files.copy(self, pattern="LICENSE.txt", src='.', dst="licenses") cmake = self._configure_cmake() cmake.install() From 1dd6f27b8df633ce63d58063a38180ec0b50710e Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Wed, 31 Jan 2024 17:13:55 -0500 Subject: [PATCH 2/9] Working conan 1 and 2 build with the test package. updated the test_package to be updated to conan 2 and fixed missing cmake. Still need to check that the license file is packaged up and that the packages look identical before the changes --- .conan/test_package/CMakeLists.txt | 15 +++++---------- .conan/test_package/conanfile.py | 23 +++++++++++++++++------ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.conan/test_package/CMakeLists.txt b/.conan/test_package/CMakeLists.txt index 6ee069c01e..e069aef34b 100644 --- a/.conan/test_package/CMakeLists.txt +++ b/.conan/test_package/CMakeLists.txt @@ -1,12 +1,7 @@ -cmake_minimum_required(VERSION 3.2.0) -project(test_package CXX) +cmake_minimum_required(VERSION 3.15) +project(PackageTest CXX) -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +find_package(Catch2 CONFIG REQUIRED) -find_package(Catch2 REQUIRED CONFIG) - -add_executable(${PROJECT_NAME} test_package.cpp) - -target_link_libraries(${PROJECT_NAME} Catch2::Catch2WithMain) -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14) +add_executable(test_package test_package.cpp) +target_link_libraries(test_package catch2::catch2main) \ No newline at end of file diff --git a/.conan/test_package/conanfile.py b/.conan/test_package/conanfile.py index 069ace61ef..c51befb0d7 100644 --- a/.conan/test_package/conanfile.py +++ b/.conan/test_package/conanfile.py @@ -1,12 +1,21 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from conans import ConanFile, CMake +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run import os class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake_find_package_multi", "cmake" + generators = "CMakeToolchain", "CMakeDeps" + + def requirements(self): + self.requires(self.tested_reference_str) + print(f'TESTED:: {self.tested_reference_str}') + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -14,7 +23,9 @@ def build(self): cmake.build() def test(self): - 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) + print(os.getcwd()) + print(self.package_folder) + + if can_run(self): + cmd = os.path.join(self.cpp.build.bindir, "test_package") + self.run(cmd, env="conanrun") From c7ca84d31c3e017305569d6e70fcfe92ff99acec Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Wed, 31 Jan 2024 17:15:00 -0500 Subject: [PATCH 3/9] Removing debug prints and the license check that isn't working yet --- .conan/test_package/conanfile.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.conan/test_package/conanfile.py b/.conan/test_package/conanfile.py index c51befb0d7..74571bb7d1 100644 --- a/.conan/test_package/conanfile.py +++ b/.conan/test_package/conanfile.py @@ -12,7 +12,6 @@ class TestPackageConan(ConanFile): def requirements(self): self.requires(self.tested_reference_str) - print(f'TESTED:: {self.tested_reference_str}') def layout(self): cmake_layout(self) @@ -23,9 +22,11 @@ def build(self): cmake.build() def test(self): - print(os.getcwd()) - print(self.package_folder) - if can_run(self): cmd = os.path.join(self.cpp.build.bindir, "test_package") self.run(cmd, env="conanrun") + + # catch2 = self.dependencies["catch2"] + # assert catch2.license == 'BSL-1.0' + # print(catch2.package_folder) + # # assert os.path.Path(catch2.) From c8f673a38c01458cdfd7a81dce648b0389862405 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Wed, 31 Jan 2024 22:23:19 -0500 Subject: [PATCH 4/9] Working license file copied over as it was before --- .conan/test_package/conanfile.py | 9 +++++---- conanfile.py | 7 ++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.conan/test_package/conanfile.py b/.conan/test_package/conanfile.py index 74571bb7d1..88f3d137fa 100644 --- a/.conan/test_package/conanfile.py +++ b/.conan/test_package/conanfile.py @@ -26,7 +26,8 @@ def test(self): cmd = os.path.join(self.cpp.build.bindir, "test_package") self.run(cmd, env="conanrun") - # catch2 = self.dependencies["catch2"] - # assert catch2.license == 'BSL-1.0' - # print(catch2.package_folder) - # # assert os.path.Path(catch2.) + # If we are on conan 2 we can check the license info is populated + if hasattr(self, 'dependencies'): + catch2 = self.dependencies["catch2"] + assert os.path.exists(f'{catch2.package_folder}/licenses/LICENSE.txt') + assert catch2.license == 'BSL-1.0' diff --git a/conanfile.py b/conanfile.py index 77611169dc..1847245750 100755 --- a/conanfile.py +++ b/conanfile.py @@ -2,6 +2,8 @@ from conan import ConanFile, tools from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout from conan.tools import files +import os +import shutil class CatchConan(ConanFile): @@ -11,6 +13,7 @@ class CatchConan(ConanFile): url = "https://github.com/catchorg/Catch2" homepage = url license = "BSL-1.0" + version = "latest" exports = "LICENSE.txt" exports_sources = ("src/*", "CMakeLists.txt", "CMake/*", "extras/*") @@ -55,10 +58,12 @@ def build(self): cmake.build() def package(self): - files.copy(self, pattern="LICENSE.txt", src='.', dst="licenses") cmake = self._configure_cmake() cmake.install() + os.mkdir(f'{self.package_folder}/licenses/') + shutil.copy2(f'{self.recipe_folder}/LICENSE.txt', f'{self.package_folder}/licenses/') + def package_info(self): lib_suffix = "d" if self.settings.build_type == "Debug" else "" From 0736bc264380874f2ae278998d86c14e001328d9 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Wed, 31 Jan 2024 22:56:13 -0500 Subject: [PATCH 5/9] Migrated the properties of cpp_info to conan 2. Keeping conan 1 support by checking the version of conan https://docs.conan.io/1/migrating_to_2.0/properties.html --- conanfile.py | 57 ++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/conanfile.py b/conanfile.py index 1847245750..e64952c680 100755 --- a/conanfile.py +++ b/conanfile.py @@ -1,7 +1,7 @@ #!/usr/bin/env python -from conan import ConanFile, tools +from conan import ConanFile, tools, __version__ as conan_version from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout -from conan.tools import files +from conan.tools import files, scm import os import shutil @@ -43,17 +43,7 @@ def _configure_cmake(self): ) return cmake - def build(self): -# # We need this workaround until the toolchains feature -# # to inject stuff like MD/MT -# line_to_replace = 'list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")' -# replacement_text = '''{} -# include("{}/conanbuildinfo.cmake") -# conan_basic_setup()'''.format(line_to_replace, self.package_folder.replace("\\", "/")) - -# files.replace_in_file(self, f"{self.source_folder}/CMakeLists.txt", line_to_replace, replacement_text) - cmake = self._configure_cmake() cmake.build() @@ -67,17 +57,32 @@ def package(self): def package_info(self): lib_suffix = "d" if self.settings.build_type == "Debug" else "" - 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" + lib_suffix] - self.cpp_info.components["catch2base"].builddirs.append("lib/cmake/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" + lib_suffix] - self.cpp_info.components["catch2main"].requires = ["catch2base"] + if conan_version < scm.Version("2.0.0"): + 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" + lib_suffix] + self.cpp_info.components["catch2base"].builddirs.append("lib/cmake/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" + lib_suffix] + self.cpp_info.components["catch2main"].requires = ["catch2base"] + else: + self.cpp_info.set_property("cmake_file_name", "Catch2") + + # Catch2 + self.cpp_info.components["catch2base"].set_property("cmake_file_name", "Catch2") + self.cpp_info.components["catch2base"].set_property("pkg_config_name", "Catch2") + self.cpp_info.components["catch2base"].libs = ["Catch2" + lib_suffix] + self.cpp_info.components["catch2base"].builddirs.append("lib/cmake/Catch2") + + # Catch2WithMain + self.cpp_info.components["catch2main"].set_property("cmake_file_name", "Catch2WithMain") + self.cpp_info.components["catch2main"].set_property("pkg_config_name", "Catch2WithMain") + self.cpp_info.components["catch2main"].libs = ["Catch2Main" + lib_suffix] + self.cpp_info.components["catch2main"].requires = ["catch2base"] \ No newline at end of file From c39d3bd0c80c4833a87ad3a663935ce4ed6c4072 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Wed, 31 Jan 2024 23:06:42 -0500 Subject: [PATCH 6/9] Revert "Removed Conan1 build.py file using conan package tools that are no longer supported" This reverts commit a606d1dfe6e118199be8a371403717e3e42ad5da. --- .conan/build.py | 94 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .conan/build.py diff --git a/.conan/build.py b/.conan/build.py new file mode 100644 index 0000000000..e163d5f46d --- /dev/null +++ b/.conan/build.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import re +from cpt.packager import ConanMultiPackager +from cpt.ci_manager import CIManager +from cpt.printer import Printer + + +class BuilderSettings(object): + @property + def username(self): + """ Set catchorg as package's owner + """ + return os.getenv("CONAN_USERNAME", "catchorg") + + @property + def login_username(self): + """ Set Bintray login username + """ + return os.getenv("CONAN_LOGIN_USERNAME", "horenmar") + + @property + def upload(self): + """ Set Catch2 repository to be used on upload. + The upload server address could be customized by env var + CONAN_UPLOAD. If not defined, the method will check the branch name. + Only devel or CONAN_STABLE_BRANCH_PATTERN will be accepted. + The devel branch will be pushed to testing channel, because it does + not match the stable pattern. Otherwise it will upload to stable + channel. + """ + return os.getenv("CONAN_UPLOAD", "https://api.bintray.com/conan/catchorg/catch2") + + @property + def upload_only_when_stable(self): + """ Force to upload when running over tag branch + """ + return os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", "True").lower() in ["true", "1", "yes"] + + @property + def stable_branch_pattern(self): + """ Only upload the package the branch name is like a tag + """ + return os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"v\d+\.\d+\.\d+") + + @property + def reference(self): + """ Read project version from branch create Conan reference + """ + return os.getenv("CONAN_REFERENCE", "catch2/{}".format(self._version)) + + @property + def channel(self): + """ Default Conan package channel when not stable + """ + return os.getenv("CONAN_CHANNEL", "testing") + + @property + def _version(self): + """ Get version name from cmake file + """ + pattern = re.compile(r"project\(Catch2 LANGUAGES CXX VERSION (\d+\.\d+\.\d+)\)") + version = "latest" + with open("CMakeLists.txt") as file: + for line in file: + result = pattern.search(line) + if result: + version = result.group(1) + return version + + @property + def _branch(self): + """ Get branch name from CI manager + """ + printer = Printer(None) + ci_manager = CIManager(printer) + return ci_manager.get_branch() + + +if __name__ == "__main__": + settings = BuilderSettings() + builder = ConanMultiPackager( + reference=settings.reference, + channel=settings.channel, + upload=settings.upload, + upload_only_when_stable=False, + stable_branch_pattern=settings.stable_branch_pattern, + login_username=settings.login_username, + username=settings.username, + test_folder=os.path.join(".conan", "test_package")) + builder.add() + builder.run() From b4510aa1fa60bd38ae8c825d8f76dedfa45847f7 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Wed, 31 Jan 2024 23:23:58 -0500 Subject: [PATCH 7/9] Need to add a set_version to parse the version from CMakeLists.txt Adding a package build yaml to ensure conan keeps building on 1 and 2 --- .github/workflows/package-manager-builds.yaml | 31 +++++++++++++++++++ .gitignore | 1 + conanfile.py | 11 +++++++ 3 files changed, 43 insertions(+) create mode 100644 .github/workflows/package-manager-builds.yaml diff --git a/.github/workflows/package-manager-builds.yaml b/.github/workflows/package-manager-builds.yaml new file mode 100644 index 0000000000..cb55b753ee --- /dev/null +++ b/.github/workflows/package-manager-builds.yaml @@ -0,0 +1,31 @@ +name: Package Manager Builds + +on: [push, pull_request] + +jobs: + conan_builds: + name: Conan ${{matrix.conan_version}} + runs-on: ubuntu-20.04 + strategy: + matrix: + conan_version: + - '1.62' + - '2.0' + + include: + # Conan 1 has default profiles installed + - conan_version: '1.62' + profile_generate: 'false' + + steps: + - uses: actions/checkout@v4 + + - name: Install conan + run: pip install conan==${{matrix.conan_version}} + + - name: Setup conan profiles + if: matrix.profile_generate != 'false' + run: conan profile detect + + - name: Run conan package create + run: conan create . -tf .conan/test_package diff --git a/.gitignore b/.gitignore index 27f6bc0b30..4ed76b0b3f 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ Build cmake-build-* benchmark-dir .conan/test_package/build +.conan/test_package/CMakeUserPresets.json bazel-* build-fuzzers debug-build diff --git a/conanfile.py b/conanfile.py index e64952c680..1ae636070e 100755 --- a/conanfile.py +++ b/conanfile.py @@ -4,6 +4,7 @@ from conan.tools import files, scm import os import shutil +import re class CatchConan(ConanFile): @@ -20,6 +21,16 @@ class CatchConan(ConanFile): settings = "os", "compiler", "build_type", "arch" + def set_version(self): + pattern = re.compile(r"\w*VERSION (\d+\.\d+\.\d+) # CML version placeholder, don't delete") + with open("CMakeLists.txt") as file: + for line in file: + result = pattern.search(line) + if result: + self.version = result.group(1) + + self.output.info(f'Using version: {self.version}') + def layout(self): cmake_layout(self) From 526f4473560128e1e435615369b2a90682bd8870 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Fri, 2 Feb 2024 23:09:06 -0500 Subject: [PATCH 8/9] Setting lowercase catch2 for pkg_config and cmake_target_name --- conanfile.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/conanfile.py b/conanfile.py index 1ae636070e..1482295a07 100755 --- a/conanfile.py +++ b/conanfile.py @@ -74,7 +74,7 @@ def package_info(self): # 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"].names["pkg_config"] = "catch2" self.cpp_info.components["catch2base"].libs = ["Catch2" + lib_suffix] self.cpp_info.components["catch2base"].builddirs.append("lib/cmake/Catch2") # Catch2WithMain @@ -85,15 +85,18 @@ def package_info(self): self.cpp_info.components["catch2main"].requires = ["catch2base"] else: self.cpp_info.set_property("cmake_file_name", "Catch2") + self.cpp_info.set_property("cmake_target_name", "Catch2WithMain") + self.cpp_info.set_property("pkg_config_name", "catch2-with-main") # Catch2 self.cpp_info.components["catch2base"].set_property("cmake_file_name", "Catch2") - self.cpp_info.components["catch2base"].set_property("pkg_config_name", "Catch2") + self.cpp_info.components["catch2base"].set_property("pkg_config_name", "catch2") self.cpp_info.components["catch2base"].libs = ["Catch2" + lib_suffix] self.cpp_info.components["catch2base"].builddirs.append("lib/cmake/Catch2") # Catch2WithMain self.cpp_info.components["catch2main"].set_property("cmake_file_name", "Catch2WithMain") - self.cpp_info.components["catch2main"].set_property("pkg_config_name", "Catch2WithMain") + self.cpp_info.components["catch2main"].set_property("cmake_target_name", "Catch2WithMain") + self.cpp_info.components["catch2main"].set_property("pkg_config_name", "catch2-with-main") self.cpp_info.components["catch2main"].libs = ["Catch2Main" + lib_suffix] self.cpp_info.components["catch2main"].requires = ["catch2base"] \ No newline at end of file From a0419433725c93defca098af82e501e33fa1df44 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Fri, 2 Feb 2024 23:16:47 -0500 Subject: [PATCH 9/9] Fixing the namespace for conan file cmake_target_name --- .conan/test_package/CMakeLists.txt | 2 +- conanfile.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.conan/test_package/CMakeLists.txt b/.conan/test_package/CMakeLists.txt index e069aef34b..ff9496adb4 100644 --- a/.conan/test_package/CMakeLists.txt +++ b/.conan/test_package/CMakeLists.txt @@ -4,4 +4,4 @@ project(PackageTest CXX) find_package(Catch2 CONFIG REQUIRED) add_executable(test_package test_package.cpp) -target_link_libraries(test_package catch2::catch2main) \ No newline at end of file +target_link_libraries(test_package Catch2::Catch2WithMain) \ No newline at end of file diff --git a/conanfile.py b/conanfile.py index 1482295a07..2edb475b84 100755 --- a/conanfile.py +++ b/conanfile.py @@ -85,18 +85,18 @@ def package_info(self): self.cpp_info.components["catch2main"].requires = ["catch2base"] else: self.cpp_info.set_property("cmake_file_name", "Catch2") - self.cpp_info.set_property("cmake_target_name", "Catch2WithMain") + self.cpp_info.set_property("cmake_target_name", "Catch2::Catch2WithMain") self.cpp_info.set_property("pkg_config_name", "catch2-with-main") # Catch2 - self.cpp_info.components["catch2base"].set_property("cmake_file_name", "Catch2") + self.cpp_info.components["catch2base"].set_property("cmake_file_name", "Catch2::Catch2") self.cpp_info.components["catch2base"].set_property("pkg_config_name", "catch2") self.cpp_info.components["catch2base"].libs = ["Catch2" + lib_suffix] self.cpp_info.components["catch2base"].builddirs.append("lib/cmake/Catch2") # Catch2WithMain - self.cpp_info.components["catch2main"].set_property("cmake_file_name", "Catch2WithMain") - self.cpp_info.components["catch2main"].set_property("cmake_target_name", "Catch2WithMain") + self.cpp_info.components["catch2main"].set_property("cmake_file_name", "Catch2::Catch2WithMain") + self.cpp_info.components["catch2main"].set_property("cmake_target_name", "Catch2::Catch2WithMain") self.cpp_info.components["catch2main"].set_property("pkg_config_name", "catch2-with-main") self.cpp_info.components["catch2main"].libs = ["Catch2Main" + lib_suffix] self.cpp_info.components["catch2main"].requires = ["catch2base"] \ No newline at end of file