• Stars
    star
    135
  • Rank 269,297 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 5 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Determine the minimal requirement CMake version of a project

cmake_min_version

Cross-platform

Every CMake project requires a call to cmake_minimum_required to set the minimally required CMake version. However, CMake gives no guidance what this version may be, and a lot of projects just take the current CMake version or whatever the IDE is proposing as default. This is a problem, because some platforms don't always provide the latest CMake version, and a lot of trial and error is needed before projects can be used.

cmake_min_version is a script to determine the minimal working version of CMake for a given project. It does not do any magic, but just performs a binary search using a pool of CMake binaries and basically implements the "trial and error" in an efficient way.

Example

Assume ~/projects/example contains a project with a CMakeLists.txt file. Then the following call determines the minimal working version of CMake:

❯ venv/bin/python cmake_min_version.py ~/projects/example

Found 94 CMake binaries from directory tools

[  0%] CMake 3.9.2    βœ” works
[ 12%] CMake 3.2.2    ✘ error
       CMakeLists.txt:7 (cmake_minimum_required)
[ 33%] CMake 3.8.0    βœ” works
[ 50%] CMake 3.7.1    ✘ error
       CMakeLists.txt:16 (target_compile_features)
[ 80%] CMake 3.7.2    ✘ error
       CMakeLists.txt:16 (target_compile_features)
[100%] Minimal working version: CMake 3.8.0

cmake_minimum_required(VERSION 3.8.0)

As a result, ~/projects/example/CMakeLists.txt could be adjusted to require CMake 3.8.0.

FAQ

  • Q: Isn't this a rather naive and inefficent approach to achieve the goal?
  • A: Yes, but I am currently not aware of a better one. I would be happy to replace this repository with a link on a tool that achieves the same goal.

Setup

In a nutshell

  1. Install a Python virtual requirement (Python 3.6 or later).
  2. Download CMake binaries.

Virtual Environment

The code requires some packages to be installed:

python3 -mvenv venv
venv/bin/pip3 install -r requirements.txt

CMake binaries

The script cmake_downloader.py takes care of downloading CMake binaries:

usage: cmake_downloader.py [-h] [--os {macos,linux}] [--latest_release]
                           [--latest_patch] [--first_minor]
                           [--release_candidates] [--tools_directory DIR]

Download CMake binaries.

optional arguments:
  -h, --help            show this help message and exit
  --os {macos,linux}    OS to download CMake for (default: macos)
  --latest_release      only download the latest release (default: False)
  --latest_patch        only download the latest patch version for each
                        release (default: False)
  --first_minor         only download the first minor version for each release
                        (default: False)
  --release_candidates  also consider release candidates (default: False)
  --tools_directory DIR
                        path to the CMake binaries (default: "tools")

Example run:

❯ venv/bin/python3 cmake_downloader.py --latest_patch
Retrieving URLs...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 32/32 [00:18<00:00,  1.71it/s]
Downloading CMake 2.8.12.2...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 40.5M/40.5M [00:12<00:00, 3.34MB/s]
Downloading CMake 3.0.2...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 38.7M/38.7M [00:10<00:00, 3.90MB/s]
Downloading CMake 3.1.3...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 28.6M/28.6M [00:07<00:00, 3.99MB/s]
Downloading CMake 3.2.3...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 26.4M/26.4M [00:07<00:00, 3.52MB/s]
Downloading CMake 3.3.2...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 21.3M/21.3M [00:06<00:00, 3.68MB/s]
Downloading CMake 3.4.3...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 21.6M/21.6M [00:07<00:00, 3.07MB/s]
Downloading CMake 3.5.2...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 21.8M/21.8M [00:06<00:00, 3.33MB/s]
Downloading CMake 3.6.3...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 24.9M/24.9M [00:08<00:00, 2.92MB/s]
Downloading CMake 3.7.2...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 25.1M/25.1M [00:09<00:00, 2.85MB/s]
Downloading CMake 3.8.2...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 25.2M/25.2M [00:06<00:00, 3.95MB/s]
Downloading CMake 3.9.6...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 25.5M/25.5M [00:07<00:00, 3.41MB/s]
Downloading CMake 3.10.3...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 25.9M/25.9M [00:06<00:00, 3.93MB/s]
Downloading CMake 3.11.4...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 26.1M/26.1M [00:06<00:00, 3.96MB/s]
Downloading CMake 3.12.4...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 27.7M/27.7M [00:08<00:00, 3.44MB/s]
Downloading CMake 3.13.5...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 30.6M/30.6M [00:08<00:00, 3.82MB/s]
Downloading CMake 3.14.7...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 32.0M/32.0M [00:08<00:00, 4.04MB/s]
Downloading CMake 3.15.7...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 33.2M/33.2M [00:10<00:00, 3.44MB/s]
Downloading CMake 3.16.5...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 34.2M/34.2M [00:08<00:00, 4.11MB/s]
Downloading CMake 3.17.0...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 35.3M/35.3M [00:10<00:00, 3.67MB/s]

The script downloads and unpacks different versions of CMake into the tools folder.

License

The code is licensed under the MIT License:

Copyright Β© 2020-2023 Niels Lohmann

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the β€œSoftware”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED β€œAS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

json

JSON for Modern C++
C++
42,945
star
2

swagger_to_uml

Convert OpenAPI specifications (a.k.a. Swagger) to PlantUML diagrams
Python
251
star
3

fifo_map

a FIFO-ordered associative container for C++
C++
183
star
4

mutate_cpp

C++ Mutation Test Environment
CSS
170
star
5

crow

Crow - a C++ client for Sentry
C++
133
star
6

std_json

A proposal for a JSON data type in the C++ standard library
54
star
7

fuzzcover

test suite generation for C++
C++
26
star
8

exception_reporter

A tool to collect the exceptions that can reach a C++ function
Python
22
star
9

json_test_data

Test data for nlohmann/json
13
star
10

StanfordCoreNLPXMLServer

The Stanford CoreNLP as HTTP XML server
Java
9
star
11

json-ci

Docker image for the CI of nlohmann/json
Dockerfile
9
star
12

plexible

Plex is cool. And sharing is caring.
Python
8
star
13

rfc-docset

RFC docset for Dash
HTML
8
star
14

gcc_flags

A Python script to collect all C++ warning flags from GCC
Python
7
star
15

diarybot

DiaryBot
Python
6
star
16

service-technology.org

C++
6
star
17

homebrew-json

🍺 Homebrew formula for JSON for Modern C++
Ruby
5
star
18

lqfb_viewer

ein Viewer fΓΌr LiquidFeedback
Python
4
star
19

jar_manifest

returns the content of a jar file's MANIFEST as dict
Python
4
star
20

nlohmann.me

Website https://nlohmann.me
HTML
4
star
21

bpel2owfn

GNU BPEL2oWFN translates WS-BPEL processes into Petri net models
C++
4
star
22

json_release_scripts

Release scripts for "JSON for Modern C+++
Python
4
star
23

bahn_auftragsnummer

Abfrage von Reisedaten der Deutschen Bahn aus der Auftragsnummer
Python
3
star
24

smv_icons

Icons zur Klassifikation von SMV-Modellen
Makefile
3
star
25

phd

Correctness of services and their composition
TeX
3
star
26

suedmensa

Der Speiseplan der SΓΌdmensa Rostock.
Python
2
star
27

bvg-verkehrsmeldungen

BVG Verkehrsmeldungen
Python
2
star
28

mutate_cpp_old

Mutate++ - a C++ mutation test generator and executor
Python
2
star
29

what_the_license

a tool to find the concrete open source license given a source file header
Python
2
star
30

Regenschirm

1
star
31

blog

C
1
star
32

nitpicker

Nitpicker - an overly picky language style checker
1
star
33

wendy

Wendy - synthesizing partners for services
C++
1
star