├── .clang-format ├── .clang-tidy ├── .github └── workflows │ ├── ci_gnu_linux.yml │ ├── ci_macos.yml │ ├── ci_windows.yml │ └── cppcheck.yml ├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── premake5.lua ├── src ├── example.hpp └── main.cpp ├── tests └── test_example.cpp └── vendor └── premake └── bin ├── LICENSE.txt ├── premake5.exe ├── premake5_linux └── premake5_macos /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | AccessModifierOffset: -4 4 | AlignAfterOpenBracket: Align 5 | AlignArrayOfStructures: None 6 | AlignConsecutiveMacros: None 7 | AlignConsecutiveAssignments: None 8 | AlignConsecutiveBitFields: None 9 | AlignConsecutiveDeclarations: None 10 | AlignEscapedNewlines: Right 11 | AlignOperands: Align 12 | AlignTrailingComments: true 13 | AllowAllArgumentsOnNextLine: true 14 | AllowAllParametersOfDeclarationOnNextLine: false 15 | AllowShortEnumsOnASingleLine: true 16 | AllowShortBlocksOnASingleLine: Never 17 | AllowShortCaseLabelsOnASingleLine: false 18 | AllowShortFunctionsOnASingleLine: Inline 19 | AllowShortLambdasOnASingleLine: Inline 20 | AllowShortIfStatementsOnASingleLine: Never 21 | AllowShortLoopsOnASingleLine: false 22 | AlwaysBreakAfterDefinitionReturnType: TopLevel 23 | AlwaysBreakAfterReturnType: TopLevel 24 | AlwaysBreakBeforeMultilineStrings: false 25 | AlwaysBreakTemplateDeclarations: Yes 26 | BinPackArguments: true 27 | BinPackParameters: true 28 | BraceWrapping: 29 | AfterCaseLabel: true 30 | AfterClass: true 31 | AfterControlStatement: Never 32 | AfterEnum: false 33 | AfterFunction: true 34 | AfterNamespace: false 35 | AfterObjCDeclaration: false 36 | AfterStruct: true 37 | AfterUnion: false 38 | AfterExternBlock: true 39 | BeforeCatch: false 40 | BeforeElse: false 41 | BeforeLambdaBody: false 42 | BeforeWhile: false 43 | IndentBraces: false 44 | SplitEmptyFunction: false 45 | SplitEmptyRecord: true 46 | SplitEmptyNamespace: true 47 | BreakBeforeBinaryOperators: NonAssignment 48 | BreakBeforeConceptDeclarations: true 49 | BreakBeforeBraces: Custom 50 | BreakBeforeInheritanceComma: false 51 | BreakInheritanceList: AfterComma 52 | BreakBeforeTernaryOperators: true 53 | BreakConstructorInitializersBeforeComma: false 54 | BreakConstructorInitializers: BeforeColon 55 | BreakAfterJavaFieldAnnotations: true 56 | BreakStringLiterals: true 57 | ColumnLimit: 120 # 74/80/94/120 58 | CommentPragmas: '^ IWYU pragma:' 59 | QualifierAlignment: Leave 60 | CompactNamespaces: false 61 | ConstructorInitializerIndentWidth: 4 62 | ContinuationIndentWidth: 4 63 | Cpp11BracedListStyle: false 64 | DerivePointerAlignment: false 65 | DisableFormat: false 66 | EmptyLineAfterAccessModifier: Leave # Never 67 | EmptyLineBeforeAccessModifier: Always # LogicalBlock 68 | ExperimentalAutoDetectBinPacking: false # true 69 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 70 | AllowAllConstructorInitializersOnNextLine: true 71 | FixNamespaceComments: true 72 | ForEachMacros: 73 | - foreach 74 | - Q_FOREACH 75 | - BOOST_FOREACH 76 | IncludeBlocks: Preserve 77 | IncludeCategories: 78 | - Regex: '^"(llvm|llvm-c|clang|clang-c)/' 79 | Priority: 2 80 | SortPriority: 0 81 | CaseSensitive: false 82 | - Regex: '^(<|"(gtest|gmock|isl|json)/)' 83 | Priority: 3 84 | SortPriority: 0 85 | CaseSensitive: false 86 | - Regex: '.*' 87 | Priority: 1 88 | SortPriority: 0 89 | CaseSensitive: false 90 | IncludeIsMainRegex: '(Test)?$' 91 | IndentAccessModifiers: false 92 | IndentCaseLabels: false 93 | IndentCaseBlocks: false 94 | RequiresClausePosition: OwnLine 95 | IndentRequires: false 96 | IndentRequiresClause: false 97 | IndentWidth: 4 98 | IndentWrappedFunctionNames: true 99 | KeepEmptyLinesAtTheStartOfBlocks: true 100 | LambdaBodyIndentation: Signature 101 | MacroBlockBegin: '' 102 | MacroBlockEnd: '' 103 | MaxEmptyLinesToKeep: 2 104 | NamespaceIndentation: None # Inner 105 | ObjCBinPackProtocolList: Auto 106 | ObjCBlockIndentWidth: 4 107 | ObjCBreakBeforeNestedBlockParam: true 108 | ObjCSpaceAfterProperty: true 109 | ObjCSpaceBeforeProtocolList: false 110 | PenaltyBreakAssignment: 10 111 | PenaltyBreakBeforeFirstCallParameter: 30 112 | PenaltyBreakComment: 10 113 | PenaltyBreakFirstLessLess: 0 114 | PenaltyBreakOpenParenthesis: 0 115 | PenaltyBreakString: 10 116 | PenaltyBreakTemplateDeclaration: 10 117 | PenaltyExcessCharacter: 100 118 | PenaltyReturnTypeOnItsOwnLine: 5 119 | PenaltyIndentedWhitespace: 0 120 | PointerAlignment: Left 121 | PPIndentWidth: -1 122 | ReferenceAlignment: Pointer 123 | ReflowComments: true 124 | SeparateDefinitionBlocks: Always # Leave 125 | ShortNamespaceLines: 1 126 | SortIncludes: Never 127 | SortUsingDeclarations: Lexicographic 128 | SpaceAfterCStyleCast: false 129 | SpaceAfterLogicalNot: false 130 | SpaceAfterTemplateKeyword: false 131 | SpaceBeforeAssignmentOperators: true 132 | SpaceBeforeCaseColon: false 133 | SpaceBeforeCpp11BracedList: false 134 | SpaceBeforeCtorInitializerColon: true 135 | SpaceBeforeInheritanceColon: true 136 | SpaceBeforeParens: ControlStatements 137 | SpaceAroundPointerQualifiers: Default 138 | SpaceBeforeRangeBasedForLoopColon: true 139 | SpaceInEmptyBlock: false 140 | SpaceInEmptyParentheses: false 141 | SpacesBeforeTrailingComments: 1 142 | SpacesInAngles: Never 143 | SpacesInContainerLiterals: true 144 | SpacesInLineCommentPrefix: 145 | Minimum: 1 146 | Maximum: -1 147 | SpacesInSquareBrackets: false 148 | SpaceBeforeSquareBrackets: false 149 | BitFieldColonSpacing: Both 150 | Standard: Latest 151 | TabWidth: 8 152 | UseTab: Never -------------------------------------------------------------------------------- /.clang-tidy: -------------------------------------------------------------------------------- 1 | --- 2 | Checks: "*, 3 | -abseil-*, 4 | -altera-*, 5 | -android-*, 6 | -fuchsia-*, 7 | -google-*, 8 | -llvm*, 9 | -modernize-use-trailing-return-type, 10 | -zircon-*, 11 | -readability-else-after-return, 12 | -readability-static-accessed-through-instance, 13 | -readability-avoid-const-params-in-decls, 14 | -cppcoreguidelines-non-private-member-variables-in-classes, 15 | -misc-non-private-member-variables-in-classes 16 | " 17 | WarningsAsErrors: '' 18 | HeaderFilterRegex: '' 19 | FormatStyle: file -------------------------------------------------------------------------------- /.github/workflows/ci_gnu_linux.yml: -------------------------------------------------------------------------------- 1 | name: CI GNU/Linux 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | strategy: 13 | matrix: 14 | configuration: [Debug, Release] 15 | steps: 16 | - name: Checkout repository with submodules 17 | uses: actions/checkout@v4 18 | with: 19 | submodules: true 20 | 21 | - name: Set executable permission for Premake 22 | run: chmod +x vendor/premake/bin/premake5_linux 23 | 24 | - name: Set up dependencies on Ubuntu 25 | run: sudo apt-get install -y build-essential 26 | 27 | - name: Set configuration as lowercase 28 | run: echo "CONFIGURATION=${{ matrix.configuration == 'Debug' && 'debug' || 'release' }}" >> $GITHUB_ENV 29 | 30 | - name: Build with Premake 31 | run: | 32 | vendor/premake/bin/premake5_linux gmake2 33 | cd MyProject 34 | make config=$CONFIGURATION -j$(nproc) # Use $CONFIGURATION (lowercase) 35 | 36 | - name: Run tests 37 | run: ./bin/${{ matrix.configuration }}-linux-x86_64/MyProjectTests 38 | -------------------------------------------------------------------------------- /.github/workflows/ci_macos.yml: -------------------------------------------------------------------------------- 1 | name: CI macOS 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build: 11 | runs-on: macos-latest 12 | strategy: 13 | matrix: 14 | configuration: [Debug, Release] 15 | steps: 16 | - name: Checkout repository with submodules 17 | uses: actions/checkout@v4 18 | with: 19 | submodules: true 20 | 21 | - name: Set executable permission for Premake 22 | run: chmod +x vendor/premake/bin/premake5_macos 23 | 24 | - name: Set configuration as lowercase 25 | run: echo "CONFIGURATION=${{ matrix.configuration == 'Debug' && 'debug' || 'release' }}" >> $GITHUB_ENV 26 | 27 | - name: Build with Premake 28 | run: | 29 | vendor/premake/bin/premake5_macos gmake2 30 | cd MyProject 31 | make config=$CONFIGURATION -j$(sysctl -n hw.ncpu) # Use $CONFIGURATION (lowercase) 32 | 33 | - name: Run tests 34 | run: ./bin/${{ matrix.configuration }}-macosx-x86_64/MyProjectTests 35 | -------------------------------------------------------------------------------- /.github/workflows/ci_windows.yml: -------------------------------------------------------------------------------- 1 | name: CI Windows 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build: 11 | runs-on: windows-latest 12 | strategy: 13 | matrix: 14 | configuration: [Debug, Release] 15 | steps: 16 | - name: Checkout repository with submodules 17 | uses: actions/checkout@v4 18 | with: 19 | submodules: true 20 | 21 | - name: Build with Premake and MSVC 22 | shell: cmd 23 | run: | 24 | vendor\\premake\\bin\\premake5.exe vs2022 25 | "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\vcvars64.bat" ^ 26 | && "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\MSBuild\\Current\\Bin\\MSBuild.exe" MyProject/MyProject.sln /p:Configuration=${{ matrix.configuration }} 27 | 28 | - name: Run tests 29 | run: ./bin\\${{ matrix.configuration }}-windows-x86_64\\MyProjectTests.exe 30 | -------------------------------------------------------------------------------- /.github/workflows/cppcheck.yml: -------------------------------------------------------------------------------- 1 | name: Cppcheck Analysis 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | cppcheck: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Checkout repository with submodules 17 | uses: actions/checkout@v4 18 | with: 19 | submodules: true 20 | 21 | - name: Cache Cppcheck 22 | uses: actions/cache@v4 23 | with: 24 | path: /usr/bin/cppcheck 25 | key: cppcheck-cache 26 | 27 | - name: Install Cppcheck (if not cached) 28 | run: | 29 | if ! command -v cppcheck &> /dev/null; then 30 | sudo apt-get update 31 | sudo apt-get install -y cppcheck 32 | fi 33 | 34 | - name: Run Cppcheck configuration check 35 | run: | 36 | cppcheck --check-config --suppress=missingIncludeSystem src/ 37 | 38 | - name: Run Cppcheck analysis and generate report 39 | run: | 40 | cppcheck --enable=all --inconclusive --std=c++20 --xml --xml-version=2 \ 41 | --template='::error file={{file}},line={{line}},:: {{message}}' \ 42 | --suppress=missingIncludeSystem \ 43 | --force \ 44 | --output-file=cppcheck-report.xml \ 45 | src/ 46 | continue-on-error: true 47 | 48 | - name: Upload Cppcheck report as an artifact 49 | if: always() 50 | uses: actions/upload-artifact@v4 51 | with: 52 | name: cppcheck-report 53 | path: cppcheck-report.xml 54 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore build directories and intermediate files 2 | /bin/* 3 | /bin-int/* 4 | 5 | # Ignore Premake-generated project files 6 | **/*.make 7 | **/*.workspace 8 | **/*.sln 9 | **/*.vcxproj 10 | **/*.vcxproj.filters 11 | **/*.vcxproj.user 12 | Makefile 13 | CMakeLists.txt.user 14 | obj/ 15 | 16 | # Ignore macOS Xcode project files 17 | *.xcodeproj 18 | *.xcworkspace 19 | *.xcuserdata 20 | 21 | # Ignore Linux-specific generated files 22 | *.o 23 | *.a 24 | *.so 25 | *.out 26 | 27 | # Ignore Windows-specific generated files 28 | *.obj 29 | *.pdb 30 | *.exp 31 | *.idb 32 | *.ipch 33 | *.iobj 34 | *.ipdb 35 | 36 | # Ignore Visual Studio Code files 37 | .vscode/ 38 | 39 | # Ignore Visual Studio files 40 | .vs/ 41 | 42 | # Ignore Premake-generated metadata and cache 43 | project_makefile 44 | Makefile 45 | Makefile.config 46 | build.ninja 47 | *.ninja 48 | 49 | # Ignore OS-specific metadata 50 | .DS_Store 51 | Thumbs.db 52 | desktop.ini 53 | 54 | # Ignore IDE-specific files 55 | .idea/ 56 | *.sublime-workspace 57 | *.sublime-project 58 | 59 | # Ignore Git merge conflict files 60 | *.orig 61 | *.rej 62 | 63 | # Ignore temporary files 64 | *.tmp 65 | *.swp 66 | *.bak 67 | 68 | # Ignore personal editor settings 69 | *.user 70 | *.suo 71 | *.ncb 72 | *.opendb 73 | *.sdf 74 | *.sln.docstates 75 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "vendor/googletest"] 2 | path = vendor/googletest 3 | url = https://github.com/google/googletest.git 4 | [submodule "vendor/spdlog"] 5 | path = vendor/spdlog 6 | url = https://github.com/gabime/spdlog.git 7 | [submodule "vendor/asio"] 8 | path = vendor/asio 9 | url = https://github.com/chriskohlhoff/asio.git 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # C++ Project Template 2 | 3 | [![License: Unlicense](https://img.shields.io/badge/license-Unlicense-blue.svg)](https://github.com/farukeryilmaz/cpp-project-template/blob/main/LICENSE) 4 | [![Windows build-test status](https://github.com/farukeryilmaz/cpp-project-template/actions/workflows/ci_windows.yml/badge.svg)](https://github.com/farukeryilmaz/cpp-project-template/actions/workflows/ci_windows.yml) 5 | [![GNU/Linux build-test status](https://github.com/farukeryilmaz/cpp-project-template/actions/workflows/ci_gnu_linux.yml/badge.svg)](https://github.com/farukeryilmaz/cpp-project-template/actions/workflows/ci_gnu_linux.yml) 6 | [![macOS build-test status](https://github.com/farukeryilmaz/cpp-project-template/actions/workflows/ci_macos.yml/badge.svg)](https://github.com/farukeryilmaz/cpp-project-template/actions/workflows/ci_macos.yml) 7 | 8 | Welcome to the C++ Project Template! This project template provides an easy way to kick-start a cross-platform C++ project using modern tooling and libraries like Premake5, GoogleTest, spdlog, and Standalone Asio. No additional configuration or installation is needed, and it builds on major platforms (Windows, Linux, macOS) out of the box. 9 | 10 | ## Key Features 11 | - **Premake5** for project generation and build configuration. 12 | - **Supports C++20** by default, with the option to use **C++11/14/17**. 13 | - **Cross-platform:** Tested on `Windows`, `GNU/Linux` and `macOS`. 14 | - **GoogleTest** for unit testing. 15 | - **spdlog** for fast and header-only logging. 16 | - **Standalone Asio** for asynchronous networking. 17 | - **No configuration or installation needed:** All dependencies are included as submodules. 18 | 19 | ## Getting Started 20 | ### Prerequisites 21 | - **C++ Compiler** with support for your desired C++ standard (e.g., GCC, Clang, MSVC). 22 | - **Git** for cloning the repository and managing submodules. 23 | 24 | ### Clone the Repository 25 | To get started, clone the repository along with its submodules: 26 | ```bash 27 | git clone --recursive https://github.com/farukeryilmaz/cpp-project-template.git 28 | ``` 29 | 30 | If you have already cloned the repository without submodules, you can initialize them with: 31 | ```bash 32 | git submodule update --init --recursive 33 | ``` 34 | 35 | ### Build the Project 36 | Premake5 is used to generate project files for various platforms and toolchains. The project already includes premake binaries for Windows, Linux, and macOS in the `vendor/premake/bin` directory, so no additional installation is required. However, if you prefer to use your own installation of Premake5, you can download it from [here](https://premake.github.io/download). 37 | > For more details on how to use Premake5, check the official [Premake documentation](https://premake.github.io/docs/). 38 | 39 | 1. **Generate Project Files**: Run the following command for your desired platform 40 | - **Windows** (Visual Studio) 41 | - For Visual Studio 2022, use: 42 | ```bash 43 | vendor/premake/bin/premake5.exe vs2022 44 | ``` 45 | - For earlier versions, replace vs2022 with vs2019, vs2017, etc., depending on your installed version: 46 | ```bash 47 | vendor/premake/bin/premake5.exe vs2019 48 | ``` 49 | - **GNU/Linux** (GNU Make) 50 | ```bash 51 | vendor/premake/bin/premake5_linux gmake2 52 | ``` 53 | - **macOS** (Xcode) 54 | ```bash 55 | vendor/premake/bin/premake5_macos xcode4 56 | ``` 57 | - **VSCode/CLion** (for all platforms): 58 | - Use `gmake2` argument. 59 | 60 | For more project generation commands, see the full list in the [Using Premake documentation](https://premake.github.io/docs/Using-Premake/). 61 | 2. **Build the Project:** 62 | - Generated project files are under `MyProject` folder. 63 | - For Visual Studio, open the generated `.sln` file and build from the IDE. 64 | - For GNU Make: 65 | ```bash 66 | make config=release 67 | ``` 68 | - For Xcode, open the generated project and build from Xcode. 69 | 70 | ### Configuring the C++ Standard 71 | By default, the project is configured to use C++20. If you wish to change the C++ standard, you can modify the cppdialect field in `premake5.lua`. 72 | For more details on the available C++ standards, check the official [Premake cppdialect documentation](https://premake.github.io/docs/cppdialect/). 73 | 74 | ## Code Formatting and Linting 75 | - **clang-format:** This project includes a `.clang-format` file to ensure consistent code style. Many modern IDEs, such as **Visual Studio** and **CLion**, have built-in support for **clang-format**, automatically applying formatting according to the specified rules when you save or edit files. You can also explicitly run `clang-format` on your source files to automatically format your code. 76 | - **clang-tidy:** The project also includes a `.clang-tidy` configuration file for static code analysis and linting. Many IDEs can run clang-tidy automatically as you write code, helping you catch issues early. However, you can also explicitly run `clang-tidy` from the command line to analyze your code. 77 | 78 | These tools help maintain code quality and consistency throughout your project. 79 | 80 | ## Continuous Integration (CI) 81 | This project comes with preconfigured GitHub Actions workflows that automatically build the project on: 82 | - **Windows** using Visual Studio 83 | - **GNU/Linux** using GCC 84 | - **macOS** using Xcode 85 | 86 | ## Upcoming Features 87 | - [ ] `GitLab CI/CD` and `Jenkins` integration are planned and will be added. 88 | - [x] `Cppcheck` static code analysis will be added to the CI process. 89 | - [ ] `SonarCloud` static code analysis will be integrated. 90 | 91 | ## Contributing 92 | Contributions are welcome! If you find a bug or have a suggestion for improvement, feel free to open an issue or submit a pull request. 93 | 94 | ## License 95 | This project is licensed under the `Unlicense`, which means you are free to use, modify, and distribute this project however you wish. See the [LICENSE](https://github.com/farukeryilmaz/cpp-project-template/blob/main/LICENSE) file for more details. 96 | -------------------------------------------------------------------------------- /premake5.lua: -------------------------------------------------------------------------------- 1 | workspace "MyProject" 2 | configurations { "Debug", "Release" } 3 | architecture "x86_64" 4 | flags { "MultiProcessorCompile" } 5 | location "MyProject" 6 | 7 | outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}" 8 | 9 | project "MyProject" 10 | kind "ConsoleApp" 11 | language "C++" 12 | cppdialect "C++20" 13 | location "MyProject/MyProject" 14 | 15 | targetdir ("bin/%{outputdir}") 16 | objdir ("bin-int/%{outputdir}") 17 | 18 | files { 19 | "src/**.hpp", 20 | "src/**.cpp" 21 | } 22 | 23 | includedirs { 24 | "vendor/asio/asio/include", 25 | "vendor/spdlog/include" 26 | } 27 | 28 | defines { "ASIO_STANDALONE" } 29 | 30 | filter "configurations:Debug" 31 | defines { "SV_DEBUG" } 32 | symbols "On" 33 | 34 | filter "configurations:Release" 35 | defines { "SV_RELEASE" } 36 | optimize "On" 37 | 38 | filter "system:windows" 39 | systemversion "latest" 40 | defines { "_WIN32_WINNT=0x0601" } 41 | 42 | filter "system:linux" 43 | links { "pthread" } 44 | 45 | filter "system:macosx" 46 | defines { "_DARWIN_C_SOURCE" } 47 | 48 | project "MyProjectTests" 49 | kind "ConsoleApp" 50 | language "C++" 51 | cppdialect "C++20" 52 | location "MyProject/MyProjectTests" 53 | 54 | targetdir ("bin/%{outputdir}") 55 | objdir ("bin-int/%{outputdir}") 56 | 57 | files { 58 | "tests/**.hpp", 59 | "tests/**.cpp", 60 | "vendor/googletest/googletest/src/gtest-all.cc", 61 | "vendor/googletest/googletest/src/gtest_main.cc" 62 | } 63 | 64 | includedirs { 65 | "vendor/googletest/googletest/include", 66 | "vendor/googletest/googletest", 67 | "vendor/asio/asio/include", 68 | "vendor/spdlog/include", 69 | "src" 70 | } 71 | 72 | links { 73 | "MyProject" 74 | } 75 | 76 | filter "configurations:Debug" 77 | defines { "SV_DEBUG" } 78 | symbols "On" 79 | 80 | filter "configurations:Release" 81 | defines { "SV_RELEASE" } 82 | optimize "On" 83 | 84 | filter "system:windows" 85 | systemversion "latest" 86 | defines { "_WIN32_WINNT=0x0601" } 87 | 88 | filter "system:linux" 89 | links { "pthread" } 90 | 91 | filter "system:macosx" 92 | defines { "_DARWIN_C_SOURCE" } -------------------------------------------------------------------------------- /src/example.hpp: -------------------------------------------------------------------------------- 1 | #ifndef EXAMPLE_HPP 2 | #define EXAMPLE_HPP 3 | 4 | namespace MyProject { 5 | // A simple addition function 6 | inline int add(const int a, const int b) { 7 | return a + b; 8 | } 9 | } 10 | 11 | #endif // EXAMPLE_HPP 12 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "spdlog/spdlog.h" 2 | 3 | int main() { 4 | spdlog::info("Hello, C++ Project Template!"); 5 | 6 | return 0; 7 | } -------------------------------------------------------------------------------- /tests/test_example.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "example.hpp" 4 | 5 | TEST(AdditionTest, HandlesPositiveInput) { 6 | EXPECT_EQ(MyProject::add(1, 2), 3); 7 | } 8 | 9 | TEST(AdditionTest, HandlesNegativeInput) { 10 | EXPECT_EQ(MyProject::add(-1, -1), -2); 11 | } 12 | 13 | TEST(AdditionTest, HandlesZeroInput) { 14 | EXPECT_EQ(MyProject::add(0, 0), 0); 15 | } 16 | -------------------------------------------------------------------------------- /vendor/premake/bin/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2003-2022 Jason Perkins and individual contributors. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | 3. Neither the name of Premake nor the names of its contributors may be 15 | used to endorse or promote products derived from this software without 16 | specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/premake/bin/premake5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/farukeryilmaz/cpp-project-template/7bc1c7898bd7655b35df0ec9a6b7dc192962ec7d/vendor/premake/bin/premake5.exe -------------------------------------------------------------------------------- /vendor/premake/bin/premake5_linux: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/farukeryilmaz/cpp-project-template/7bc1c7898bd7655b35df0ec9a6b7dc192962ec7d/vendor/premake/bin/premake5_linux -------------------------------------------------------------------------------- /vendor/premake/bin/premake5_macos: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/farukeryilmaz/cpp-project-template/7bc1c7898bd7655b35df0ec9a6b7dc192962ec7d/vendor/premake/bin/premake5_macos --------------------------------------------------------------------------------