A tool to auto-update CMakeLists.txt when source files change.
Project description
CMakeLists Updater
CMakeLists Updater detects new or deleted .h, .hpp, and .cpp files and updates SET(HEADERS) and SET(SOURCES) sections in the CMakeLists.txt file. It also supports a global ignore list for files and directories that should not be monitored.
Installation
Install the package using pip:
pip install cmakelists-updater
Configuration
Create a YAML configuration file (e.g., config.yaml) with the following structure:
global_ignore_list:
- build
- .git
- .vscode
cmake_files:
path/to/first/CMakeLists.txt:
source_dirs:
- path/to/first/src
- path/to/first/include
ignore_list:
- ignored_dir
- ignored_file.cpp
path/to/second/CMakeLists.txt:
source_dirs:
- path/to/second/src
- path/to/second/include
ignore_list:
- ignored_dir
- ignored_file.cpp
cmake_files: A mapping of CMake files to their respective settings.source_dirs: A list of directories to monitor for source file changes.ignore_list: (Optional) A list of directories or files to exclude from monitoring for each CMake file.global_ignore_list: (Optional) A list of directories or files to exclude from monitoring across all CMake files.
Usage
Terminal
Run the cmakelists-updater command, providing the path to your configuration file:
cmakelists-updater config.yaml
VS Code task
Add .vscode/tasks.json file to your project root with the following contents:
{
"version": "2.0.0",
"tasks": [
{
"label": "Run CMakeLists Updater",
"type": "shell",
"command": "cmakelists-updater",
"args": ["config.yaml"],
"problemMatcher": [],
"presentation": {
"reveal": "silent",
"panel": "shared",
"clear": true
},
"options": {
"env": {
"PYTHONUNBUFFERED": "1"
}
},
"runOptions": {
"runOn": "folderOpen"
}
}
]
}
CMake command
Check if cmake-autoupdater is installed and execute it if found:
set(AUTO_UPDATER_STARTED FALSE CACHE BOOL "" FORCE)
find_program(CMAKELISTS_UPDATER_EXEC cmakelists-updater)
if(NOT AUTO_UPDATER_STARTED AND CMAKELISTS_UPDATER_EXEC)
execute_process(
COMMAND ${CMAKELISTS_UPDATER_EXEC} "config.yaml"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
set(AUTO_UPDATER_STARTED TRUE CACHE BOOL "" FORCE)
endif()
Example
Assume the following directory structure:
project/
--src/
----main.cpp
----utils.cpp
----utils.hpp
--include/
----project.hpp
--CMakeLists.txt
In order to get the script working, first make sure that CMakeLists has HEADERS and SOURCES variables set and are used in add_executable/add_library:
SET(HEADERS
include/project.hpp
)
SET(SOURCES
src/utils.hpp
src/utils.cpp
src/main.cpp
${HEADERS}
)
add_executable(${PROJECT_NAME}
${HEADERS}
${SOURCES}
any_external_dep.hpp)
Place a config.yaml file into the project root. It might look like:
cmake_files:
CMakeLists.txt:
source_dirs:
- src
- include
ignore_list:
- build
Run the following command from the project root to start monitoring and updating the CMakeLists.txt:
cmakelists-updater config.yaml
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cmakelists_updater-1.0.1.tar.gz.
File metadata
- Download URL: cmakelists_updater-1.0.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73bc08fc2de2968a40b1b3cb06fa32f0145f523dd0784dd3bd534acd44b437a8
|
|
| MD5 |
bc5146de60b95ab8574d54ed4edd9111
|
|
| BLAKE2b-256 |
fe6f20bf95b532c65266869ee00fde0a947c1362fa60eaf02d7ff21c856f8c46
|
Provenance
The following attestation bundles were made for cmakelists_updater-1.0.1.tar.gz:
Publisher:
pypi-publish.yml on obsqrbtz/cmakelists-autoupdater
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cmakelists_updater-1.0.1.tar.gz -
Subject digest:
73bc08fc2de2968a40b1b3cb06fa32f0145f523dd0784dd3bd534acd44b437a8 - Sigstore transparency entry: 156334219
- Sigstore integration time:
-
Permalink:
obsqrbtz/cmakelists-autoupdater@dc02825fd383446d639cbd537ed0f994070fe732 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/obsqrbtz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@dc02825fd383446d639cbd537ed0f994070fe732 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cmakelists_updater-1.0.1-py3-none-any.whl.
File metadata
- Download URL: cmakelists_updater-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce43aa5b2a70c48360a5cd1aba24c2ef119dd3becde0950dde91d6586619b17e
|
|
| MD5 |
6a011f86c64657beeac54aca325c99b7
|
|
| BLAKE2b-256 |
ff6bf939caf0605861ca021616439c43816802c4955510d8feea96387a25942d
|
Provenance
The following attestation bundles were made for cmakelists_updater-1.0.1-py3-none-any.whl:
Publisher:
pypi-publish.yml on obsqrbtz/cmakelists-autoupdater
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cmakelists_updater-1.0.1-py3-none-any.whl -
Subject digest:
ce43aa5b2a70c48360a5cd1aba24c2ef119dd3becde0950dde91d6586619b17e - Sigstore transparency entry: 156334220
- Sigstore integration time:
-
Permalink:
obsqrbtz/cmakelists-autoupdater@dc02825fd383446d639cbd537ed0f994070fe732 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/obsqrbtz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@dc02825fd383446d639cbd537ed0f994070fe732 -
Trigger Event:
push
-
Statement type: