Add fmt example and document version from git tag (#100)

* add VERSION_PREFIX argument

* add fmt example

* add VERSION_PREFIX note to readme

* rollback, add info about determining version from git tag

* rollback version
This commit is contained in:
Lars Melchior
2020-03-16 20:00:30 +01:00
committed by GitHub
parent 01b69aad82
commit cea81872cf
5 changed files with 27 additions and 1 deletions

View File

@@ -36,6 +36,7 @@ CPMAddPackage(
The origin may be specified by a `GIT_REPOSITORY`, but other sources, such as direct URLs, are [also supported](https://cmake.org/cmake/help/v3.11/module/ExternalProject.html#external-project-definition).
If `GIT_TAG` hasn't been explicitly specified it defaults to `v(VERSION)`, a common convention for git projects.
On the other hand, if `VERSION` hasn't been explicitly specified, CPM can automatically identify the version from the git tag in some common cases.
`GIT_TAG` can also be set to a specific commit or a branch name such as `master` to always download the most recent version.
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).

View File

@@ -124,7 +124,7 @@ function(CPMAddPackage)
OPTIONS
)
cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
cmake_parse_arguments(CPM_ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
if(CPM_USE_LOCAL_PACKAGES OR CPM_LOCAL_PACKAGES_ONLY)
cpm_find_package(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}" ${CPM_ARGS_FIND_PACKAGE_ARGUMENTS})

0
examples/build_all.py Normal file → Executable file
View File

View File

@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project(CPMJSONExample)
# ---- Dependencies ----
include(../../cmake/CPM.cmake)
CPMAddPackage(
NAME fmt
GIT_TAG 6.1.2
GITHUB_REPOSITORY fmtlib/fmt
)
# ---- Executable ----
add_executable(CPMFmtExample "main.cpp")
set_target_properties(CPMFmtExample PROPERTIES CXX_STANDARD 17)
target_link_libraries(CPMFmtExample fmt)

6
examples/fmt/main.cpp Normal file
View File

@@ -0,0 +1,6 @@
#include <fmt/format.h>
int main(){
fmt::print("Hello, {}!\n", "world");
return 0;
}