question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] `transitive_headers` not working as expected

See original GitHub issue

I have the following situation:

  • I have a library base that depends on a library audio which depends on the dr_wav library.
  • The base library includes the audio.hpp from the audio library which again includes the dr_wav.h header.

So there is a transitive header dependency to dr_wav from base and also from the test_package of the audio library.

graph TD;
    base-->audio;
    audio-->dr_wav;
    test_package_audio[audio test_package]-->audio;
    base-. transitive_headers .->dr_wav;
    test_package_audio-. transitive_headers .->dr_wav;

This works and builds fine when defining the dr_wav requires in audio with the transitive_headers option: self.requires("drwav/0.13.7", transitive_headers=True)

But now I also have a test_package for base which depends transitively on the dr_wav.h header:

graph TD;
    base-->audio;
    audio-->dr_wav;
    test_package_base[base test_package]-->base;
    test_package_base-. transitive_headers .->audio;
    test_package_base-. transitive_headers .->dr_wav;

I enabled the transitive_headers option also for the audio library dependency in base: self.requires("audio/1.0.0", transitive_headers=True)
Now the base test_package can find the audio.hpp header file, but not the dr_wav.h. I also checked the CMakeDeps generated files in the test_package and the drwav-release-x86_64-data.cmake file does not include the header directory:

set(drwav_INCLUDE_DIRS_RELEASE )
set(drwav_RES_DIRS_RELEASE )
set(drwav_DEFINITIONS_RELEASE )
set(drwav_SHARED_LINK_FLAGS_RELEASE )
set(drwav_EXE_LINK_FLAGS_RELEASE )
set(drwav_OBJECTS_RELEASE )
set(drwav_COMPILE_DEFINITIONS_RELEASE )
set(drwav_COMPILE_OPTIONS_C_RELEASE )
set(drwav_COMPILE_OPTIONS_CXX_RELEASE )
set(drwav_LIB_DIRS_RELEASE "${drwav_PACKAGE_FOLDER_RELEASE}/lib")
set(drwav_BIN_DIRS_RELEASE )
set(drwav_LIBRARY_TYPE_RELEASE STATIC)
set(drwav_IS_HOST_WINDOWS_RELEASE 0)
set(drwav_LIBS_RELEASE dr_wav)
set(drwav_SYSTEM_LIBS_RELEASE )
set(drwav_FRAMEWORK_DIRS_RELEASE )
set(drwav_FRAMEWORKS_RELEASE )
set(drwav_BUILD_DIRS_RELEASE )
set(drwav_NO_SONAME_MODE_RELEASE FALSE)

Am I missing something or could this even be a bug? I would expect transitive headers to be transitive over more than one dependency.

EDIT:

Implementation of minimal example from above can be found here: https://github.com/Linux13524/conan-transitive-headers

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
czoidocommented, Nov 11, 2022

Thanks for reporting @Linux13524, the fix: https://github.com/conan-io/conan/pull/12508 was merged and will be in next beta to be released soon.

0reactions
memshardedcommented, Nov 14, 2022

Thanks to you @Linux13524 ! Testing and giving feedback for the 2.0 is really appreciated!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it good practice to rely on headers being included transitively?
You should always include all headers defining any objects used in a .cpp file in that file regardless of what you know about...
Read more >
Publish and consume headers-only dependency transitively
No way to declare a header-only dependency. Both 'api' and 'implementation' dependencies expect a library and fail at link time. The workaround ...
Read more >
c++ - Is it common practive to #include header files already ...
In almost all my header files I would have to include <stdint.h> and ... To deal with potential problems of a header being...
Read more >
D132284 [libc++] Reduces the number of transitive includes.
This defines a new policy for removal of transitive includes. The goal of the policy it to make it relatively easy to remove...
Read more >
Include What You Use: transitive includes from associated .h file
I thought cpplint finds missing headers but doesn't find headers that are no longer needed, so it only solves half the problem. Maybe...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found