Skip to content

Commit 8afc2af

Browse files
authored
update more examples to use shorthand syntax (#223)
* update more examples to use shorthand syntax * revert google-benchmark as tests require googletest to be installed * update comments * always quote single-arguments * undo accidental deletion
1 parent a3d1048 commit 8afc2af

File tree

6 files changed

+14
-48
lines changed

6 files changed

+14
-48
lines changed

README.md

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -266,43 +266,25 @@ See the [wiki](https://github.com/cpm-cmake/CPM.cmake/wiki/More-Snippets) for mo
266266
### [Catch2](https://github.com/catchorg/Catch2)
267267

268268
```cmake
269-
CPMAddPackage(gh:catchorg/[email protected])
269+
CPMAddPackage("gh:catchorg/[email protected]")
270270
```
271271

272272
### [Boost (via boost-cmake)](https://github.com/Orphis/boost-cmake)
273273

274274
```CMake
275-
CPMAddPackage(gh:Orphis/[email protected])
275+
CPMAddPackage("gh:Orphis/[email protected]")
276276
```
277277

278278
### [cxxopts](https://github.com/jarro2783/cxxopts)
279279

280280
```cmake
281-
CPMAddPackage(
282-
NAME cxxopts
283-
GITHUB_REPOSITORY jarro2783/cxxopts
284-
VERSION 2.2.0
285-
OPTIONS
286-
"CXXOPTS_BUILD_EXAMPLES Off"
287-
"CXXOPTS_BUILD_TESTS Off"
288-
)
281+
CPMAddPackage("gh:jarro2783/[email protected]")
289282
```
290283

291284
### [Yaml-cpp](https://github.com/jbeder/yaml-cpp)
292285

293286
```CMake
294-
CPMAddPackage(
295-
NAME yaml-cpp
296-
GITHUB_REPOSITORY jbeder/yaml-cpp
297-
# 0.6.2 uses deprecated CMake syntax
298-
VERSION 0.6.3
299-
# 0.6.3 is not released yet, so use a recent commit
300-
GIT_TAG 012269756149ae99745b6dafefd415843d7420bb
301-
OPTIONS
302-
"YAML_CPP_BUILD_TESTS Off"
303-
"YAML_CPP_BUILD_CONTRIB Off"
304-
"YAML_CPP_BUILD_TOOLS Off"
305-
)
287+
CPMAddPackage("gh:jbeder/yaml-cpp#[email protected]")
306288
```
307289

308290
### [google/benchmark](https://github.com/google/benchmark)
@@ -311,14 +293,13 @@ CPMAddPackage(
311293
CPMAddPackage(
312294
NAME benchmark
313295
GITHUB_REPOSITORY google/benchmark
314-
VERSION 1.4.1
315-
OPTIONS
316-
"BENCHMARK_ENABLE_TESTING Off"
296+
VERSION 1.5.2
297+
OPTIONS "BENCHMARK_ENABLE_TESTING Off"
317298
)
318299
319-
if (benchmark_ADDED)
320-
# compile with C++17
321-
set_target_properties(benchmark PROPERTIES CXX_STANDARD 17)
300+
if(benchmark_ADDED)
301+
# enable c++11 to avoid compilation errors
302+
set_target_properties(benchmark PROPERTIES CXX_STANDARD 11)
322303
endif()
323304
```
324305

examples/asio-standalone/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ include(../../cmake/CPM.cmake)
88

99
find_package(Threads REQUIRED)
1010

11-
CPMAddPackage(
12-
NAME asio
13-
VERSION 1.18.1
14-
GITHUB_REPOSITORY chriskohlhoff/asio
15-
GIT_TAG asio-1-18-1 # asio uses non-standard version tag, we must specify GIT_TAG
16-
)
11+
CPMAddPackage("gh:chriskohlhoff/asio#[email protected]")
1712

1813
# ASIO doesn't use CMake, we have to configure it manually. Extra notes for using on Windows:
1914
#

examples/benchmark/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ CPMAddPackage(
1616
)
1717

1818
if(benchmark_ADDED)
19-
# Don't use C++14 because it doesn't work in some configurations.
19+
# enable c++11 to avoid compilation errors
2020
set_target_properties(benchmark PROPERTIES CXX_STANDARD 11)
2121
endif()
2222

examples/boost/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ CPMFindPackage(
1515
NAME Boost
1616
GITHUB_REPOSITORY Orphis/boost-cmake
1717
VERSION 1.67.0
18+
# setting FIND_PACKAGE_ARGUMENTS allow usage with `CPM_USE_LOCAL_PACKAGES`
1819
FIND_PACKAGE_ARGUMENTS "COMPONENTS system"
1920
)
2021

examples/cxxopts/CMakeLists.txt

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

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

9-
CPMAddPackage(
10-
NAME cxxopts
11-
GITHUB_REPOSITORY jarro2783/cxxopts
12-
VERSION 2.2.0
13-
OPTIONS "CXXOPTS_BUILD_EXAMPLES Off" "CXXOPTS_BUILD_TESTS Off"
14-
)
9+
CPMAddPackage("gh:jarro2783/[email protected]")
1510

1611
# ---- Create binary ----
1712

examples/yaml/CMakeLists.txt

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

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

9-
CPMAddPackage(
10-
NAME yaml-cpp
11-
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
12-
VERSION 0.6.3
13-
GIT_TAG yaml-cpp-0.6.3
14-
OPTIONS "YAML_CPP_BUILD_TESTS Off" "YAML_CPP_BUILD_CONTRIB Off" "YAML_CPP_BUILD_TOOLS Off"
15-
)
9+
CPMAddPackage("gh:jbeder/yaml-cpp#[email protected]")
1610

1711
# ---- Executable ----
1812

0 commit comments

Comments
 (0)