{"id":27219799,"url":"https://github.com/gotz1480/yaml2cmake","last_synced_at":"2025-04-10T06:05:23.528Z","repository":{"id":230456453,"uuid":"779416574","full_name":"gotz1480/yaml2cmake","owner":"gotz1480","description":"Generate CMakeLists from YAML for easy C++ project setups and dependency management","archived":false,"fork":false,"pushed_at":"2024-04-02T00:19:13.000Z","size":33,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T13:13:20.814Z","etag":null,"topics":["cmake","cmake-basis","cmake-scripts","cmake-template","cmake-templates","cmakelists"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gotz1480.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-29T19:41:45.000Z","updated_at":"2024-11-26T13:22:03.000Z","dependencies_parsed_at":"2024-03-29T21:32:16.199Z","dependency_job_id":"4ca13aab-e5a8-4a33-b490-c6e28d2728b3","html_url":"https://github.com/gotz1480/yaml2cmake","commit_stats":null,"previous_names":["araujo88/yaml2cmake","gotz1480/yaml2cmake"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotz1480%2Fyaml2cmake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotz1480%2Fyaml2cmake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotz1480%2Fyaml2cmake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotz1480%2Fyaml2cmake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gotz1480","download_url":"https://codeload.github.com/gotz1480/yaml2cmake/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248166937,"owners_count":21058481,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cmake","cmake-basis","cmake-scripts","cmake-template","cmake-templates","cmakelists"],"created_at":"2025-04-10T06:04:09.370Z","updated_at":"2025-04-10T06:05:23.484Z","avatar_url":"https://github.com/gotz1480.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yaml2cmake\n\n[![license](https://img.shields.io/badge/license-MIT-green)](https://raw.githubusercontent.com/araujo88/yaml2cmake/main/LICENSE)\n[![build](https://github.com/araujo88/yaml2cmake/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/araujo88/yaml2cmake/actions/workflows/build.yml)\n[![release](https://img.shields.io/github/v/release/araujo88/yaml2cmake)](https://github.com/araujo88/yaml2cmake/releases)\n\nyaml2cmake simplifies C++ project setups by generating `CMakeLists.txt` files from easy-to-write YAML configurations. It streamlines the process of integrating external dependencies, managing project settings, and ensuring project portability and scalability with minimal effort.\n\n## Features\n\n- **Simple YAML to CMake**: Convert intuitive YAML files into `CMakeLists.txt` configurations.\n- **External Dependencies**: Easily include external projects from GitHub repositories.\n- **Customizable Setup**: Define project name, version, C++ standards, and more through YAML.\n- **Installation Rules**: Automatically generate installation rules for your projects.\n\n## Getting Started\n\n### Prerequisites\n\n- Go 1.22 or higher\n\n### Installation\n\n1. Clone this repository:\n\n   ```bash\n   git clone https://github.com/araujo88/yaml2cmake.git\n   ```\n\n2. Navigate to the project directory:\n\n   ```bash\n   cd yaml2cmake\n   ```\n\n3. Build the project (optional):\n\n   ```bash\n   go build -o yaml2cmake\n   ```\n\n### Usage\n\n1. Create a `config.yaml` file in the project directory with your project configurations. See [Configuration](#configuration) for more details.\n\n2. Run yaml2cmake:\n\n   ```bash\n   ./yaml2cmake\n   ```\n\n   This will generate a `CMakeLists.txt` file in the same directory.\n\n## Configuration\n\nYour `config.yaml` should look something like this:\n\n```yaml\nproject_name: example_project\nversion: 1.0\ncpp_standard: 11\nlibrary_type: static\ninclude_dirs:\n  - include\nsource_patterns:\n  - src/*.cpp\ninstall: true\nexternal_projects:\n  - name: example_external_project\n    git_repo: https://github.com/user/example_external_project.git\n    tag: main\n```\n\nFor a detailed explanation of each configuration option, refer to [Configuration Options](#configuration-options).\n\n## Contributing\n\nContributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\nPlease refer to [CONTRIBUTING.md](CONTRIBUTING.md) for our contribution guidelines.\n\n## License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n\n### Configuration Options\n\nThe `config.yaml` file is central to how yaml2cmake functions, allowing users to define the specifics of their C++ project's build configuration with ease. Below, each configuration option available in `config.yaml` is detailed, explaining its purpose, expected values, and format.\n\n#### `project_name`\n\n- **Description**: Specifies the name of your C++ project.\n- **Type**: String\n- **Example**: `project_name: example_project`\n\n#### `version`\n\n- **Description**: Defines the version of your project. This can be used within CMake to set version-specific properties or requirements.\n- **Type**: String\n- **Example**: `version: 1.0`\n\n#### `cpp_standard`\n\n- **Description**: Sets the C++ standard version the project should comply with. Common values include `11`, `14`, `17`, `20`, etc.\n- **Type**: Integer\n- **Example**: `cpp_standard: 17`\n\n#### `library_type`\n\n- **Description**: Determines whether the project should be built as a static or shared library.\n- **Type**: String (`static` or `shared`)\n- **Example**: `library_type: static`\n\n#### `include_dirs`\n\n- **Description**: A list of directories where CMake should look for header files. These paths are typically relative to the project root.\n- **Type**: List of strings\n- **Example**:\n  ```yaml\n  include_dirs:\n    - include\n    - third_party/include\n  ```\n\n#### `source_patterns`\n\n- **Description**: File patterns to identify source files for the project. These patterns are usually relative paths with wildcards.\n- **Type**: List of strings\n- **Example**:\n  ```yaml\n  source_patterns:\n    - src/*.cpp\n    - src/**/*.cpp\n  ```\n\n#### `install`\n\n- **Description**: Indicates whether install rules should be generated. Useful for projects intended to be installed on the target system.\n- **Type**: Boolean (`true` or `false`)\n- **Example**: `install: true`\n\n#### `external_projects`\n\n- **Description**: Defines external projects to be included as dependencies. Each external project can specify a name, git repository URL, and an optional tag (branch, tag, or commit).\n- **Type**: List of objects\n- **Example**:\n  ```yaml\n  external_projects:\n    - name: external_project\n      git_repo: https://github.com/user/external_project.git\n      tag: main\n    - name: another_dependency\n      git_repo: https://github.com/user/another_dependency.git\n      tag: v1.2.3\n  ```\n\n#### `output_type`\n\n- **Description**: Specifies the type of output the project should generate. It determines whether yaml2cmake configures the project to build an executable binary or a library. For libraries, further specification of the library type (`static` or `shared`) is required.\n- **Type**: String (`executable` or `library`)\n- **Example**:\n  - To generate an executable:\n    ```yaml\n    output_type: executable\n    ```\n  - To generate a library (note: `library_type` is also needed for libraries):\n    ```yaml\n    output_type: library\n    library_type: static\n    ```\n\nEach option in the `config.yaml` file is designed to be straightforward, making it easy for users to configure their projects without deep knowledge of CMake's syntax or complexities. By adjusting these options, users can quickly scaffold a `CMakeLists.txt` that meets their project's specific needs, from simple applications to complex ones with multiple external dependencies.\n\n## Example Project: Running Your First Build with yaml2cmake\n\nThis guide will walk you through the process of using yaml2cmake to configure, build, and run a simple C++ \"Hello, World!\" project. Follow these steps to see how yaml2cmake simplifies the CMake configuration process.\n\n### Step 1: Generating the CMake Configuration\n\nFirst, ensure you have your `config.yaml` in the project directory and that it is configured correctly for your project. Then, run yaml2cmake to generate your `CMakeLists.txt` file:\n\n```bash\ngo run main.go\n```\n\nThis command reads your `config.yaml` and produces a `CMakeLists.txt` tailored to your project's specifications.\n\n### Step 2: Configuring the Project with CMake\n\nNext, use CMake to configure your project. This step creates the build system in a new directory called `build`:\n\n```bash\ncmake -S . -B build\n```\n\n### Step 3: Building the Project\n\nWith the build system configured, you can now compile your project:\n\n```bash\ncmake --build build\n```\n\nThis command builds the executable defined in your `CMakeLists.txt`, placing it within the `build` directory.\n\n### Step 4: Running the Executable\n\nFinally, run your compiled executable:\n\n```bash\n./build/example_project\n```\n\n### Expected Output\n\nIf everything is set up correctly, you will see something similar to the following output in your terminal:\n\n```\n[2024-03-29 17:13:56] [INFO] [/home/leonardo/Github/yaml2cmake/src/main.cpp:6] Hello, world!\n```\n\nThis output indicates that your \"Hello, World!\" program has run successfully, demonstrating how yaml2cmake facilitates the process of configuring, building, and running C++ projects with ease.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotz1480%2Fyaml2cmake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgotz1480%2Fyaml2cmake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotz1480%2Fyaml2cmake/lists"}