cmakelists-updater


Namecmakelists-updater JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/obsqrbtz/cmakelists-autoupdater
SummaryA tool to auto-update CMakeLists.txt when source files change.
upload_time2024-12-18 12:04:56
maintainerNone
docs_urlNone
authorobsqrbtz
requires_python>=3.6
licenseNone
keywords cmake automation updater
VCS
bugtrack_url
requirements pyyaml watchdog
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CMakeLists Updater

[![PyPI version](https://img.shields.io/pypi/v/cmakelists-updater)](https://pypi.org/project/cmakelists-updater/)
![License](https://img.shields.io/pypi/l/cmakelists-updater)
![Python versions](https://img.shields.io/pypi/pyversions/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`:

```bash
pip install cmakelists-updater
```

## Configuration

Create a YAML configuration file (e.g., `config.yaml`) with the following structure:

```yaml
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:

```bash
cmakelists-updater config.yaml
```

### VS Code task

Add `.vscode/tasks.json` file to your project root with the following contents:

```json
{
  "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:

```cmake
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`:

```cmake
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:

```yaml
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`:

```bash
cmakelists-updater config.yaml
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/obsqrbtz/cmakelists-autoupdater",
    "name": "cmakelists-updater",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "cmake, automation, updater",
    "author": "obsqrbtz",
    "author_email": "dan@obsqrbtz.space",
    "download_url": "https://files.pythonhosted.org/packages/fe/6f/20bf95b532c65266869ee00fde0a947c1362fa60eaf02d7ff21c856f8c46/cmakelists_updater-1.0.1.tar.gz",
    "platform": null,
    "description": "# CMakeLists Updater\n\n[![PyPI version](https://img.shields.io/pypi/v/cmakelists-updater)](https://pypi.org/project/cmakelists-updater/)\n![License](https://img.shields.io/pypi/l/cmakelists-updater)\n![Python versions](https://img.shields.io/pypi/pyversions/cmakelists-updater)\n\nCMakeLists 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.\n\n## Installation\n\nInstall the package using `pip`:\n\n```bash\npip install cmakelists-updater\n```\n\n## Configuration\n\nCreate a YAML configuration file (e.g., `config.yaml`) with the following structure:\n\n```yaml\nglobal_ignore_list:\n    - build\n    - .git\n    - .vscode\ncmake_files:\n  path/to/first/CMakeLists.txt:\n    source_dirs:\n      - path/to/first/src\n      - path/to/first/include\n    ignore_list:\n      - ignored_dir\n      - ignored_file.cpp\n  path/to/second/CMakeLists.txt:\n    source_dirs:\n      - path/to/second/src\n      - path/to/second/include\n    ignore_list:\n      - ignored_dir\n      - ignored_file.cpp\n```\n\n- **`cmake_files`**: A mapping of CMake files to their respective settings.\n- **`source_dirs`**: A list of directories to monitor for source file changes.\n- **`ignore_list`**: (Optional) A list of directories or files to exclude from monitoring for each CMake file.\n- **`global_ignore_list`**: (Optional) A list of directories or files to exclude from monitoring across all CMake files.\n\n## Usage \n\n### Terminal\n\nRun the `cmakelists-updater` command, providing the path to your configuration file:\n\n```bash\ncmakelists-updater config.yaml\n```\n\n### VS Code task\n\nAdd `.vscode/tasks.json` file to your project root with the following contents:\n\n```json\n{\n  \"version\": \"2.0.0\",\n  \"tasks\": [\n    {\n      \"label\": \"Run CMakeLists Updater\",\n      \"type\": \"shell\",\n      \"command\": \"cmakelists-updater\",\n      \"args\": [\"config.yaml\"],\n      \"problemMatcher\": [],\n      \"presentation\": {\n        \"reveal\": \"silent\",\n        \"panel\": \"shared\",\n        \"clear\": true\n      },\n      \"options\": {\n        \"env\": {\n          \"PYTHONUNBUFFERED\": \"1\"\n        }\n      },\n      \"runOptions\": {\n        \"runOn\": \"folderOpen\"\n      }\n    }\n  ]\n}\n```\n\n### CMake command\n\nCheck if cmake-autoupdater is installed and execute it if found:\n\n```cmake\nset(AUTO_UPDATER_STARTED FALSE CACHE BOOL \"\" FORCE)\n\nfind_program(CMAKELISTS_UPDATER_EXEC cmakelists-updater)\n\nif(NOT AUTO_UPDATER_STARTED AND CMAKELISTS_UPDATER_EXEC)\n  execute_process(\n    COMMAND ${CMAKELISTS_UPDATER_EXEC} \"config.yaml\"\n    WORKING_DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}\"\n  )\n  set(AUTO_UPDATER_STARTED TRUE CACHE BOOL \"\" FORCE)\nendif()\n```\n\n## Example\n\nAssume the following directory structure:\n\n```\nproject/\n--src/\n----main.cpp\n----utils.cpp\n----utils.hpp\n--include/\n----project.hpp\n--CMakeLists.txt\n```\n\nIn 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`:\n\n```cmake\nSET(HEADERS\n    include/project.hpp\n)\n\nSET(SOURCES\n    src/utils.hpp\n    src/utils.cpp\n    src/main.cpp\n    ${HEADERS}\n)\n\nadd_executable(${PROJECT_NAME}\n    ${HEADERS}\n    ${SOURCES}\n    any_external_dep.hpp)\n```\n\nPlace a `config.yaml` file into the project root. It might look like:\n\n```yaml\ncmake_files:\n  CMakeLists.txt:\n    source_dirs:\n      - src\n      - include\n    ignore_list:\n      - build\n```\n\nRun the following command from the project root to start monitoring and updating the `CMakeLists.txt`:\n\n```bash\ncmakelists-updater config.yaml\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A tool to auto-update CMakeLists.txt when source files change.",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/obsqrbtz/cmakelists-autoupdater"
    },
    "split_keywords": [
        "cmake",
        " automation",
        " updater"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff6bf939caf0605861ca021616439c43816802c4955510d8feea96387a25942d",
                "md5": "6a011f86c64657beeac54aca325c99b7",
                "sha256": "ce43aa5b2a70c48360a5cd1aba24c2ef119dd3becde0950dde91d6586619b17e"
            },
            "downloads": -1,
            "filename": "cmakelists_updater-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6a011f86c64657beeac54aca325c99b7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5362,
            "upload_time": "2024-12-18T12:04:54",
            "upload_time_iso_8601": "2024-12-18T12:04:54.053779Z",
            "url": "https://files.pythonhosted.org/packages/ff/6b/f939caf0605861ca021616439c43816802c4955510d8feea96387a25942d/cmakelists_updater-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fe6f20bf95b532c65266869ee00fde0a947c1362fa60eaf02d7ff21c856f8c46",
                "md5": "bc5146de60b95ab8574d54ed4edd9111",
                "sha256": "73bc08fc2de2968a40b1b3cb06fa32f0145f523dd0784dd3bd534acd44b437a8"
            },
            "downloads": -1,
            "filename": "cmakelists_updater-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "bc5146de60b95ab8574d54ed4edd9111",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 4758,
            "upload_time": "2024-12-18T12:04:56",
            "upload_time_iso_8601": "2024-12-18T12:04:56.306638Z",
            "url": "https://files.pythonhosted.org/packages/fe/6f/20bf95b532c65266869ee00fde0a947c1362fa60eaf02d7ff21c856f8c46/cmakelists_updater-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-18 12:04:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "obsqrbtz",
    "github_project": "cmakelists-autoupdater",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pyyaml",
            "specs": [
                [
                    "==",
                    "6.0.2"
                ]
            ]
        },
        {
            "name": "watchdog",
            "specs": [
                [
                    "==",
                    "6.0.0"
                ]
            ]
        }
    ],
    "lcname": "cmakelists-updater"
}
        
Elapsed time: 0.42258s