Skip to content

Commit 3ee61cb

Browse files
committed
version files instead of hard code
1 parent d0da36e commit 3ee61cb

File tree

11 files changed

+33
-16
lines changed

11 files changed

+33
-16
lines changed

CMAKE_VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.20.4

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
cmake_minimum_required(VERSION 3.14...3.21)
22

3+
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/VERSION PROJECT_VERSION
4+
REGEX "^([0-9]+\.[0-9]+\.[0-9]+)" LIMIT_INPUT 16 LENGTH_MAXIMUM 16 LIMIT_COUNT 1)
5+
36
project(CMakeDemos
47
LANGUAGES C CXX Fortran
5-
VERSION 1.7.1
8+
VERSION ${PROJECT_VERSION}
69
DESCRIPTION "Demonstrate CMake usage"
710
HOMEPAGE_URL https://github.com/scivision/cmake-utils)
811

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CMAKE_VERSION
2+
NINJA_VERSION
3+
VERSION

NINJA_VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.10.2

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ The bootstrap method is only for Unix-like systems, while the CMake-based build
8282
Any platform for which Kitware doesn't distribute binaries use this script, including IBM Power and ARM.
8383

8484
```sh
85-
cmake_compile
85+
python -m cmakeutils.cmake_compile
8686
```
8787

8888
This downloads the latest CMake release source and builds from scratch.

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.9.0

build_cmake.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ if(NOT prefix)
2323
endif()
2424

2525
if(NOT version)
26-
set(version 3.20.3)
26+
file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/CMAKE_VERSION version
27+
REGEX "^([0-9]+\.[0-9]+\.[0-9]+)" LIMIT_INPUT 16 LENGTH_MAXIMUM 16 LIMIT_COUNT 1)
2728
endif()
2829

2930
if(version VERSION_LESS 2.8.12.2)

build_ninja.cmake

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ if(NOT prefix)
1313
get_filename_component(prefix ~ ABSOLUTE)
1414
endif()
1515

16-
set(ver 1.10.2)
16+
if(NOT version)
17+
file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/NINJA_VERSION version
18+
REGEX "^([0-9]+\.[0-9]+\.[0-9]+)" LIMIT_INPUT 16 LENGTH_MAXIMUM 16 LIMIT_COUNT 1)
19+
endif()
1720

1821
set(host https://github.com/ninja-build/ninja/archive/)
19-
set(name v${ver}.tar.gz)
22+
set(name v${version}.tar.gz)
2023

2124
function(checkup ninja)
2225

@@ -33,16 +36,16 @@ endif()
3336
endfunction(checkup)
3437

3538
get_filename_component(prefix ${prefix} ABSOLUTE)
36-
set(path ${prefix}/ninja-${ver})
39+
set(path ${prefix}/ninja-${version})
3740

3841
find_program(ninja NAMES ninja PATHS ${path} PATH_SUFFIXES bin NO_DEFAULT_PATH)
3942
if(ninja)
40-
message(STATUS "Ninja ${ver} already at ${ninja}")
43+
message(STATUS "Ninja ${version} already at ${ninja}")
4144
checkup(${ninja})
4245
return()
4346
endif()
4447

45-
message(STATUS "installing Ninja ${ver} to ${path}")
48+
message(STATUS "installing Ninja ${version} to ${path}")
4649

4750
set(archive ${path}/${name})
4851

@@ -59,7 +62,7 @@ if(NOT EXISTS ${archive})
5962
file(DOWNLOAD ${url} ${archive} INACTIVITY_TIMEOUT 15)
6063
endif()
6164

62-
set(src_dir ${path}/ninja-${ver})
65+
set(src_dir ${path}/ninja-${version})
6366

6467
if(NOT EXISTS ${src_dir}/ninjaCMakeLists.txt)
6568
message(STATUS "extracting ${archive} to ${path}")

install_cmake.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ if(NOT prefix)
2222
endif()
2323

2424
if(NOT version)
25-
set(version 3.20.3)
25+
file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/CMAKE_VERSION version
26+
REGEX "^([0-9]+\.[0-9]+\.[0-9]+)" LIMIT_INPUT 16 LENGTH_MAXIMUM 16 LIMIT_COUNT 1)
2627
endif()
2728

2829
if(version VERSION_LESS 3.7)

install_ninja.cmake

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ if(NOT prefix)
1313
get_filename_component(prefix ~ ABSOLUTE)
1414
endif()
1515

16-
set(ver v1.10.2)
16+
if(NOT version)
17+
file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/NINJA_VERSION version
18+
REGEX "^([0-9]+\.[0-9]+\.[0-9]+)" LIMIT_INPUT 16 LENGTH_MAXIMUM 16 LIMIT_COUNT 1)
19+
endif()
1720

18-
set(host https://github.com/ninja-build/ninja/releases/download/${ver}/)
21+
set(host https://github.com/ninja-build/ninja/releases/download/${version}/)
1922

2023

2124
function(checkup ninja)
@@ -66,16 +69,16 @@ endif()
6669
set(name ${stem}.zip)
6770

6871
get_filename_component(prefix ${prefix} ABSOLUTE)
69-
set(path ${prefix}/ninja-${ver})
72+
set(path ${prefix}/ninja-${version})
7073

7174
find_program(ninja NAMES ninja PATHS ${path} PATH_SUFFIXES bin NO_DEFAULT_PATH)
7275
if(ninja)
73-
message(STATUS "Ninja ${ver} already at ${ninja}")
76+
message(STATUS "Ninja ${version} already at ${ninja}")
7477
checkup(${ninja})
7578
return()
7679
endif()
7780

78-
message(STATUS "installing Ninja ${ver} to ${path}")
81+
message(STATUS "installing Ninja ${version} to ${path}")
7982

8083
set(archive ${path}/${name})
8184

0 commit comments

Comments
 (0)