From ff8e82ca1319dd3067690a971c0f3aa40ee70b03 Mon Sep 17 00:00:00 2001 From: leha-bot Date: Thu, 5 Sep 2024 01:38:48 +0300 Subject: [PATCH 1/2] feat: simplest `cmake --install` support (requires CMake 3.15+) It allows to install the CPM.cmake into the (system) prefix and uses CPM via find_package(CPM). --- CMakeLists.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..decb2527 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,18 @@ +# Warning: this CMakeLists has been created only for supporting +# `cmake --install` && find_package(CPM) workflow. If you don't +# use it, then this file is not required, just download CPM.cmake +# as written in README.md. +cmake_minimum_required(VERSION 3.15) # minimal for `cmake --install` +include(cmake/CPM.cmake) # extract version +project(CPM LANGUAGES NONE) + +include(GNUInstallDirs) +install(FILES ${CMAKE_CURRENT_LIST_DIR}/cmake/CPM.cmake DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/CPM) + +# CPM-config.cmake stub +file(CONFIGURE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/CPM-config.cmake CONTENT [=[ +include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake) +set(CPM_FOUND ON) +]=] @ONLY) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CPM-config.cmake DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/CPM) From 5a9fe607e500febec308167c6297d86bfe3a282e Mon Sep 17 00:00:00 2001 From: leha-bot Date: Thu, 5 Sep 2024 01:39:36 +0300 Subject: [PATCH 2/2] Update README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 33fbbc89..da3b8f8e 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,9 @@ wget -O cmake/CPM.cmake https://github.com/cpm-cmake/CPM.cmake/releases/latest/d You can also download CPM.cmake directly from your project's `CMakeLists.txt`. See the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/Downloading-CPM.cmake-in-CMake) for more details. +### cmake --install workflow +You can also clone this repo and install the CPM.cmake into your prefix via `cmake -S . -B build && cmake --install build --prefix `. + ## Usage After `CPM.cmake` has been [added](#adding-cpm) to your project, the function `CPMAddPackage` can be used to fetch and configure a dependency.