-
Notifications
You must be signed in to change notification settings - Fork 27
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 Request: Transitive headers settable #180
Comments
|
Hi @Eric-Bwr Thanks for your feedback.
I am not sure what you mean. Do you mean the requirement traits like when a conanfile does
You mean, the |
Hi @memsharded , thats quick :D I meant the package.py sry. So we have a conandata.yml, conanfile.py and package.py (the recipe for packaging our library). If we want to be able to set individual ones to true/false, wed have to do it like @knimix did in the comment above. Which is not beautiful. What do you mean with the arbitrary user conf? |
what is
I am not sure what you mean. Generally, dependencies are directly defined in def requirements(self):
self.requires("boost/1.82")
self.requires("zlib/1.3", transitive_headers=True)
... the package If you want to have a declarative interface for your dependencies in requirements:
boost/1.82:
transitive_headers: True
zlib/1.3:
other/2.1: And then something like: def requirements(self):
requirements = self.conan_data.get('requirements', [])
for req, traits in requirements.items():
self.requires(req, **traits) (Just a very rough idea, not tested, most likely doesn't work as-is) Is this what you want? |
@memsharded
So when I add that line (transitive_headers: True) which would be a nice interface, and then use the clion plugin, the entire config gets overwritten. |
Sure, the moment you start writing your own logic for your It is not possible to create a GUI interface for every possible variation or detail that can go in |
@memsharded |
I am afraid this is not possible, but I'll wait for @czoido feedback. It would be the equivalent to have CLion fully write your |
@memsharded |
No, no, you only need one file a I'd suggest following the tutorial in https://docs.conan.io/2/tutorial.html to understand the basic concepts about Conan. |
Hi @memsharded
But the conanfile for a package looks more Like this (
I thought it's not so good to put all these additional functions into the conanfile.py created by the plugin, so I created a package.py which just creates the missing stuff like the The question is would it then be possible for the plugin to create data such as name, version etc. without me having to do it myself? And also the missing functions like e.g. the package_info() Or maby integrate the I hope you could understand my steps |
Hi @knimix, Thanks for your suggestions. Unfortunately, covering the package creator case is not something the plugin can do, as it's outside its scope. However, you can still take advantage of the plugin and perform the creation steps yourself. Some tips for you: As @memsharded mentioned, you don't need both a Doing so, you could end up with a from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
class mylibraryRecipe(ConanFile):
name = "mylibrary"
version = "1.0"
package_type = "library"
# Optional metadata
license = "<Put the package license here>"
author = "<Put your name here> <And your email here>"
url = "<Package recipe repository url here, for issues about the package>"
description = "<Description of mylibrary package here>"
topics = ("<Put some tag here>", "<here>", "<and here>")
# Binary configuration
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
# Sources are located in the same place as this recipe, copy them to the recipe
exports_sources = "CMakeLists.txt", "src/*", "include/*"
def requirements(self):
requirements = self.conan_data.get('requirements', [])
for requirement in requirements:
self.requires(requirement)
def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
def layout(self):
cmake_layout(self)
def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
tc.user_presets_path = False
tc.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
cmake = CMake(self)
cmake.install()
def package_info(self):
self.cpp_info.libs = ["mylibrary"] a cmake_minimum_required(VERSION 3.26)
project(mylibrary)
set(CMAKE_CXX_STANDARD 17)
find_package(fmt)
add_library(mylibrary src/mylibrary.cpp)
target_include_directories(mylibrary PUBLIC "include")
set_target_properties(mylibrary PROPERTIES PUBLIC_HEADER "include/mylibrary.h")
target_link_libraries(mylibrary fmt::fmt)
install(TARGETS mylibrary) The structure of the project could look like this:
As long as you don't modify the Hope this helps. Please feel free to ask if you have any other questions. |
@czoido |
I need to be able to set transitive headers true / false for specific packages.
This is possible via the package xml.
But it is not really a beautiful interface to do so.
One would have to loop through the requirements and implement a switch case.
Feels a bit overlooked.
Maybe making it an argument in the conandata.yml would be cool.
At the moment this file will be overwritten when doing changes with the conan clion plugin.
The text was updated successfully, but these errors were encountered: