Understanding exports_sources and CMake's add_subdirectory
See original GitHub issueHello Kings of the swamp,
My understanding is that when I have something like:
exports_sources = "CMakeLists.txt", "src/*", "tools/*", "tests/*", "include/*"
conan create
would take all of these and place it in the .conan/...
(aka the recipe).
I also realized, though I’m not sure, that if code in tests/CMakeLists.txt
need some package to link with, e.g. boost
but the rest of the tree does not need it, since I have it in exports_sources
it is as if the entire package needs boost
.
Now, I also figured out that add_subdirectory()
need to match the above exports_sources
list.
In other words, if I have add_subdirectory(tests)
and I remove tests/*
from the above list, I have an error:
CMake Error at CMakeLists.txt:43 (add_subdirectory):
add_subdirectory given source "tests" which is not an existing directory.
...
ERROR: foo/1.1.1: Error in build() method, line 41
cmake.configure()
ConanException: Error 1 while executing cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=..."
But I don’t want tests/*
. I don’t need it in the recipe. I don’t need the dependencies.
How do I remove tests/*
without the above error. Surely there is a way.
Thanks! Kobi
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
thank you @memsharded !!
I think it might be related to the nature of
build_requires
, not intended to be used via ``find_package(), and this also depends on if you are using the “build” and “host” profiles. The direction should be:boost
asself.requires("boost...", force_host_context=True)
insiderequirements()
, this indicates this dep is in the “host” context.CMakeDeps
integrations.--profile:build
explicitly, to start opting-in in what will be the default behavior in 2.0 and in ConanCenter soon too.