Comments (6)
Ah, maybe Editable Packages help me here?
from cmake-conan.
Hi @garethsb
Thanks for your question.
This is something that we should have a look. Certainly, this was not the intended use case of cmake-conan
, but to provide a relatively simple way to have single projects calling Conan automatically. But mostly it avoids a conan install
call.
If the project is more a meta-project, gathering other subprojects, this seems a bit beyond the original scope of this cmake-conan
integration, but lets have a look at it and think about it.
Ah, maybe Editable Packages help me here?
Probably not, those are intended to solve a different problem: working simultaneously on different packages. Something to do occasionally, because mainly using packages means that every package should and will be develop in isolation most of the time (otherwise it is not really a package). But if the project is not really componentized into packages, then the editables
won't really help much, and specially they will not provide the same integrated development experience in a single IDE project than a real monolith can achieve.
Regarding the approach of having a meta project with several subprojects and each one containing a different conanfile
, consider the following: If those subprojects have dependencies to other subprojects, and they are using different versions of dependencies, things will be ugly, with link errors or runtime errors due to discrepancies. Conan cannot detect those discrepancies of versions, because each subproject has a different conanfile
, so they install completely independent dependency graphs, but those graphs are not checked against other graphs computed later in another folder, even if it is a sibling folder.
If you need consistency of dependencies across all subprojects, it would be much better to have a single central conanfile
declaring all the needed dependencies. Then each subproject can have different find_package()
and link only the ones they need.
from cmake-conan.
Thanks for the thoughtful response. The use case for me is exactly the one you mentioned of the integrated development experience in a single IDE project, by using add_subdirectory
, with the option to switch to find_package
when the monolith isn't required, since all the same CMake targets are made available either way.
I do understand the concerns about carefully managing dependencies of dependencies, so a central conanfile when using add_subdirectory
maybe the workaround even though switching from find_package
would become less simple than just toggling a CMake option.
from cmake-conan.
experience in a single IDE project, by using add_subdirectory, with the option to switch to find_package when the monolith isn't required, since all the same CMake targets are made available either way.
Definitely, being able to modify the CMakeLists.txt
to use some conditional logic to use one approach (find_package()
) or the other, would help a lot towards that goal. The thing is that often users expect to be able to switch transparently from mono-repo with add_subdirectory()
and just using targets defined in sibling sub-projects, to use Conan and magically have things still working, and unfortunately CMake doesn't allow that that easily.
from cmake-conan.
I use this idiom frequently:
# Find and use FooBar from its installed location or as a subdirectory
set(USE_ADD_SUBDIRECTORY OFF CACHE BOOL "Use add_subdirectory() rather than find_package()")
if(NOT USE_ADD_SUBDIRECTORY)
message(STATUS "Using find_package(FooBar)")
# Using find_package() will require FooBar and its dependencies (Baz, Qux, etc.)
# to be installed and discoverable via a config-file package or find-module
# Conan is one way of achieving this...
find_package(FooBar REQUIRED)
else()
set(FOO_BAR_DIRECTORY "../FooBar" CACHE STRING "Path to FooBar directory")
message(STATUS "Using add_subdirectory(${FOO_BAR_DIRECTORY})")
add_subdirectory(${FOO_BAR_DIRECTORY} build-FooBar EXCLUDE_FROM_ALL)
endif()
from cmake-conan.
I am adding a test here: #623
that shows that the described add_subdirectory()
should work too
from cmake-conan.
Related Issues (20)
- Different formatting of msvc runtime value conan_provider.cmake
- Installing only certain packages HOT 8
- [develop2] Question: How stable is the current state HOT 2
- tools.build:compiler_executables breaks build with Autotools and Xcode HOT 3
- [develop2] detect_compiler() detects invalid 'settings.compiler.version' for apple-clang
- find_program working when building from command line, but not when using the CLion Conan plugin HOT 11
- [bug] generated settings.yml missing Macos.version "14.2", causes build failures HOT 10
- [develop2, BUG] Unknown arguments specified in conan_provider.cmake:519 HOT 2
- Unable to cross compile openssl/3.x.x on develop2 HOT 6
- Using "build-scripts" package via tool_requires() not working HOT 2
- [develop2] CMAKE_CONFIGURATION_TYPES with custom build types not getting dependencies added properly HOT 3
- ERROR: Invalid setting '6' is not a valid 'settings.compiler.version' value HOT 2
- 【conan install】conan_provider.cmake downloads packages from source because detect_host_profile generates compiler.cppstd=xx in the cmake-build-release/conan_host_profile file with the detect_host_profile method HOT 5
- cmake bootstrapping fails if not on PATH HOT 3
- Not working with conan editable mode HOT 5
- Update readme with more details HOT 1
- MSVC version update HOT 6
- [question] Using layout and -of together Conan 2 HOT 4
- Some "url" attributes causes cmake-conan to fail HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cmake-conan.