{"id":18538969,"url":"https://github.com/simonthorell/cpp-cmake-googletest","last_synced_at":"2025-08-03T09:09:44.658Z","repository":{"id":212657242,"uuid":"732006877","full_name":"simonthorell/cpp-cmake-googletest","owner":"simonthorell","description":"Template for Apple Silicon using C++20, CMake \u0026 GoogleTest. The template include some sample code for unit testing in gtest framework.","archived":false,"fork":false,"pushed_at":"2024-01-17T11:01:53.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-15T02:13:17.610Z","etag":null,"topics":["build-tool","cmake","cpp20","googletest","vscode-settings"],"latest_commit_sha":null,"homepage":"","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/simonthorell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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-12-15T12:05:14.000Z","updated_at":"2024-02-15T11:28:40.000Z","dependencies_parsed_at":"2024-11-06T19:47:44.653Z","dependency_job_id":null,"html_url":"https://github.com/simonthorell/cpp-cmake-googletest","commit_stats":null,"previous_names":["simonthorell/cpp-cmake-googletest"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonthorell%2Fcpp-cmake-googletest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonthorell%2Fcpp-cmake-googletest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonthorell%2Fcpp-cmake-googletest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonthorell%2Fcpp-cmake-googletest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonthorell","download_url":"https://codeload.github.com/simonthorell/cpp-cmake-googletest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254259443,"owners_count":22040822,"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":["build-tool","cmake","cpp20","googletest","vscode-settings"],"created_at":"2024-11-06T19:45:41.502Z","updated_at":"2025-05-15T02:13:17.715Z","avatar_url":"https://github.com/simonthorell.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C++20 Project Setup Template\n### For Apple Silicon Mac using C++20, CMake \u0026 GoogleTest with VSCode\n\n## Introduction\nThis guide outlines steps for setting up a new project using C++20, CMake, and the GoogleTest unit  \ntesting framework. This repo is tailored and tested for Apple Silicon Macs, but the process is  \nsimilar on other operating systems.  \n\n## Prerequisites\n\n### Essential Tools\n- **CMake**: Build, test, and package software.\n- **Git**: Version control system.\n- **Xcode Command Line Tools**: Includes Make, Clang C/C++ compiler, and LLDB debugger.\n\n### Optional Tools\n(Based on specific development needs)  \n- **GCC Compiler**: Preferred for embedded development (e.g., AVR).\n- **Visual Studio Code**: Advanced code editor.\n  - **CMake Tools Extension for Visual Studio Code**: Enhances CMake integration with VSCode.\n\n### Installing Prerequisites on Mac\n- **CMake**:\n  - Install using Homebrew: `brew install cmake`\n  - Verify installation: `cmake --version`\n- **Git**:\n  - Install using Homebrew: `brew install git`\n  - Verify installation: `git --version`\n- **Xcode Command Line Tools**:\n  - Install using: `xcode-select --install`\n  - Verify installation: `code --version`\n- **GCC Compiler (Optional)**:\n  - Install using Homebrew: `brew install gcc`\n  - Verify installation: `gcc --version`  \n  *Note: Clang is the default compiler on macOS. To use GCC, specify it in your CMake*  \n  *configuration or use environment variables.*  \n- **Visual Studio Code (Optional)**:\n  - Download and install from [Visual Studio Code website](https://code.visualstudio.com/)\n\n## Project Setup\n\n### Cloning the Repository\n1. Clone the repository: `git clone https://github.com/simonthorell/cpp-cmake-googletest.git`.\n2. Navigate to the project directory: `cd cpp-cmake-googletest`.\n\n### CMake Tools\n1. Make sure **CMake Tools** VSCode extension is installed\n2. Select a 'Kit' for CMake in the bottom menu-bar of VSCode to set compiler and toolchain  \nfor the project *(choose Clang or GCC)*. You can change 'kit' later by pressing this part   \nof the bottom menu again. VSCode may also prompt to choose kit by showing a dropdown list.  \n*Note: Once a 'kit' is selected, CMake should build the project as mentioned in next section.*  \n*If it builds, skip to the 'Compilation \u0026 Execution' section*  \n3. If it does not build, press **F1**, type and select 'CMake: Configure' to configure before  \nmoving to next section\n\n### Building the Project [optional]\n1. Create a 'build' directory: `mkdir build \u0026\u0026 cd build`  \n2. Generate the build system and fetch Google Tests: `cmake ..`  \n3. Compile the project: `cmake --build .`    \n*Note: This may not be needed if using CMake Tools and may be automatically setup*\n\n## Compilation \u0026 Execution\n\n### Compile using 'CMake: Build'\n- Press **F5** to compile and debug with LLDB in debug console  \n- Press **Shift + F5** to compile and run binary in terminal *(Running task 'Run MyProject')*\n- Press **Ctrl + F5** to compile and run without debugging\n- Press **F7** to compile only\n\n### Running Tests [optional]\n- In the build folder, replace 'TestMyProject' with your test executable's name and  \nexecute: `./tests/TestMyProject`.  \n*Note: Tests are running automatically during compilation in current setup*\n\n### Running Executable [optional]\n- In the build folder, replace 'MyProject' with your executable's name and  \nrun: `./src/MyProject`.  \n*Note: Use The Run MyProject task to perform this action (or press shift + F5)*\n\n### Set new Github repo\n1. **Clear Template Commit History [optional]**\n  ```bash\n  git checkout --orphan new-start\n  git add -A\n  git commit -m \"Initial commit from template\"\n  git branch -D main\n  git branch -m main\n  git push -f origin main\n  ```\n2. **Remove Template Origin \u0026 Set New Origin**\n  ```bash\n  git remote remove origin\n  git remote add origin YOUR_REPO_URL\n  ```\n\n## Additional Notes\n- **Running Specific Tests**: If you have multiple tests, you can use command-line arguments  \nwith the Google Test executable to filter tests.\n- **Automated Testing with CMake**: Set up CTest (integrated with CMake) to run all tests  \nusing the `ctest` command in your build directory.\n- **Debugging**: Use a debugger like gdb or lldb to debug application or test crashes.\n\n## License\nDistributed under the MIT License. See `LICENSE` for more information.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonthorell%2Fcpp-cmake-googletest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonthorell%2Fcpp-cmake-googletest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonthorell%2Fcpp-cmake-googletest/lists"}