update_cmake_min_req¶
The script update_cmake_min_req.py
allows you to scan a CMake project tree and update all instances of cmake_minimum_required()
to a new specified minimum version of CMake.
Command-line usage¶
usage: update_cmake_min_req [-h] --version NEW_VERSION --root ROOT_DIR
Named Arguments¶
- --version, -v
The new minimum version of CMake to require. This can contain integers and
.
characters.- --root, -r
Root directory to scan for CMake files to change. If this is not an absolute path, then the directory searched will be
$(pwd)/<root_dir>
.
Module functions¶
This script searches a project source tree for all CMake files, and updates the cmake_minimum_required()
version in each of them.
- update_cmake_min_req.process_directory(new_version: str, dir_path: str) bool ¶
Processes all CMake files in this directory recursively.
- Parameters:
new_version (str) – The new minimum version of CMake to require. This can contain integers and
.
characters.dir_path (str) – The absolute path to the directory to process.
- Returns:
true if any files in this directory were changed.
- Return type:
bool
- update_cmake_min_req.process_file(new_version: str, file_path: str) bool ¶
Processes a single file. Does nothing if the filename is not CMakelists.txt or the file extension is not .cmake.
- Parameters:
new_version (str) – The new minimum version of CMake to require. This can contain integers and
.
characters.file_path (str) – The absolute path to the file to process.
- Returns:
true if this file was changed.
- Return type:
bool
- update_cmake_min_req.update_cmake_min_req(new_version: str, root_dir: str) bool ¶
Scans all CMake files found in
<root_dir>
for occurrences ofcmake_minimum_required()
, and updates them to use the<new_version>
specified.- Parameters:
new_version (str) – The new minimum version of CMake to require. This can contain integers and
.
characters.root_dir (str) – Path to the root directory to search. If this is not an absolute path, then the directory searched will be
$(pwd)/<root_dir>
.
- Returns:
true if any files were changed by this operation.
- Return type:
bool