├── .gitignore ├── App ├── Build-App.lua └── Source │ └── App.cpp ├── Build.lua ├── Core ├── Build-Core.lua └── Source │ └── Core │ ├── Core.cpp │ └── Core.h ├── README.md ├── Scripts ├── Setup-Linux.sh └── Setup-Windows.bat ├── UNLICENSE.txt └── Vendor └── Binaries └── Premake ├── LICENSE.txt ├── Linux └── premake5 ├── Windows └── premake5.exe └── macOS └── premake5 /.gitignore: -------------------------------------------------------------------------------- 1 | # Directories 2 | .vs/ 3 | Binaries/ 4 | 5 | # Files 6 | *.vcxproj 7 | *.vcxproj.user 8 | *.vcxproj.filters 9 | *.sln 10 | *.log 11 | Makefile 12 | 13 | # Exclude 14 | !Vendor/Binaries -------------------------------------------------------------------------------- /App/Build-App.lua: -------------------------------------------------------------------------------- 1 | project "App" 2 | kind "ConsoleApp" 3 | language "C++" 4 | cppdialect "C++20" 5 | targetdir "Binaries/%{cfg.buildcfg}" 6 | staticruntime "off" 7 | 8 | files { "Source/**.h", "Source/**.cpp" } 9 | 10 | includedirs 11 | { 12 | "Source", 13 | 14 | -- Include Core 15 | "../Core/Source" 16 | } 17 | 18 | links 19 | { 20 | "Core" 21 | } 22 | 23 | targetdir ("../Binaries/" .. OutputDir .. "/%{prj.name}") 24 | objdir ("../Binaries/Intermediates/" .. OutputDir .. "/%{prj.name}") 25 | 26 | filter "system:windows" 27 | systemversion "latest" 28 | defines { "WINDOWS" } 29 | 30 | filter "configurations:Debug" 31 | defines { "DEBUG" } 32 | runtime "Debug" 33 | symbols "On" 34 | 35 | filter "configurations:Release" 36 | defines { "RELEASE" } 37 | runtime "Release" 38 | optimize "On" 39 | symbols "On" 40 | 41 | filter "configurations:Dist" 42 | defines { "DIST" } 43 | runtime "Release" 44 | optimize "On" 45 | symbols "Off" -------------------------------------------------------------------------------- /App/Source/App.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Core.h" 2 | 3 | int main() 4 | { 5 | Core::PrintHelloWorld(); 6 | } -------------------------------------------------------------------------------- /Build.lua: -------------------------------------------------------------------------------- 1 | -- premake5.lua 2 | workspace "New Project" 3 | architecture "x64" 4 | configurations { "Debug", "Release", "Dist" } 5 | startproject "App" 6 | 7 | -- Workspace-wide build options for MSVC 8 | filter "system:windows" 9 | buildoptions { "/EHsc", "/Zc:preprocessor", "/Zc:__cplusplus" } 10 | 11 | OutputDir = "%{cfg.system}-%{cfg.architecture}/%{cfg.buildcfg}" 12 | 13 | group "Core" 14 | include "Core/Build-Core.lua" 15 | group "" 16 | 17 | include "App/Build-App.lua" -------------------------------------------------------------------------------- /Core/Build-Core.lua: -------------------------------------------------------------------------------- 1 | project "Core" 2 | kind "StaticLib" 3 | language "C++" 4 | cppdialect "C++20" 5 | targetdir "Binaries/%{cfg.buildcfg}" 6 | staticruntime "off" 7 | 8 | files { "Source/**.h", "Source/**.cpp" } 9 | 10 | includedirs 11 | { 12 | "Source" 13 | } 14 | 15 | targetdir ("../Binaries/" .. OutputDir .. "/%{prj.name}") 16 | objdir ("../Binaries/Intermediates/" .. OutputDir .. "/%{prj.name}") 17 | 18 | filter "system:windows" 19 | systemversion "latest" 20 | defines { } 21 | 22 | filter "configurations:Debug" 23 | defines { "DEBUG" } 24 | runtime "Debug" 25 | symbols "On" 26 | 27 | filter "configurations:Release" 28 | defines { "RELEASE" } 29 | runtime "Release" 30 | optimize "On" 31 | symbols "On" 32 | 33 | filter "configurations:Dist" 34 | defines { "DIST" } 35 | runtime "Release" 36 | optimize "On" 37 | symbols "Off" -------------------------------------------------------------------------------- /Core/Source/Core/Core.cpp: -------------------------------------------------------------------------------- 1 | #include "Core.h" 2 | 3 | #include 4 | 5 | namespace Core { 6 | 7 | void PrintHelloWorld() 8 | { 9 | std::cout << "Hello World!\n"; 10 | std::cin.get(); 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Core/Source/Core/Core.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Core { 4 | 5 | void PrintHelloWorld(); 6 | 7 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # C++ Project Starter Template 2 | 3 | This is a little quick-start project template for C++ projects which utilise a Core/App project architecture. There are two included projects - one called _Core_, and one called _App_. [Premake](https://github.com/premake/premake-core) is used to generate project files. 4 | 5 | Core builds into a static library and is meant to contain common code intended for use in multiple applications. App builds into an executable and links the Core static library, as well as provides an include path to Core's code. 6 | 7 | The `Scripts/` directory contains build scripts for Windows and Linux, and the `Vendor/` directory contains Premake binaries (currently version `5.0-beta2`). 8 | 9 | ## Getting Started 10 | 1. Clone this repository or use the "Use this template" button on GitHub to quickly set up your own repository based on this template 11 | 2. `App/` and `Core/` are the two projects - you can edit the names of these folders and their contents to suit 12 | 3. The three included Premake build files are `Build.lua`, `Core/Build-Core.lua` and `App/Build-App.lua` - you can edit these to customise your build configurations, edit the names of your projects and workspace/solution, etc. 13 | 4. Open the `Scripts/` directory and run the appropriate `Setup` script to generate projects files. You can edit the setup scripts to change the type of project that is generated - out of the box they are set to Visual Studio 2022 for Windows and gmake2 for Linux. 14 | 15 | Note that no macOS setup script is currently provided; you can duplicate the Linux script and adjust accordingly. 16 | 17 | ## Included 18 | - Some example code (in `App/Source` and `Core/Source`) to provide a starting point and test 19 | - Simple `.gitignore` to ignore project files and binaries 20 | - Premake binaries for Win/Mac/Linux (`v5.0-beta2`) 21 | 22 | ## License 23 | - UNLICENSE for this repository (see `UNLICENSE.txt` for more details) 24 | - Premake is licensed under BSD 3-Clause (see included LICENSE.txt file for more details) -------------------------------------------------------------------------------- /Scripts/Setup-Linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pushd .. 4 | Vendor/Binaries/Premake/Linux/premake5 --cc=clang --file=Build.lua gmake2 5 | popd 6 | -------------------------------------------------------------------------------- /Scripts/Setup-Windows.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | pushd .. 4 | Vendor\Binaries\Premake\Windows\premake5.exe --file=Build.lua vs2022 5 | popd 6 | pause -------------------------------------------------------------------------------- /UNLICENSE.txt: -------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------- /Vendor/Binaries/Premake/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/Binaries/Premake/Linux/premake5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCherno/ProjectTemplate/d4edaf76031bdafc3e61e375d2064ca5791ef1ee/Vendor/Binaries/Premake/Linux/premake5 -------------------------------------------------------------------------------- /Vendor/Binaries/Premake/Windows/premake5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCherno/ProjectTemplate/d4edaf76031bdafc3e61e375d2064ca5791ef1ee/Vendor/Binaries/Premake/Windows/premake5.exe -------------------------------------------------------------------------------- /Vendor/Binaries/Premake/macOS/premake5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheCherno/ProjectTemplate/d4edaf76031bdafc3e61e375d2064ca5791ef1ee/Vendor/Binaries/Premake/macOS/premake5 --------------------------------------------------------------------------------