{"id":33231828,"url":"https://github.com/polysquare/tooling-cmake-util","last_synced_at":"2026-01-14T15:43:04.001Z","repository":{"id":21354819,"uuid":"24671941","full_name":"polysquare/tooling-cmake-util","owner":"polysquare","description":"Utility and common library for all polysquare cmake tools.","archived":false,"fork":false,"pushed_at":"2016-05-30T13:30:41.000Z","size":109,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-21T18:12:20.178Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CMake","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/polysquare.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}},"created_at":"2014-10-01T09:02:10.000Z","updated_at":"2021-05-07T00:49:08.000Z","dependencies_parsed_at":"2022-08-05T11:30:48.334Z","dependency_job_id":null,"html_url":"https://github.com/polysquare/tooling-cmake-util","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/polysquare/tooling-cmake-util","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polysquare%2Ftooling-cmake-util","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polysquare%2Ftooling-cmake-util/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polysquare%2Ftooling-cmake-util/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polysquare%2Ftooling-cmake-util/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/polysquare","download_url":"https://codeload.github.com/polysquare/tooling-cmake-util/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polysquare%2Ftooling-cmake-util/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28424469,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T15:24:48.085Z","status":"ssl_error","status_checked_at":"2026-01-14T15:23:41.940Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2025-11-16T18:00:21.274Z","updated_at":"2026-01-14T15:43:03.992Z","avatar_url":"https://github.com/polysquare.png","language":"CMake","readme":"# Polysquare CMake Tooling Utility Functions #\n\nUtility and common library for all polysquare cmake tools.\n\n## Status ##\n\n| Travis CI (Ubuntu) | AppVeyor (Windows) | Coverage | Biicode | Licence |\n|--------------------|--------------------|----------|---------|---------|\n|[![Travis](https://img.shields.io/travis/polysquare/tooling-cmake-util.svg)](http://travis-ci.org/polysquare/tooling-cmake-util)|[![AppVeyor](https://img.shields.io/appveyor/ci/smspillaz/tooling-cmake-util.svg)](https://ci.appveyor.com/project/smspillaz/tooling-cmake-util)|[![Coveralls](https://img.shields.io/coveralls/polysquare/tooling-cmake-util.svg)](http://coveralls.io/polysquare/tooling-cmake-util)|[![Biicode](https://webapi.biicode.com/v1/badges/smspillaz/smspillaz/tooling-cmake-util/master)](https://www.biicode.com/smspillaz/tooling-cmake-util)|[![License](https://img.shields.io/github/license/polysquare/tooling-cmake-util.svg)](http://github.com/polysquare/tooling-cmake-util)|\n\n## Description ##\n\n`tooling-cmake-util` is used as a support library by modules like\n`polysquare/veracpp-cmake`, `polysquare/cppcheck-target-cmake`and\n`polysquare/clang-tidy-target-cmake`. It provides functions useful to modules\nwhich provide integration with various static analysis tools for C++.\n\n## Usage ##\n\n### Running a static analysis tool on each source of a target ###\n\nThe most common pattern is to use `psq_run_tool_for_each_source`\n\n#### `psq_run_tool_for_each_source` ####\n\nRun a static analysis tool on each source file for `TARGET`. All of the\ntarget's C and C++ sources are extracted from its definition and the\nspecified `COMMAND` is run on each of them. The string `@SOURCE@` is replaced\nwith the source file name in the arguments for `COMMAND`.\n\n* `TARGET`: The target to run the tool for.\n* `TOOL_NAME`: The name of the tool. This will be shown when the command\n               runs as \"Analyzing @SOURCE@ with ${TOOL_NAME}\"\n* `COMMAND`: The command to run to invoke this tool. @SOURCE@ is replaced\n             with the source file path.\n* [Optional] `CHECK_GENERATED`: Include generated files in the analysis.\n                                Generated files are not included by default.\n* [Optional] `DEPENDS`: Targets and sources running this tool depends on.\n\nYou can also run a tool on a single source file.\n\n#### `psq_run_tool_on_source` ####\n\nRun a static analysis tool on a source file during TARGET. All of the\ntarget's C and C++ sources are extracted from its definition and the\nspecified COMMAND is run on each of them. The string @SOURCE@ is replaced\nwith the source file name in the arguments for COMMAND.\n\n* `TARGET`: The target to run the tool for.\n* `SOURCE`: The source file to check.\n* `TOOL_NAME`: The name of the tool. This will be shown when the command\n               runs as \"Analyzing @SOURCE@ with ${TOOL_NAME}\"\n* `COMMAND`: The command to run to invoke this tool. @SOURCE@ is replaced\n             with the source file path.\n* [Optional] `DEPENDS`: Targets and sources running this tool depends on.\n\n### Making a JSON Compilation Database ###\n\nSome tools use the [CMake JSON Compilation Database](http://clang.llvm.org/docs/JSONCompilationDatabase.html)\nstandard in order to mimic compiler invocations. This can usually be generated\nwith `CMAKE_EXPORT_COMPILE_COMMANDS` but it doesn't capture everything. In\nparticular, it will miss generated files.\n\n`tooling-cmake-util` provides a `psq_make_compilation_db` function to\nensure that a JSON compilation database is always written out in relation\nto a particular target specified during the configure stage.\n\n#### `psq_make_compilation_db` ####\n\nCreates a JSON Compilation Database in relation to the specified TARGET.\n\n`TARGET`: Target to create JSON compilation database for.\n`CUSTOM_COMPILATION_DB_DIR_RETURN`: Variable to store location of compilation\n                                    database for the specified TARGET\n* [Optional] `C_SOURCES`: C-language sources to include.\n* [Optional] `CXX_SOURCES`: C++-language sources to include.\n* [Optional] `INTERNAL_INCLUDE_DIRS`: Non-system include directories.\n* [Optional] `EXTERNAL_INCLUDE_DIRS`: System include directories.\n* [Optional] `DEFINES`: Extra definitions to set.\n\n### Filtering between source file types ###\n\nSometimes you need to distinguish between different types of source files\nwhen running static analysis tools. For instance, you might wish to\navoid generated code when running style checks, or C source files\nwhen running a tool that assumes the language is C++. `tooling-cmake-util`\nprovides helper functions for these cases.\n\n#### `psq_filter_out_generated_sources` ####\n\nFilter out generated sources from SOURCES and store the resulting\nlist of sources in `RESULT_VARIABLE`.\n\n* `RESULT_VARIABLE`: Resultant list of sources, without generated sources.\n* `SOURCES`: List of source files, including generated sources.\n\nFor most projects, the convention is to not filter source files\nwhere `CHECK_GENERATED` is passed. A `psq_handle_check_generated_option`\nwith a similar signature, and the first argument being the `PREFIX` argument\npassed to `cmake_parse_arguments` is provided. This detects if `CHECK_GENERATED`\nhas been set and filters source arguments accordingly.\n\n#### `psq_sort_sources_to_languages` ####\n\nSeparate headers from non-headers and C++ source files from C source files.\n\n* `C_SOURCES`: Variable to store list of C sources in.\n* `CXX_SOURCES`: Variable to store list of C++ sources in.\n* `HEADERS`: Variable to store list of headers in.\n* `SOURCES`: List of source files to separate out.\n* [Optional] `FORCE_LANGUAGE`: Force language of all sources to be either C\n                               or CXX.\n* [Optional] `CPP_IDENTIFIERS`: List of identifiers that indicate that a\n                                source file is actually a C++ source file.\n* [Optional] `INCLUDES`: Include directories to search.\n\n### Utility functions ###\n\n#### `psq_add_switch` ####\n\nSpecify certain command line switches depending on value of\nboolean variable.\n\n* `ALL_OPTIONS`: Existing list of command line switches.\n* `OPTION_NAME`: Boolean variable to check.\n* [Optional] `ON`: Switch to add if boolean variable is true.\n* [Optional] `OFF`: Switch to add if boolean variable is false.\n\n#### `psq_append_each_to_options_with_prefix` ####\n\nAppend items in `ARGN` to `MAIN_LIST`, giving each `PREFIX`.\n\n* `MAIN_LIST`: List to append to.\n* `PREFIX`: Prefix to append to each item.\n\n#### `psq_get_list_intersection` ####\n\nGet the logical intersection between two lists and store it in\n`DESTINATION`.\n\n* `DESTINATION`: Variable to store intersection in.\n* `SOURCE`: Source list.\n* `INTERSECTION`: List to intersect with.\n\n#### `psq_append_to_global_property_unique` ####\n\nAppend `ITEM` to the global property `PROPERTY`, only if it is not\nalready part of the list.\n\n`PROPERTY`: Global property to append to.\n`ITEM`: Item to append, only if not present.","funding_links":[],"categories":["Utility Scripts"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolysquare%2Ftooling-cmake-util","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpolysquare%2Ftooling-cmake-util","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolysquare%2Ftooling-cmake-util/lists"}