mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-17 06:37:43 -05:00
Add url shortcuts (#53)
* add github and gitlab shortcut, closes #52 * update version * update examples and readme
This commit is contained in:
@@ -85,12 +85,13 @@ Has a CMakeLists.txt that supports `add_subdirectory`.
|
|||||||
```cmake
|
```cmake
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME Catch2
|
NAME Catch2
|
||||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
GITHUB_REPOSITORY catchorg/Catch2
|
||||||
VERSION 2.5.0
|
VERSION 2.5.0
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
See [here](https://github.com/TheLartians/CPM/blob/master/examples/doctest/CMakeLists.txt) for doctest example.
|
See [here](https://github.com/TheLartians/CPM/blob/master/examples/doctest/CMakeLists.txt) for doctest example.
|
||||||
|
Note that we can shorten Github and Gitlab URLs by using `GITHUB_REPOSITORY` or `GITLAB_REPOSITORY`, respectively.
|
||||||
|
|
||||||
### [google/benchmark](https://github.com/google/benchmark.git)
|
### [google/benchmark](https://github.com/google/benchmark.git)
|
||||||
|
|
||||||
@@ -99,7 +100,7 @@ Has a CMakeLists.txt that supports `add_subdirectory`, but needs some configurin
|
|||||||
```cmake
|
```cmake
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME benchmark
|
NAME benchmark
|
||||||
GIT_REPOSITORY https://github.com/google/benchmark.git
|
GITHUB_REPOSITORY google/benchmark
|
||||||
VERSION 1.4.1
|
VERSION 1.4.1
|
||||||
OPTIONS
|
OPTIONS
|
||||||
"BENCHMARK_ENABLE_TESTING Off"
|
"BENCHMARK_ENABLE_TESTING Off"
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
||||||
|
|
||||||
set(CURRENT_CPM_VERSION 0.10)
|
set(CURRENT_CPM_VERSION 0.11)
|
||||||
|
|
||||||
if(CPM_DIRECTORY)
|
if(CPM_DIRECTORY)
|
||||||
if(NOT ${CPM_DIRECTORY} MATCHES ${CMAKE_CURRENT_LIST_DIR})
|
if(NOT ${CPM_DIRECTORY} MATCHES ${CMAKE_CURRENT_LIST_DIR})
|
||||||
@@ -97,12 +97,22 @@ function(CPMAddPackage)
|
|||||||
set(CPM_ARGS_GIT_TAG v${CPM_ARGS_VERSION})
|
set(CPM_ARGS_GIT_TAG v${CPM_ARGS_VERSION})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_TAG ${CPM_ARGS_GIT_TAG})
|
||||||
|
|
||||||
if(CPM_ARGS_DOWNLOAD_ONLY)
|
if(CPM_ARGS_DOWNLOAD_ONLY)
|
||||||
set(DOWNLOAD_ONLY ${CPM_ARGS_DOWNLOAD_ONLY})
|
set(DOWNLOAD_ONLY ${CPM_ARGS_DOWNLOAD_ONLY})
|
||||||
else()
|
else()
|
||||||
set(DOWNLOAD_ONLY NO)
|
set(DOWNLOAD_ONLY NO)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (CPM_ARGS_GITHUB_REPOSITORY)
|
||||||
|
list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_REPOSITORY "https://github.com/${CPM_ARGS_GITHUB_REPOSITORY}.git")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (CPM_ARGS_GITLAB_REPOSITORY)
|
||||||
|
list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_REPOSITORY "https://gitlab.com/${CPM_ARGS_GITHUB_REPOSITORY}.git")
|
||||||
|
endif()
|
||||||
|
|
||||||
if (${CPM_ARGS_NAME} IN_LIST CPM_PACKAGES)
|
if (${CPM_ARGS_NAME} IN_LIST CPM_PACKAGES)
|
||||||
CPM_GET_PACKAGE_VERSION(${CPM_ARGS_NAME})
|
CPM_GET_PACKAGE_VERSION(${CPM_ARGS_NAME})
|
||||||
if(${CPM_PACKAGE_VERSION} VERSION_LESS ${CPM_ARGS_VERSION})
|
if(${CPM_PACKAGE_VERSION} VERSION_LESS ${CPM_ARGS_VERSION})
|
||||||
@@ -146,7 +156,6 @@ function (CPM_DECLARE_PACKAGE PACKAGE VERSION GIT_TAG)
|
|||||||
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
${PACKAGE}
|
${PACKAGE}
|
||||||
GIT_TAG ${GIT_TAG}
|
|
||||||
${ARGN}
|
${ARGN}
|
||||||
)
|
)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ CPMAddPackage(
|
|||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME benchmark
|
NAME benchmark
|
||||||
GIT_REPOSITORY https://github.com/google/benchmark.git
|
GITHUB_REPOSITORY google/benchmark
|
||||||
VERSION 1.4.1
|
VERSION 1.4.1
|
||||||
OPTIONS
|
OPTIONS
|
||||||
"BENCHMARK_ENABLE_TESTING Off"
|
"BENCHMARK_ENABLE_TESTING Off"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ CPMAddPackage(
|
|||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME Catch2
|
NAME Catch2
|
||||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
GITHUB_REPOSITORY catchorg/Catch2
|
||||||
VERSION 2.5.0
|
VERSION 2.5.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ CPMAddPackage(
|
|||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME doctest
|
NAME doctest
|
||||||
GIT_REPOSITORY https://github.com/onqtam/doctest.git
|
GITHUB_REPOSITORY onqtam/doctest
|
||||||
VERSION 2.3.2
|
VERSION 2.3.2
|
||||||
GIT_TAG 2.3.2
|
GIT_TAG 2.3.2
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user