{"id":13471235,"url":"https://github.com/ttroy50/cmake-examples","last_synced_at":"2025-04-10T02:14:36.580Z","repository":{"id":37408895,"uuid":"46611889","full_name":"ttroy50/cmake-examples","owner":"ttroy50","description":"Useful CMake Examples","archived":false,"fork":false,"pushed_at":"2024-02-28T22:39:37.000Z","size":554,"stargazers_count":12723,"open_issues_count":31,"forks_count":2523,"subscribers_count":187,"default_branch":"master","last_synced_at":"2025-04-10T02:14:30.740Z","etag":null,"topics":["boost","catch","clang","clang-format","cmake","cpack","cpp","cppcheck","ctest","google-test","static-analysis","tutorial","unit-testing"],"latest_commit_sha":null,"homepage":"http://ttroy50.github.io/cmake-examples","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/ttroy50.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"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":"2015-11-21T11:03:11.000Z","updated_at":"2025-04-09T14:49:47.000Z","dependencies_parsed_at":"2024-05-02T20:57:55.346Z","dependency_job_id":"031b06f5-f2fd-4e4c-bbf4-d0a87e6019e4","html_url":"https://github.com/ttroy50/cmake-examples","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttroy50%2Fcmake-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttroy50%2Fcmake-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttroy50%2Fcmake-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttroy50%2Fcmake-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ttroy50","download_url":"https://codeload.github.com/ttroy50/cmake-examples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248142903,"owners_count":21054671,"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":["boost","catch","clang","clang-format","cmake","cpack","cpp","cppcheck","ctest","google-test","static-analysis","tutorial","unit-testing"],"created_at":"2024-07-31T16:00:41.994Z","updated_at":"2025-04-10T02:14:36.553Z","avatar_url":"https://github.com/ttroy50.png","language":"CMake","funding_links":[],"categories":["CMake","Cmake","Examples / Templates","Content","Programming Language Tutorials","Language-Specific Tools","C/C++ 程序设计","tutorial","C/C++生态圈Dev\u0026Ops工具与服务"],"sub_categories":["For Scala","C/C++","网络服务_其他"],"readme":"\n= CMake Examples\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nhttps://cmake.org/[CMake] is a cross-platform open-source meta-build system which\ncan build, test and package software. It can be used to support multiple native build environments including\nmake, Apple's xcode and Microsoft Visual Studio.\n\nThis repository includes some example modern CMake configurations which I have picked up\nwhen exploring it's usage for various projects. The examples are laid out in a tutorial like format.\nThe first examples are very basic and slowly increase in complexity drawing on previous examples to show\nmore complex use cases.\n\nThese examples have been tested on Ubuntu 16.04 but should work under any Linux system that supports CMake v3.5+.\n\nThis branch works with the CMake version 3.5 onwards. \n\n* For examples that use CMake version 2.x see the branch link:https://github.com/ttroy50/cmake-examples/tree/v2-style-includes[v2-style-includes].\n* For examples that use CMake version 3.0 see the branch link:https://github.com/ttroy50/cmake-examples/tree/v3.0-minimum[v3.0-minimum]\n\nimage:https://travis-ci.org/ttroy50/cmake-examples.svg?branch=master[\"Build Status\", link=\"https://travis-ci.org/ttroy50/cmake-examples\"]\n\n# Requirements\n\nThe basic requirements for most examples are:\n\n* CMake v3.5+\n* A c++ compiler (defaults to gcc)\n* make\n\n## Installation on Ubuntu\n\nThe easiest way to install the above on Ubuntu is as follows\n\n[source,bash]\n----\n$ sudo apt-get install build-essential\n$ sudo apt-get install cmake\n----\n\nSome specific examples may require other tools including:\n\n* http://www.boost.org/[boost]\n\n  $ sudo apt-get install libboost-all-dev\n\n* https://github.com/google/protobuf[protobuf]\n\n  $ sudo apt-get install libprotobuf-dev\n  $ sudo apt-get install protobuf-compiler\n\n* http://cppcheck.sourceforge.net/[cppcheck]\n\n  $ sudo apt-get install cppcheck\n\n* http://clang.llvm.org/[clang]\n\n  $ sudo apt-get install clang-3.6\n\n* https://ninja-build.org/[ninja]\n\n  $ sudo apt-get install ninja-build\n\n* link:https://conan.io[conan]\n\n  $ sudo apt-get install python3 python3-pip\n  $ sudo pip3 install conan\n\n## Docker\n\nDocker containers with all requirements and various versions of CMake are generated to help make testing the examples easier. These are available from the docker hub repository link:https://hub.docker.com/r/matrim/cmake-examples/[matrim/cmake-examples].\n\nTo build the full set of cmake-examples test cases you can run:\n\n[source,bash]\n----\ndocker run -it matrim/cmake-examples:3.5.1\ncd ~ \ngit clone https://github.com/ttroy50/cmake-examples.git code\ncd code\n./test.sh\n----\n\nFor more details on build and running the docker containers link:here[dockerfiles].\n\n# Other Links\n\nThere are many CMake tutorials and examples online. The list below includes links\nto some of these which I have found helpful in my CMake journey.\n\n  * https://web.archive.org/web/20160314094326/https://www.kdab.com/~stephen/moderncmake.pdf[Modern CMake Slides]\n  * https://rix0r.nl/blog/2015/08/13/cmake-guide/[rix0r Modern CMake Blog]\n  * https://cmake.org/cmake-tutorial/[Official CMake Tutorial]\n  * https://gitlab.kitware.com/cmake/community/wikis/home[Official CMake Wiki]\n  * https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/Useful-Variables[CMake Useful Variables]\n  * http://derekmolloy.ie/hello-world-introductions-to-cmake/[Derek Molloy - Intro to CMake]\n  * http://techminded.net/blog/modular-c-projects-with-cmake.html[Modular C++ Projects]\n  * https://web.archive.org/web/20190320121339/http://voices.canonical.com/jussi.pakkanen/2013/03/26/a-list-of-common-cmake-antipatterns/[Common CMake Anti-Patterns]\n  * http://baptiste-wicht.com/posts/2014/04/install-use-clang-static-analyzer-cmake.html[Using clang static analyser with CMake]\n  * https://cmake.org/pipermail/cmake/2011-April/043709.html[Static Analysis with CDash] - Includes some info about using CppCheck with CMake\n  * https://samthursfield.wordpress.com/2015/10/20/some-cmake-tips/[CMake Tips]\n  * https://www.johnlamp.net/cmake-tutorial.html[John Lamp - CMake Tutorial]\n  * link:https://docs.conan.io[Conan Documentation]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttroy50%2Fcmake-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fttroy50%2Fcmake-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttroy50%2Fcmake-examples/lists"}