Skip to content

only headers package #18114

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

Open
1 task
highvoltagecontrol opened this issue Apr 12, 2025 · 2 comments
Open
1 task

only headers package #18114

highvoltagecontrol opened this issue Apr 12, 2025 · 2 comments
Assignees
Labels
staled The issue has been inactive for a while and will be closed soon

Comments

@highvoltagecontrol
Copy link

What is your question?

I have created only header package using the following conanfile.py:

class TypesmConan(ConanFile):
name = "types"
version = "1.0"
# No settings/options are necessary, this is header only
exports_sources = "include/*"
no_copy_source = True

def package(self):
    # This will also copy the "include" folder
    copy(self, "*.h", self.source_folder, self.package_folder)

def package_info(self):
    # For header-only packages, libdirs and bindirs are not used
    # so it's recommended to set those as empty.
    self.cpp_info.bindirs = []
    self.cpp_info.libdirs = []

How I can force conan to build custom name inside folder automatically during only header package creation as from example2? My custom folder have c/h files with their conanfile.py and CMakeLists.txt that suppose to build c/h files using only header package? The inside folder name is different than from example2 and it is not triggering the build...When I am changing the name to test_package and use the special requirment as self.requires(self.tested_reference_str), than automatic build is triggered but I dont want to use it only for tests but and a specific folder name but custom project of custom name...

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded memsharded self-assigned this Apr 13, 2025
@memsharded
Copy link
Member

Hi @highvoltagecontrol

Thanks for your question.

If you want to package a header-only, it can be important to add the package_type = "header-library" package type

It is true that there are some examples in https://docs.conan.io/2/tutorial/creating_packages/other_types_of_packages/header_only_packages.html, but it is true that the package_type and it is missing there, because those examples focus on some aspects like the package_info() and package_id() methods.

How I can force conan to build custom name inside folder automatically during only header package creation as from example2? My custom folder have c/h files with their conanfile.py and CMakeLists.txt that suppose to build c/h files using only header package? The inside folder name is different than from example2 and it is not triggering the build...When I am changing the name to test_package and use the special requirment as self.requires(self.tested_reference_str), than automatic build is triggered but I dont want to use it only for tests but and a specific folder name but custom project of custom name...

Sorry, I am afraid that I don't understand this question. My custom folder have c/h files with their conanfile.py and CMakeLists.txt that suppose to build c/h files using only header package?. But if your library contains .c files, then it is not a header-library, it would be regular library that needs to be compiled as either static or shared.

The inside folder name is different than from example2 and it is not triggering the build...When I am changing the name to test_package and use the special requirment as self.requires(self.tested_reference_str)

I am afraid that I don't understand this either.

The best way to clarify these kind of issues, would be to put a full minimal reproducible example in a repo and specify the exact commands you are using, with the output logs. It can be a fork of the examples2 repo, with your modifications for your question, or an independent repo just with the files you want.

Thanks for your feedback!

@memsharded
Copy link
Member

Hi @highvoltagecontrol

Any other question or comment here? Thanks for your feedback.

@memsharded memsharded added the staled The issue has been inactive for a while and will be closed soon label Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
staled The issue has been inactive for a while and will be closed soon
Projects
None yet
Development

No branches or pull requests

2 participants