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) 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.