-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Conan v2 #2805
Merged
Merged
Conan v2 #2805
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a606d1d
Removed Conan1 build.py file using conan package tools that are no lo…
LinuxDevon 1dd6f27
Working conan 1 and 2 build with the test package.
LinuxDevon c7ca84d
Removing debug prints and the license check that isn't working yet
LinuxDevon c8f673a
Working license file copied over as it was before
LinuxDevon 0736bc2
Migrated the properties of cpp_info to conan 2. Keeping conan 1 suppo…
LinuxDevon c39d3bd
Revert "Removed Conan1 build.py file using conan package tools that a…
LinuxDevon b4510aa
Need to add a set_version to parse the version from CMakeLists.txt
LinuxDevon 526f447
Setting lowercase catch2 for pkg_config and cmake_target_name
LinuxDevon a041943
Fixing the namespace for conan file cmake_target_name
LinuxDevon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,33 @@ | ||
#!/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) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
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) | ||
if can_run(self): | ||
cmd = os.path.join(self.cpp.build.bindir, "test_package") | ||
self.run(cmd, env="conanrun") | ||
|
||
# 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do specify
cmake_target_name
similar tohttps://github.com/conan-io/conan-center-index/blob/master/recipes/catch2/3.x.x/conanfile.py#L168
That way you would be able to correctly use
Catch2::Catch2WithMain
target instead of the lowercase.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think i did this. I kept the
cmake_file_name
but not sure if that matters.I also didn't realize that the conan file for conan.io is separate from this repo. So will this close the issue in reference? Maybe if it is maintained over there we just drop the conan files here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Conan Center policy is to maintain recipes for the default repo so in-source conanfiles are only needed for project-specific development. I'm not sure how many people require it so it's up to the maintainer in here to decide if it's still needed.
Regarding this specific PR -
cmake_target_name
is used for the target name. It needs to be specified with namespace because of the different filename to namespace to target to component conventions different projects have.cmake_file_name
is needed only for thefind_package
syntax, it's not useful for components and it doesn't make sense to specify the target name in there. The global levelcmake_target_name
I think refers to the target which is wired on Conan-level global component dependencies, it's not actually used in CMake.Additionally, prefer
os.path.join
over the/
directory separator for cross-environment compatibility.