remove CPM_RESET in favor of CPM_OFFLINE (#6)

* remove CPM_RESET in favor of CPM_OFFLINE

* Update README.md (#5)

* Update README.md

* Update README.md

* Update README.md
This commit is contained in:
Lars Melchior
2019-04-10 16:43:57 +02:00
committed by GitHub
parent e368fce6c3
commit e4bbd6e215
3 changed files with 15 additions and 19 deletions

View File

@@ -2,7 +2,7 @@
# CPM # CPM
CPM is a very simple package manager written in Cmake based on the amazing [DownloadProject](https://github.com/Crascit/DownloadProject) script. It is extremely easy to use and drastically simplifies the inclusion of other Cmake-based projects from github. CPM is a minimalistic package manager written in Cmake based on the amazing [DownloadProject](https://github.com/Crascit/DownloadProject) script. It is extremely easy to use and drastically simplifies the inclusion of other Cmake-based projects from github.
# Usage # Usage
@@ -29,19 +29,25 @@ add_executable(my-parser my-parser.cpp)
target_link_libraries(cpm-test LarsParser) target_link_libraries(cpm-test LarsParser)
``` ```
# Update packages # Offline mode
To update packages, run cmake with the additional option `-DCPM_RESET=ON`. To keep the project working offline after the update, set `-DCPM_RESET=OFF` afterwards. After including CPM CMake will try to update remote repositories at every new buld. To continue working offline, set the parameter `CPM_OFFLINE=On`.
# Installation # Installation
To add CPM to your current project, copy the scripts in the `cmake` directory into you current project project. The command below will perform this automatically. To add CPM to your current project, copy the scripts in the `cmake` directory into you current project project. The command below will perform this automatically.
```bash ```bash
wget -qO- https://github.com/TheLartians/CPM/releases/download/v0.3/cmake.zip | bsdtar -xvf- wget -qO- https://github.com/TheLartians/CPM/releases/download/v0.4/cmake.zip | bsdtar -xvf-
``` ```
# Advantages
- **Auto handle dependencies** Users of your projects do not need to worry about dependencies, everything is handled automatically.
- **Reproducable builds** Using git tags it is ensured that a project will always be in the same state everywhere.
- **No installation required** No need to install any third-party package managers. Just copy the files from the CMake directory and you're good to go.
# Limitations # Limitations
- First version used: in diamond dependency graphs (e.g. `A` depends on `C`(v1.1) and `A` depends on `B` depends on `C`(v1.2)) the first added dependency will be used (in this case `C`@1.1). - **First version used** In diamond-shaped dependency graphs (e.g. `A` depends on `C`(v1.1) and `A` depends on `B` depends on `C`(v1.2)) the first added dependency will be used (in this case `C`@1.1).
- No possibility not automatically update dependencies. To update a dependency, version numbers or git tags in the cmake scripts must be adapted manually. - **No auto-update** To update a dependency, version numbers or git tags in the cmake scripts must be adapted manually.

View File

@@ -3,10 +3,9 @@ set(_CPM_Dir "${CMAKE_CURRENT_LIST_DIR}")
include(CMakeParseArguments) include(CMakeParseArguments)
include(${_CPM_Dir}/DownloadProject.cmake) include(${_CPM_Dir}/DownloadProject.cmake)
option(CPM_RESET "reset CPM" OFF) option(CPM_OFFLINE "CPM offline mode" OFF)
if(${CPM_RESET}) if(NOT ${CPM_OFFLINE})
message(STATUS "CPM: resetting packages")
set(CPM_PACKAGES "" CACHE INTERNAL "CPM Packages") set(CPM_PACKAGES "" CACHE INTERNAL "CPM Packages")
endif() endif()
@@ -34,15 +33,6 @@ function(CPMAddPackage)
set(CPM_ARGS_BINARY_DIR ${CMAKE_BINARY_DIR}/CPM-projects/${CPM_ARGS_NAME}) set(CPM_ARGS_BINARY_DIR ${CMAKE_BINARY_DIR}/CPM-projects/${CPM_ARGS_NAME})
endif() endif()
if (NOT CPM_ARGS_UPDATE_DISCONNECTED)
if (${CPM_RESET})
set(CPM_ARGS_UPDATE_DISCONNECTED OFF)
else()
set(CPM_ARGS_UPDATE_DISCONNECTED ON)
endif()
endif()
if (NOT CPM_PROJECT_DIR) if (NOT CPM_PROJECT_DIR)
set(CPM_PROJECT_DIR "${CPM_ARGS_BINARY_DIR}") set(CPM_PROJECT_DIR "${CPM_ARGS_BINARY_DIR}")
endif() endif()

View File

@@ -17,7 +17,7 @@ else()
PROJ @CPM_ARGS_NAME@ PROJ @CPM_ARGS_NAME@
GIT_REPOSITORY @CPM_ARGS_GIT_REPOSITORY@ GIT_REPOSITORY @CPM_ARGS_GIT_REPOSITORY@
GIT_TAG @CPM_ARGS_GIT_TAG@ GIT_TAG @CPM_ARGS_GIT_TAG@
UPDATE_DISCONNECTED @CPM_ARGS_UPDATE_DISCONNECTED@ UPDATE_DISCONNECTED @CPM_OFFLINE@
GIT_SHALLOW 1 GIT_SHALLOW 1
PREFIX @CPM_ARGS_BINARY_DIR@/dl PREFIX @CPM_ARGS_BINARY_DIR@/dl
QUIET QUIET