Skip to content

Commit 0f23108

Browse files
authored
Fetch content (#593)
* Add git_archival mechanism * fetch_content * Delete .pre-commit-config.yaml * Update CPM.cmake * cmake-format
1 parent 33efd5f commit 0f23108

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

.git_archival.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node: $Format:%H$
2+
node-date: $Format:%cI$
3+
describe-name: $Format:%(describe:tags=true,match=?[0-9.]*)$

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git_archival.txt export-subst

CMakeLists.txt

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
2+
3+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git/")
4+
find_package(Git REQUIRED)
5+
execute_process(
6+
COMMAND "${GIT_EXECUTABLE}" describe --tags --match=?[0-9.]*
7+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
8+
OUTPUT_VARIABLE DESCRIBE_NAME COMMAND_ERROR_IS_FATAL ANY
9+
)
10+
set(CPM_DEVELOPMENT "-development-version")
11+
else()
12+
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/.git_archival.txt" DESCRIBE_NAME
13+
REGEX "^describe-name:.*"
14+
)
15+
endif()
16+
17+
string(REGEX MATCH "([0-9\\.]+)" EXTRACTED_CPM_VERSION "${DESCRIBE_NAME}")
18+
19+
project(
20+
CPM.cmake
21+
VERSION "${EXTRACTED_CPM_VERSION}"
22+
DESCRIPTION
23+
"CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management."
24+
HOMEPAGE_URL "https://github.com/cpm-cmake/CPM.cmake"
25+
LANGUAGES NONE
26+
)
27+
28+
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake")

cmake/CPM.cmake

+5-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ if(NOT COMMAND cpm_message)
4242
endfunction()
4343
endif()
4444

45-
set(CURRENT_CPM_VERSION 1.0.0-development-version)
45+
if(DEFINED EXTRACTED_CPM_VERSION)
46+
set(CURRENT_CPM_VERSION "${EXTRACTED_CPM_VERSION}${CPM_DEVELOPMENT}")
47+
else()
48+
set(CURRENT_CPM_VERSION 1.0.0-development-version)
49+
endif()
4650

4751
get_filename_component(CPM_CURRENT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
4852
if(CPM_DIRECTORY)

0 commit comments

Comments
 (0)