Skip to content

Commit 492e762

Browse files
authored
update examples to use new syntax where possible (#218)
1 parent 3f6cbe7 commit 492e762

File tree

8 files changed

+13
-50
lines changed

8 files changed

+13
-50
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ On the other hand, if `VERSION` hasn't been explicitly specified, CPM can automa
4747
`GIT_TAG` can also be set to a specific commit or a branch name such as `master` to always download the most recent version.
4848
The optional argument `FIND_PACKAGE_ARGUMENTS` can be specified to a string of parameters that will be passed to `find_package` if enabled (see below).
4949

50+
If an additional optional parameter `EXCLUDE_FROM_ALL` is set to a truthy value, then any targets defined inside the dependency won't be built by default. See the [CMake docs](https://cmake.org/cmake/help/latest/prop_tgt/EXCLUDE_FROM_ALL.html) for details.
51+
5052
A single-argument compact syntax is also supported:
5153

5254
```cmake
@@ -58,7 +60,7 @@ CPMAddPackage("uri#tag")
5860
CPMAddPackage("uri@version#tag")
5961
```
6062

61-
In the shorthand syntax if the URI is of the form `gh:user/name`, it is interpreted as GitHub URI and converted to `https://github.com/user/name.git`. If the URI is of the form `gl:user/name`, it is interpreted as a [GitLab](https://gitlab.com/explore/) URI and coverted to `https://gitlab.com/user/name.git`. Otherwise the URI used verbatim as a git URL.
63+
In the shorthand syntax if the URI is of the form `gh:user/name`, it is interpreted as GitHub URI and converted to `https://github.com/user/name.git`. If the URI is of the form `gl:user/name`, it is interpreted as a [GitLab](https://gitlab.com/explore/) URI and coverted to `https://gitlab.com/user/name.git`. Otherwise the URI used verbatim as a git URL. All packages added using the shorthand syntax will be added using the [EXCLUDE_FROM_ALL](https://cmake.org/cmake/help/latest/prop_tgt/EXCLUDE_FROM_ALL.html) flag.
6264

6365
After calling `CPMAddPackage` or `CPMFindPackage`, the following variables are defined in the local scope, where `<dependency>` is the name of the dependency.
6466

@@ -82,8 +84,7 @@ add_executable(tests tests.cpp)
8284
8385
# add dependencies
8486
include(cmake/CPM.cmake)
85-
86-
CPMAddPackage(gh:catchorg/Catch2@2.5.0)
87+
CPMAddPackage("gh:catchorg/Catch2@2.5.0")
8788
8889
# link dependencies
8990
target_link_libraries(tests Catch2)

examples/benchmark/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ project(CPMExampleBenchmark)
66

77
include(../../cmake/CPM.cmake)
88

9-
CPMAddPackage(
10-
NAME fibonacci
11-
GITLAB_REPOSITORY TheLartians/Fibonacci
12-
VERSION 2.0
13-
)
9+
CPMAddPackage("gh:TheLartians/Fibonacci@2.0")
1410

1511
CPMAddPackage(
1612
NAME benchmark

examples/catch2/CMakeLists.txt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,8 @@ project(CPMExampleCatch2)
66

77
include(../../cmake/CPM.cmake)
88

9-
CPMAddPackage(
10-
NAME fibonacci
11-
GITHUB_REPOSITORY TheLartians/Fibonacci
12-
VERSION 2.0
13-
)
14-
15-
CPMAddPackage(
16-
NAME Catch2
17-
GITHUB_REPOSITORY catchorg/Catch2
18-
VERSION 2.13.4
19-
)
9+
CPMAddPackage("gh:TheLartians/Fibonacci@2.0")
10+
CPMAddPackage("gh:catchorg/Catch2@2.13.4")
2011

2112
# ---- Create binary ----
2213

examples/doctest/CMakeLists.txt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,8 @@ project(CPMExampleDoctest)
66

77
include(../../cmake/CPM.cmake)
88

9-
CPMAddPackage(
10-
NAME fibonacci
11-
GITLAB_REPOSITORY TheLartians/Fibonacci
12-
VERSION 2.0
13-
)
14-
15-
CPMAddPackage(
16-
NAME doctest
17-
GITHUB_REPOSITORY onqtam/doctest
18-
GIT_TAG 2.4.5
19-
)
9+
CPMAddPackage("gh:TheLartians/Fibonacci@2.0")
10+
CPMAddPackage("gh:onqtam/doctest#2.4.5")
2011

2112
# ---- Create binary ----
2213

examples/fmt/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ project(CPMJSONExample)
66

77
include(../../cmake/CPM.cmake)
88

9-
CPMAddPackage(
10-
NAME fmt
11-
GIT_TAG 7.1.3
12-
GITHUB_REPOSITORY fmtlib/fmt
13-
)
9+
CPMAddPackage("gh:fmtlib/fmt#7.1.3")
1410

1511
# ---- Executable ----
1612

examples/gtest/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ project(CPMExampleGtest)
66

77
include(../../cmake/CPM.cmake)
88

9-
CPMAddPackage(
10-
NAME fibonacci
11-
GITLAB_REPOSITORY TheLartians/Fibonacci
12-
VERSION 2.0
13-
)
9+
CPMAddPackage("gh:TheLartians/Fibonacci@2.0")
1410

1511
CPMAddPackage(
1612
NAME googletest

examples/linenoise/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ project(CPMlinenoiseExample)
66

77
include(../../cmake/CPM.cmake)
88

9-
CPMAddPackage(
10-
NAME linenoise
11-
GIT_TAG 1.0
12-
GITHUB_REPOSITORY antirez/linenoise
13-
)
9+
CPMAddPackage("gh:antirez/linenoise#1.0")
1410

1511
if(linenoise_ADDED)
1612
add_library(linenoise ${linenoise_SOURCE_DIR}/linenoise.c)

examples/spdlog/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ project(CPMSpdlogExample)
66

77
include(../../cmake/CPM.cmake)
88

9-
CPMAddPackage(
10-
NAME spdlog
11-
GITHUB_REPOSITORY gabime/spdlog
12-
VERSION 1.8.2
13-
)
9+
CPMAddPackage("gh:gabime/spdlog@1.8.2")
1410

1511
# ---- Executable ----
1612

0 commit comments

Comments
 (0)