-
Notifications
You must be signed in to change notification settings - Fork 994
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
Feature: update conan new to latest guidelines #8106
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,10 +22,14 @@ class {package_name}Conan(ConanFile): | |
description = "<Description of {package_name} here>" | ||
topics = ("<Put some tag here>", "<here>", "<and here>") | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = {{"shared": [True, False]}} | ||
default_options = {{"shared": False}} | ||
options = {{"shared": [True, False], "fPIC": [True, False]}} | ||
default_options = {{"shared": False, "fPIC": True}} | ||
generators = "cmake" | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def source(self): | ||
self.run("git clone https://github.com/conan-io/hello.git") | ||
# This small hack might be useful to guarantee proper /MT /MD linkage | ||
|
@@ -91,11 +95,15 @@ class {package_name}Conan(ConanFile): | |
description = "<Description of {package_name} here>" | ||
topics = ("<Put some tag here>", "<here>", "<and here>") | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = {{"shared": [True, False]}} | ||
default_options = {{"shared": False}} | ||
options = {{"shared": [True, False], "fPIC": [True, False]}} | ||
default_options = {{"shared": False, "fPIC": True}} | ||
SSE4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
generators = "cmake" | ||
exports_sources = "src/*" | ||
{configure} | ||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure(source_folder="src") | ||
|
@@ -145,6 +153,9 @@ def source(self): | |
|
||
def package(self): | ||
self.copy("*.h", "include") | ||
|
||
def package_id(self): | ||
self.info.header_only() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand this is more explicit than just a recipe without settings, but we are adding more code here that is unneeded. If this is a pattern followed in CCI for example, then I am ok with it. Maybe we should consider it for conan 2.0 (enforce settings always?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it might be error prone without explicit, e.g. if you add some settings and options to the recipe after running
I believe the same package id is expected to be generated regardless of requires, which is not the case in the current template. |
||
""" | ||
|
||
|
||
|
@@ -175,7 +186,7 @@ def test(self): | |
self.run(".%sexample" % os.sep) | ||
""" | ||
|
||
test_cmake = """cmake_minimum_required(VERSION 2.8.12) | ||
test_cmake = """cmake_minimum_required(VERSION 3.1) | ||
project(PackageTest CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
|
@@ -191,7 +202,7 @@ def test(self): | |
# COMMAND example) | ||
""" | ||
|
||
test_cmake_pure_c = """cmake_minimum_required(VERSION 2.8.12) | ||
test_cmake_pure_c = """cmake_minimum_required(VERSION 3.1) | ||
project(PackageTest C) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
|
@@ -250,7 +261,7 @@ def test(self): | |
}} | ||
""" | ||
|
||
cmake_pure_c = """cmake_minimum_required(VERSION 2.8) | ||
cmake_pure_c = """cmake_minimum_required(VERSION 3.1) | ||
project({name} C) | ||
|
||
include(${{CMAKE_BINARY_DIR}}/conanbuildinfo.cmake) | ||
|
@@ -259,7 +270,7 @@ def test(self): | |
add_library({name} {name}.c) | ||
""" | ||
|
||
cmake = """cmake_minimum_required(VERSION 2.8) | ||
cmake = """cmake_minimum_required(VERSION 3.1) | ||
project({name} CXX) | ||
|
||
include(${{CMAKE_BINARY_DIR}}/conanbuildinfo.cmake) | ||
|
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 am fairly certain this is also expected during review
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.
Not completely sure, many recipes do not implement it yet. I would say wait until this is discussed a bit more, seems that some Conan built-in helpers would be better.
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.
agree
this code has 361 occurrences on CCI
this one is only 264.
so, probably, it might be too early to enforce that, as it's not an established practice on CCI.
earlier we also had proposal for so called
shared_library_package_id
to be used in recipes, I don't remember what was a conclusion.we need to talk about these two IMO before we start to recommend them.