mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-23 12:48:05 -05:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4bbd6e215 | ||
|
|
e368fce6c3 | ||
|
|
f8e571e416 | ||
|
|
e565e35397 | ||
|
|
702f413801 | ||
|
|
03b2dd0cb9 | ||
|
|
4badcddc5d | ||
|
|
72371bcc8b | ||
|
|
0798050d6d | ||
|
|
ffa310199a | ||
|
|
cd3cdfd197 |
26
README.md
26
README.md
@@ -2,7 +2,7 @@
|
||||
|
||||
# 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
|
||||
|
||||
@@ -18,7 +18,7 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME LarsParser
|
||||
VERSION 1.2
|
||||
VERSION 1.4
|
||||
GIT_REPOSITORY https://github.com/TheLartians/Parser.git
|
||||
GIT_TAG master # optional
|
||||
)
|
||||
@@ -29,7 +29,25 @@ add_executable(my-parser my-parser.cpp)
|
||||
target_link_libraries(cpm-test LarsParser)
|
||||
```
|
||||
|
||||
# Offline mode
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
- 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).
|
||||
- No possibility not automatically update dependencies. To update a dependency, version numbers or git tags in the cmake scripts must be adapted manually.
|
||||
- **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 auto-update** To update a dependency, version numbers or git tags in the cmake scripts must be adapted manually.
|
||||
|
||||
@@ -3,9 +3,11 @@ set(_CPM_Dir "${CMAKE_CURRENT_LIST_DIR}")
|
||||
include(CMakeParseArguments)
|
||||
include(${_CPM_Dir}/DownloadProject.cmake)
|
||||
|
||||
function(CPMHasPackage)
|
||||
option(CPM_OFFLINE "CPM offline mode" OFF)
|
||||
|
||||
endfunction()
|
||||
if(NOT ${CPM_OFFLINE})
|
||||
set(CPM_PACKAGES "" CACHE INTERNAL "CPM Packages")
|
||||
endif()
|
||||
|
||||
function(CPMAddPackage)
|
||||
set(options QUIET)
|
||||
@@ -16,6 +18,7 @@ function(CPMAddPackage)
|
||||
VERSION
|
||||
GIT_TAG
|
||||
BINARY_DIR
|
||||
UPDATE_DISCONNECTED
|
||||
)
|
||||
|
||||
set(multiValueArgs "")
|
||||
@@ -30,8 +33,6 @@ function(CPMAddPackage)
|
||||
set(CPM_ARGS_BINARY_DIR ${CMAKE_BINARY_DIR}/CPM-projects/${CPM_ARGS_NAME})
|
||||
endif()
|
||||
|
||||
message("test: ${CPM_ARGS_BINARY_DIR}")
|
||||
|
||||
if (NOT CPM_PROJECT_DIR)
|
||||
set(CPM_PROJECT_DIR "${CPM_ARGS_BINARY_DIR}")
|
||||
endif()
|
||||
|
||||
@@ -17,7 +17,7 @@ else()
|
||||
PROJ @CPM_ARGS_NAME@
|
||||
GIT_REPOSITORY @CPM_ARGS_GIT_REPOSITORY@
|
||||
GIT_TAG @CPM_ARGS_GIT_TAG@
|
||||
UPDATE_DISCONNECTED 1
|
||||
UPDATE_DISCONNECTED @CPM_OFFLINE@
|
||||
GIT_SHALLOW 1
|
||||
PREFIX @CPM_ARGS_BINARY_DIR@/dl
|
||||
QUIET
|
||||
|
||||
@@ -7,7 +7,7 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/CPM.cmake)
|
||||
CPMAddPackage(
|
||||
NAME LHC
|
||||
GIT_REPOSITORY https://github.com/TheLartians/LHC.git
|
||||
VERSION 0.3
|
||||
VERSION 0.4
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
@@ -21,14 +21,14 @@ CPMAddPackage(
|
||||
CPMAddPackage(
|
||||
NAME LarsParser
|
||||
GIT_REPOSITORY https://github.com/TheLartians/Parser.git
|
||||
VERSION 1.3
|
||||
VERSION 1.4
|
||||
)
|
||||
|
||||
# add project twice
|
||||
# add project twice (will be ignored)
|
||||
CPMAddPackage(
|
||||
NAME LHC
|
||||
GIT_REPOSITORY https://github.com/TheLartians/LHC.git
|
||||
VERSION 0.3
|
||||
VERSION 0.1
|
||||
)
|
||||
|
||||
# add executable
|
||||
|
||||
@@ -8,7 +8,7 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/CPM.cmake)
|
||||
CPMAddPackage(
|
||||
NAME LarsParser
|
||||
GIT_REPOSITORY https://github.com/TheLartians/Parser.git
|
||||
VERSION 1.3
|
||||
VERSION 1.4
|
||||
)
|
||||
|
||||
# add executable
|
||||
|
||||
Reference in New Issue
Block a user