Skip to content
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

[bug] editable mode broken for untypical header locations #16162

Closed
1 task done
Sickeroni opened this issue Apr 26, 2024 · 4 comments
Closed
1 task done

[bug] editable mode broken for untypical header locations #16162

Sickeroni opened this issue Apr 26, 2024 · 4 comments
Assignees

Comments

@Sickeroni
Copy link

Sickeroni commented Apr 26, 2024

Describe the bug

System details

WSL with ubuntu.22.04 under Windows 11
g++-12 (through apt)
cmake 3.29.2 (through snap)
Conan 2.2.3

The Problem

Situation

The main project uses a library that's also in development.
both use conan and are cmake projects.

The main project uses the conan provider file.
The library not. (Because forbidden)

The library is in editable mode.
The main project also uses the flag --build=editable

Now the special case of the project. The library got every headers (.hpp) in the directory ${PROJECT_SOURCE_DIR}/src.
The libary is for internal use only and uses many, many templates. Seperating files in 2 directories, even through real code is in both groups, is unfavorable and therefore not used.

Error

Not finding /include folder

Now the main Problem. The conan generated cmake files try to include [folder_to_project]/include. This fails because the directory does not exist in my local, editable directory.
Adding an empty include folder solved it, but is annoying.
The reason is, conan cache provides always an "include" folder. My library project not directly.

a testcase for this can be something like

target_sources(testman PUBLIC 
  FILE_SET HEADERS 
  FILES "${LIBRARY_SOURCE_DIR}/my/custom/subfolder/testman.hpp" 
  BASE_DIRS "${LIBRARY_SOURCE_DIR}")

To be more precise here.
That works for conan create . to update the local cache, but not conan editable add . and in main project install with --build=editable

Headers not provided

The previous solution was to create an empty include folder. This solves one error, but as a consequence now we miss the files. The used directory is empty :|

Expected result:

conan in editable mode should work as intended.
suggestion would be to create proper subfolders in the buildfolders identical to conan cache ones.

Assuming

It's also possible that inc include folders can be broken also.

How to reproduce it

as explained prior in more detail

  • create a lib (conan & cmake)
  • don't create the folder include
  • set library to editable mode (conan editable add .)
  • consume this library.

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded
Copy link
Member

Hi @Sickeroni

Thanks for your feedback.

We would need a conanfile.py that helps understanding this issue.
The editables are not magic, they need an explicit definition in the layout() method that matches the local layout at development time, the "editable" layout. If you are not using an include folder which is the default provided for example by cmake_layout(), you will need to customize the cmake_layout default definitions in your layout() method.

Can you please provide a reproducible case with a conanfile.py for the editable (together with the other full files that would be needed to reproduce). Thanks!

@memsharded
Copy link
Member

This would be a good docs to check regarding this: https://docs.conan.io/2/tutorial/developing_packages/package_layout.html

@Sickeroni
Copy link
Author

Sickeroni commented Apr 29, 2024

yep that solves my problem
thanks!

[edit]
I forgot the details/summary:
1: the cmake extension adds the directory include per default -> will be ignored for compiles, but in editable mode it is differently included and fails
also
2. the layout method itself needs to be changed to be compatible with editable mode -> extra steps in conanfile.py, that will work.

https://docs.conan.io/2/tutorial/developing_packages/package_layout.html for better details how to solve it

[/edit]

@memsharded
Copy link
Member

Thanks for the feedback, always happy to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants