Replies: 2 comments 1 reply
-
An example provider can also be found in the CMake documentation. I think this is an interesting concept, but at the same time, I don't think you can make this really "portable". But then again, I'm also not 100% sure how the developers of CMake envisioned this to be used, so maybe my expectations are a bit off as well. |
Beta Was this translation helpful? Give feedback.
-
I make a PoC using FetchContent for declaring dependencies. It feels a bit weird to use FetchContent to call CPM which uses FetchContent under the hood, but it works. CMakeLists.txtcmake_minimum_required(VERSION 3.24)
project(cpm_dep_prov)
include(FetchContent)
FetchContent_Declare(
argparse
GIT_REPOSITORY https://github.com/p-ranav/argparse.git
GIT_TAG v2.9
)
FetchContent_MakeAvailable(argparse)
set(BENCHMARK_ENABLE_TESTING FALSE)
FetchContent_Declare(
benchmark
GIT_REPOSITORY https://github.com/google/benchmark
GIT_TAG v1.7.1
)
FetchContent_MakeAvailable(benchmark)
add_executable(cpm_dep_prov main.cpp)
target_link_libraries(cpm_dep_prov PRIVATE argparse::argparse benchmark::benchmark) cpm_provider.cmakeinclude(CPM.cmake)
include(FetchContent)
function(cpm_provide_dependency METHOD NAME)
CPMAddPackage(NAME ${NAME} GIT_REPOSITORY ${ARGV7} GIT_TAG ${ARGV9})
FetchContent_SetPopulated(${NAME} SOURCE_DIR ${${NAME}_SOURCE_DIR} BINARY_DIR ${${NAME}_BINARY_DIR})
endfunction()
cmake_language(
SET_DEPENDENCY_PROVIDER cpm_provide_dependency
SUPPORTED_METHODS FETCHCONTENT_MAKEAVAILABLE_SERIAL
) CMake log
|
Beta Was this translation helpful? Give feedback.
-
CMake 2.24 is going to introduce a new feature called Dependency Providers. In essence, user will be able to setup a single dependency provider for a project. And the job of the dependency provider is to deliver dependency by intercepting
find_package()
andFetchContent_MakeAvailable()
commands.It would be very nice to adapt CPM to the Dependency Provider role.
Beta Was this translation helpful? Give feedback.
All reactions