{"id":21832372,"url":"https://github.com/fenglielie/cmakezero","last_synced_at":"2025-03-21T13:35:14.203Z","repository":{"id":230886116,"uuid":"717805102","full_name":"fenglielie/cmakezero","owner":"fenglielie","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-12T09:03:28.000Z","size":56,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T10:20:23.501Z","etag":null,"topics":["cmake","cpp"],"latest_commit_sha":null,"homepage":"","language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fenglielie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-11-12T16:50:07.000Z","updated_at":"2025-03-12T09:03:31.000Z","dependencies_parsed_at":"2024-04-01T11:43:49.373Z","dependency_job_id":"55f9fa90-1743-4c8e-96da-c92edaa580f3","html_url":"https://github.com/fenglielie/cmakezero","commit_stats":null,"previous_names":["fenglielie/cmakezero"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenglielie%2Fcmakezero","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenglielie%2Fcmakezero/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenglielie%2Fcmakezero/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenglielie%2Fcmakezero/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fenglielie","download_url":"https://codeload.github.com/fenglielie/cmakezero/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244806313,"owners_count":20513423,"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","cpp"],"created_at":"2024-11-27T19:19:22.906Z","updated_at":"2025-03-21T13:35:14.173Z","avatar_url":"https://github.com/fenglielie.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CMakeZero\n\nCMakeZero is a CMake script that provides macros and functions to simplify the writing of `CMakeLists.txt`.\n\n## Usage\n\n```\n-- macro usage:\n   - zero_usage(): print usage\n   - zero_init(): print usage, then init the project (call after project)\n   - zero_init_quiet(): init the project (call after project)\n   - zero_info(): show infomation\n   - zero_check_update(): check for updates to zero.cmake\n\n-- function usage:\n   - zero_add_subdirs(src): go to src/CMakeLists.txt and src/*/CMakeLists.txt\n   - zero_add_subdirs_rec(src): go to src/CMakeLists.txt and src/*/*/CMakeLists.txt (recurse)\n   - zero_get_files(tmp test): search source files in test/ =\u003e tmp\n   - zero_get_files_rec(tmp test): search source files in test/ and test/*/ =\u003e tmp (recurse)\n\n-- target function usage:\n   - zero_target_preset_definitions(targetname): add some compile definitions\n     * ZERO_TARGET_NAME=targetname\n     * ZERO_PROJECT_SOURCE_DIR=PROJECT_SOURCE_DIR\n     * ZERO_CURRENT_SOURCE_DIR=CMAKE_CURRENT_SOURCE_DIR\n   - zero_target_info(targetname): show target properties\n```\n\n\n## Example\n\nManually download the [zero.cmake](cmake/zero.cmake) file and place it in the `cmake/` subdirectory of your project root. You can also download it using the following command:\n```\nwget https://raw.githubusercontent.com/fenglielie/cmakezero/main/cmake/zero.cmake\n```\n\nThen, import it in the `CMakeLists.txt` of your project:\n```cmake\ncmake_minimum_required(VERSION 3.15 FATAL_ERROR)\nproject(Demo VERSION 1.0)\n\ninclude(cmake/zero.cmake)\n\nzero_init()\nzero_info()\n\nzero_add_subdirs_rec(src)\n\nzero_check_update()\n```\n\nAfter that, you can use the functions and macros provided by `zero.cmake` to simplify the writing of `CMakeLists.txt`.\n\nFor example, add an executable target using all source files in the current directory (and recursive subdirectories):\n```cmake\nzero_get_files_rec(SRCS .)\nadd_executable(test ${SRCS})\n```\n\nAdd some compile definitions and show properties\n```cmake\nzero_get_files_rec(SRCS .)\nadd_executable(test ${SRCS})\nzero_target_preset_definitions(test)\nzero_target_info(test)\n```\n\nThe output of `zero_target_info` is like this:\n```\n[cmake] -- ---------- \u003cCheck Target Begin\u003e ----------\n[cmake] -- name: test1\n[cmake] -- type: executable\n[cmake] -- location: /path/to/cmakezero/src/test1\n[cmake] -- sources:\n[cmake] --   * /path/to/cmakezero/src/test1/test1.cpp\n[cmake] -- compile_definitions:\n[cmake] --   * ZERO_TARGET_NAME=\"test1\"\n[cmake] --   * ZERO_PROJECT_SOURCE_DIR=\"/path/to/cmakezero\"\n[cmake] --   * ZERO_CURRENT_SOURCE_DIR=\"/path/to/cmakezero/src/test1\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffenglielie%2Fcmakezero","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffenglielie%2Fcmakezero","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffenglielie%2Fcmakezero/lists"}