-
Notifications
You must be signed in to change notification settings - Fork 87
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
Make Conan optional #98
Comments
I do not believe that CMake is, or will ever be, a good solution for dependency management. On the other hand, everything looks like Conan is the best way to go as of now. I do not believe vcpkg will prove in the long run for corporations and will only stay as an alternative solution to Conan for small OSS projects. This is why I do not want to overcomplicate the repo code in a way that will make Conan usage harder. I have a solution in mind that hopefully addresses your needs. If not, please let me know. |
Turns out that defining FetchContent_Declare(mp-units
GIT_REPOSITORY https://github.com/mpusz/units
GIT_SHALLOW True)
FetchContent_GetProperties(mp-units)
if(NOT mp-units_POPULATED)
FetchContent_Populate(mp-units)
macro(conan_init)
endmacro()
add_subdirectory(${mp-units_SOURCE_DIR}/src ${mp-units_BINARY_DIR})
endif() |
conan_init is my utility function defined in a repository submodule. You should not have to redefine it because it uses Conan only if Its files are found. I believe that the change I did (using Conan targets only if they exist) was the proper solution and enough to make you roll. |
Yes, now it's working without redefining |
I am using this
I understand the comment about CMake not replacing conan, however CMake can be made more friendly to FetchContent by using this rather simple technique https://www.foonathan.net/2022/06/cmake-fetchcontent/. I guess you don't want to encourage using FetchConent in the first place. (Anyway, I have to learn how to use conan, specially if it can be done from CMake.) |
Thanks for sharing! Yes, I don't want to encourage
Yes, it can be done from CMake, but it is not the right way to go. This is not only my personal experience but also Conan authors claim the same. Package managers should run on top of build systems and not the other way around. |
I can avoid using Conan with just a few lines of pure CMake:
include(FetchContent) FetchContent_Declare(range-v3 GIT_REPOSITORY https://github.com/ericniebler/range-v3 GIT_SHALLOW True) FetchContent_Declare(fmt GIT_REPOSITORY https://github.com/fmtlib/fmt/ GIT_SHALLOW True) FetchContent_MakeAvailable(range-v3 fmt)
At the moment, I have to replicate the logic of
src/CMakeLists.txt
:The text was updated successfully, but these errors were encountered: