Files
CPM.cmake/README.md

55 lines
2.3 KiB
Markdown
Raw Normal View History

2019-04-09 15:54:11 +02:00
[![Build Status](https://travis-ci.com/TheLartians/CPM.svg?branch=master)](https://travis-ci.com/TheLartians/CPM)
2019-04-09 15:27:47 +02:00
# CPM
2019-04-09 16:04:04 +02:00
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.
2019-04-09 16:04:04 +02:00
# Usage
2019-04-09 16:35:15 +02:00
To add a new dependency to your project simply add the Projects target name, the git URL and the version. If the git tag for this version does not match the pattern `v$VERSION`, then the exact branch or tag can be specified with the `GIT_TAG` argument.
2019-04-09 16:04:04 +02:00
```cmake
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(MyParser)
# add dependencies
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake)
CPMAddPackage(
NAME LarsParser
2019-04-09 17:30:18 +02:00
VERSION 1.4
2019-04-09 16:35:36 +02:00
GIT_REPOSITORY https://github.com/TheLartians/Parser.git
2019-04-09 16:35:15 +02:00
GIT_TAG master # optional
2019-04-09 16:04:04 +02:00
)
# add executable
set (CMAKE_CXX_STANDARD 17)
add_executable(my-parser my-parser.cpp)
target_link_libraries(cpm-test LarsParser)
```
2019-04-09 16:35:15 +02:00
# 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`.
# Adding CPM
2019-04-09 16:49:19 +02:00
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-
2019-04-09 16:49:19 +02:00
```
# 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.
- **Cross-Plattform** As CPM adds projects as cmake subdirectories, it is compatible with all cmake toolchains and generators.
2019-04-09 16:40:32 +02:00
# Limitations
2019-04-09 16:35:15 +02:00
- **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.