-
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
Cannot find target Boost::boost after add_subdirectory #41
Comments
However, with |
Thanks @pdimov! In my project's native build system, Boost is already installed, and What would you suggest as the best way for my use case? Would I best use some if-else logic and explicitly link to individual Boost libraries if detect cross-compilation? Ty! |
I think that you can create the target
where |
Thank you very much @pdimov! As a followup question, Do you happen to know what's special about it that it lacks a top-level CMakeLists.txt, and what should one do to make As a reference, |
I submitted a pull request (boostorg/ublas#142) to add a CMakeLists.txt file to |
TLDR: Is there a way where a project uses header-only components of the Boost libraries, and avoid building them, with the above Hi @pdimov , sorry that I am extending on this thread. Pls let me know if I'd better take these how-to questions to another thread, and close this issue (since it is not a boostorg/cmake bug!). First, thanks for pointing me to the ublas PR. I patched with the PR change and unblocked. However, my project should only need header-only Boost. Due to its cross-compilation nature, I'd like to avoid building the Boost CXX objects since it suffices as long as headers are included. However, with the above approach through Below is how I'm using Boost in my project. Does it look like I am doing something obviously off? Ty!!
My suspicion is that, a bunch of transitive boost deps are being built due to |
Your guess seems correct; I'm not sure how this can be fixed; in CMake, if you link to a library, you link to its transitive dependencies, which means they will have to be built. You can in principle patch the CMakeLists.txt file for As for copying the headers somewhere, that's what the installation step does. I don't think it's possible to achieve this effect with |
Thank you very much @pdimov! That makes a lot of sense to me. Given what you said, I experimented with using
This seems to imply that deps transitivity is resolved with |
That is how it works, yes. I still don't see a better way to accomplish what you want than removing |
Thank you @pdimov!! Removing these two deps uncovers issue of my own understanding - even though my main project depends on header-only boost, my test has indirect dependency on |
Closing the issue since @pdimov has explained this to be the intended behavior with add_subdirectory usage, and suggested working solutions. Ty! |
My project git checks out Boost's source code to a subdirectory, and adds it through
add_subdirectory
. I'd like to useBoost::boost
in my main project viatarget_link_libraries(myTarget INTERFACE Boost::boost)
. HoweverBoost::boost
is not recognized while the other individual boost libraries work fine.I looked into
config/BoostConfig.cmake
and found thatBoost::boost
is added as a target here - however BoostConfig.cmake is NOT installed ifBOOST_SKIP_INSTALL_RULES
orBOOST_SKIP_INSTALL_RULES
- in this case is true because I am not installing Boost as project root, but rather added as a subdirectory.It seems that making
Boost::boost
available in theadd_subdirectory
use case would be a correct solution. Can someone (1) help me understand what's the correct way I can workaround it? And (2) Would be make sense to open this as a feature request, or do I miss the intended usage here?The text was updated successfully, but these errors were encountered: