pt
PT is a template for modern C++ projects with useful features for developing cross-platform products.
Science Score: 31.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.0%) to scientific vocabulary
Keywords
Repository
PT is a template for modern C++ projects with useful features for developing cross-platform products.
Basic Info
Statistics
- Stars: 103
- Watchers: 4
- Forks: 27
- Open Issues: 0
- Releases: 7
Topics
Metadata Files
README.md
Modern Project-Template (PT)
A template for modern C++ projects with useful features for developing cross-platform projects.
Cross-Platform project structure based on CMake
This repository is a modern project template based on C++ and CMake build tool.
Top features:
- ✅ Very easy management of dependencies.
- ✅ Top level macro usage.
- ✅ Customized project structure based on your program type.
- ✅ Advanced microprocessors.
- ✅ Cross-Platform
- ✅ Adapted to latest language & compiler standards.
Supported platforms:
- [x] macOS
- [x] Windows
- [x] Linux
- [x] freeBSD
- [ ] OpenBSD
- [ ] NetBSD
- [x] iOS
- [ ] watchOS
- [x] Android
Supported project type:
- [x] Core Application
- [x] Desktop Application
- [x] Embedded Application
- [x] Mobile Application
- [x] Library
Language Standard Support [C++2a or C++2b]
- It depends on your compiler!
Building
- You need CMake tool for building source code
- CMake 3.23 or higher is required.
``` cd build cmake .. make ./ProjectTemplate
```
How to sync project from template source? - This feature is embedded in the project as Git Action.
Customization options.
cmake .. -DPROJECT_NAME="Your Project Name" -DPROJECT_CREATOR="Kambiz" -DPROJECT_VERSION_TYPE="beta" -DPROJECT_DESCRIPTION="This is my awesome project" -DPROJECT_LICENSE_TYPE="mit"
Customization Note
- Change PROJECT_NAME variable to your own project name.
- Change PROJECT_CREATOR variable to your main project developer.
- Change PROJECT_DESCRIPTION variable to your project description.
- Change PROJECTHOMEPAGEURL variable to your project official url.
Change PROJECTVERSIONTYPE variable to your project version based on semantic versioning.
The project output structure is based on "application" with gui by default, so if you want to change it, you should change the PROJECTUSAGETYPE and PROJECTMAINTYPE variables.
Change the DEVELOPERBUNDLEIDENTIFIER variable for your own developer id, especially in Apple products, you should set it according to the bundle string in Xcode.
The language standard is based on C++17 by default, you can change it via CMAKECXXSTANDARD variable.
Finally, specify software version for the variables PROJECTVERSIONMAJOR, PROJECTVERSIONMINOR, PROJECTVERSIONPATCH and PROJECTVERSIONTWEAK.
Enjoy your project! :)
CMake module option [Dependencies]
- These features can be useful in downloading, building, and integrating prerequisites into your project.
So you can set cmake option variable for enabling them.
Include latest standard of C++
cmake .. -DUSE_LATEST_STANDARD=trueInclude Boost library
This option is currently usable if it's already installed on your system.
I'll work on the automatic downloader version as soon as possible.
cmake .. -DUSE_BOOST=trueInclude Qt Framework
cmake .. -DGUI_APPLICATION=trueForce to update latest version of dependencies from repositories.
cmake .. -DFORCE_UPGRADED_LIBS=falseInclude UI
cmake .. -DHAS_USER_INTERFACE=trueInclude project main type by [stl, qt, qtwidget, qtquick]
stl (Your project will be based on stl [Default]).
qt (Your project will be based on Qt Core only [No GUI]).
qtwidget (Your project will be based on C++, QtWidget [Classic GUI]).
qtquick (Your project will be based on C++, QtQuick and QML [Modern GUI]).
cmake .. -DPROJECT_MAIN_TYPE=stlProject Type
Use these keys [application, library]
cmake .. -DPROJECT_USAGE_TYPE=applicationProject Type
Use these keys [application, library]
cmake .. -DDEVELOPER_BUNDLE_IDENTIFIER=com.kambizasadzadeh.appThe Qt Quick Compiler is a development add-on for Qt Quick applications which allows you to compile QML source code into the final binary. When you use this add-on, the application's startup time is significantly improved and you no longer need to deploy .qml files together with the application.
cmake .. -DUSE_QT_QUICK_COMPILER=falseInclude Curl library
cmake .. -DUSE_CURL=trueInclude FMT library
cmake .. -DUSE_FMT=trueInclude CppCheck library
cmake .. -DUSE_CPP_CHECK=trueInclude Google-Test
cmake .. -DUSE_GOOGLE_TEST=trueInclude Doc-Test
cmake .. -DUSE_DOC_TEST=trueInclude Catch2
cmake .. -DUSE_CATCH2=trueInclude CTRE
cmake .. -DUSE_CTRE=trueInclude JSon library
cmake .. -DUSE_JSON=trueInclude OpenSSL
cmake .. -DUSE_OPENSSL=trueInclude ZLib
cmake .. -DDUSE_ZLIB=true
CMake module option [Compiler options]
Enabling the test of clang-tidy
cmake .. -DENABLE_CLANG_TIDY=trueBuild the project as minimally as possible
cmake .. -DSIMPLE_BUILD=trueEnable address sanitizer
cmake .. -DENABLE_ASAN=trueEnabling the build of safe codes only [check by warnings]!
cmake .. -DENABLE_WARN_MODE=trueEnabling the build of safe codes only!
cmake .. -DENABLE_SAFE_ONLY=trueEnable developer (debug) mode
cmake .. -DBUILD_DEBUG_MODE=trueEnabling the build of debug logging
cmake .. -DDEBUG_LOGGING=trueBuild Static Version
cmake .. -DENABLE_STATIC_LIB_BUILD=trueDeveloper mode
cmake .. -DENABLE_DEVELOPER_MODE=trueTodo mode
cmake .. -DENABLE_TODO_MODE=trueExperimental mode
cmake .. -DENABLE_EXPERIMENTAL_MODE=trueBuild Shared (Dynamic) Version
cmake .. -ENABLE_SHARED_LIB_BUILD=trueForcing to enable updated programming language.
cmake .. -FORCE_LATEST_STANDARD_FEATURE=trueOptimization level.
cmake .. -DOPTIMIZATION_LEVEL=0O Disables optimization, no optimization, fast compilation and nicely debuggable code. (default)
1 Some optimization. Is equivalent to 0 with no parameters. Optimization for code size and execution time, generate minimum size code.
2 Moderate optimization, enables all standard optimizations. Optimization more for code size and execution time, optimizes code for maximum speed.
3 Over and above 2, does aggressive optimizations that may not be compliant to language standard. Optimization more for code size and execution time
4 Over and above 3, does aggressive optimizations that may not be compliant to language standard. Optimizations for size over optimizations for speed.
5 O3 with fast none accurate math calculations, optimizations for speed over optimizations for size.
You can set or change your project's basic information such as name, description, link, etc.
set(PROJECT_NAME "ProjectTemplate" CACHE STRING "Project Name")
set(PROJECT_TARGET ${PROJECT_NAME} CACHE STRING "Target Name")
Creator Name.
set(PROJECT_CREATOR "Kambiz Asadzadeh")Project name, language, description, url and version.
project( ${PROJECT_NAME} LANGUAGES CXX DESCRIPTION "Description of your project." HOMEPAGE_URL "https://kambizasadzadeh.com" VERSION ${PROJECT_VERSION} )
Configuration output
```bash
-- The CXX compiler identification is AppleClang 12.0.0.12000032 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Ready for Apple Silicon. -- Performing Test COMPILERSUPPORTSCXX23 -- Performing Test COMPILERSUPPORTSCXX23 - Success -- Performing Test COMPILERSUPPORTSCXX20 -- Performing Test COMPILERSUPPORTSCXX20 - Success -- Performing Test COMPILERSUPPORTSCXX17 -- Performing Test COMPILERSUPPORTSCXX17 - Success -- Performing Test COMPILERSUPPORTSCXX14 -- Performing Test COMPILERSUPPORTSCXX14 - Success -- Performing Test COMPILERSUPPORTSCXX11 -- Performing Test COMPILERSUPPORTSCXX11 - Success -- Performing Test COMPILERSUPPORTSCXX0X -- Performing Test COMPILERSUPPORTSCXX0X - Success
-- ------ ProjectTemplate Tools Configuration ------ -- Language Standard : C++[20] -- Compiler : AppleClang -- Compiler Version : 12.0.0.12000032 -- OS Target : Darwin-20.3.0 -- OS Version : -- System Architecture : x8664 -- Project License : MIT -- ------ ProjectTemplate Framework Info ------ -- Name : ProjectTemplate -- Description : Description of your project. -- Version : -- ------ ProjectTemplate Project Configuration ------ -- DEVELOPER : -- PROJECTPROJECT : -- PROJECTTARGET : ProjectTemplate -- PROJECTVERSION : 1.0.2.0 -- PROJECTVERSIONTYPE : final -- ------ ProjectTemplate Building Configuration ------ -- PROJECTBUILDSHARED : -- PROJECTVERSIONTAGHEX : 0x00000000 -- PROJECTFOLDERSUFFIX : -- LIBRARYOUTPUTPATH : .../Project-Template/build/lib -- CMAKECURRENTSOURCEDIR : .../Project-Template -- ------ ProjectTemplate End Configuration ------ -- Configuring done ```
Usage Example
```cpp
if defined(HASUSERINTERFACE) && defined(USE_QT)
//! Qt
include
include
include
int main(int argc, char *argv[]) {
if QTVERSION < QTVERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
endif
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, url { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url);
return app.exec(); }
else
include
include "utilities/featuretest.hpp"
//! Examples
include "examples/compilertest.hpp"
include "examples/platformtest.hpp"
include "examples/librarytest.hpp"
include "examples/languagetest.hpp"
include "examples/configtest.hpp"
//!JSon [Non-STL] Features
include
//!Google Test
ifdef USEGOOGLETEST
include
class Counter { public: // Returns the current counter value, and increments it. int Increment() { return m_counter++; }
// Returns the current counter value, and decrements it. // counter can not be less than 0, return 0 in this case int Decrement() { if (mcounter == 0) { return mcounter; } else { return m_counter--; } }
// Prints the current counter value to STDOUT. void Print() const { printf("%d", mcounter); } private: int mcounter; };
//TEST UNIT TEST(Counter, Increment) { Counter c;
// Test that counter 0 returns 0 EXPECT_EQ(0, c.Decrement());
// EXPECT_EQ() evaluates its arguments exactly once, so they // can have side effects.
EXPECTEQ(0, c.Increment()); EXPECTEQ(1, c.Increment()); EXPECT_EQ(2, c.Increment());
EXPECT_EQ(3, c.Decrement()); }
endif
//!Catch2
ifdef USE_CATCH2
include
define CATCHCONFIGMAIN // This tells Catch to provide a main() - only do this in one cpp file
unsigned int Factorial( unsigned int number ) { return number <= 1 ? number : Factorial(number-1)*number; }
TEST_CASE( "Factorials are computed", "[factorial]" ) { REQUIRE( Factorial(1) == 1 ); REQUIRE( Factorial(2) == 2 ); REQUIRE( Factorial(3) == 6 ); REQUIRE( Factorial(10) == 3628800 ); }
endif
using namespace std;
int main() { cout << "Hello World!" << endl;
//!Config Test ConfigTest config; config.readSettings();
//!Compiler Test CompilerTest compiler; compiler.getCompilerInfo();
//!Platform Test PlatformTest platform; platform.getPlatformInfo();
//!Library Test LibraryTest library; library.testBoost(); // Boost
//!Language Features LanguageTest language; language.checkFeatures();
//!ThirdParty Library ThirdPartyTest thirdPartyTest; thirdPartyTest.testFmt();
return 0; }
endif
```
More usage examples
- Compiler Test ```cpp cout << "Compiler Name : " << COMPILER << endl; cout << "Compiler Version : " << COMPILER_VER << endl;
if defined(_COMPILERCLANGLLVM)
cout << "Clang compiler has been detected!\n";
elif defined(COMPILER_INTEL)
cout << "Intel compiler has been detected!\n";
elif defined(COMPILER_MINGW)
cout << "MinGW compiler has been detected!\n";
elif defined(COMPILERMINGW64)
cout << "MinGW64 compiler has been detected!\n";
elif defined(COMPILER_GCC)
cout << "GCC compiler has been detected!\n";
elif defined(COMPILERHEWLETT_)
cout << "Hewlett compiler has been detected!\n";
elif defined(COMPILER_IBM)
cout << "IBM compiler has been detected!\n";
elif defined(COMPILER_MSVC)
cout << "MSVC compiler has been detected!\n";
elif defined(COMPILER_PGCC)
cout << "PGCC compiler has been detected!\n";
elif defined(COMPILER_ORACLE)
cout << "Oracle compiler has been detected!\n";
endif
- Platform Test
cpp
if defined(PLATFORM_MAC)
cout << "This is macOS platform!\n";
elif defined(PLATFORM_WINDOWS)
cout << "This is Windows platform!\n";
elif defined(PLATFORM_LINUX)
cout << "This is Linux platform!\n";
elif defined(PLATFORM_FREEBSD)
cout << "This is freeBSD platform!\n";
elif defined(PLATFORM_OPENBSD)
cout << "This is openBSD platform!\n";
elif defined(PLATFORM_VXWORKS)
cout << "This is VXWorks platform!\n";
elif defined(PLATFORM_MOTOROLA)
cout << "This is Motorola platform!\n";
elif defined(PLATFORM_ULTRIX)
cout << "This is Ultrix platform!\n";
elif defined(PLATFORM_DOS)
cout << "This is Dos platform!\n";
elif defined(PLATFORMWINDOWSPHONE)
cout << "This is Windows Phone platform!\n";
elif defined(PLATFORMIOSSIMULATOR)
cout << "This is iOS Simulator platform!\n";
elif defined(PLATFORM_IOS)
cout << "This is iOS platform!\n";
elif defined(PLATFORMAPPLETV)
cout << "This is AppleTV platform!\n";
elif defined(PLATFORM_IWATCH)
cout << "This is iWatch platform!\n";
elif defined(PLATFORM_ANDROID)
cout << "This is Android platform!\n";
endif
- Library Test
cpp
include "include/common.hpp"
include
ifdef USE_BOOST
include
endif
LibraryTest::LibraryTest() {
}
void LibraryTest::testBoost() const noexcept { //!Boost Library
ifdef USE_BOOST
std::cout << "Boost version " << BOOSTVERSION << std::endl;
std::cout << "Boost Lib Clock Test\n";
boost::chrono::systemclock::timepoint start = boost::chrono::systemclock::now();
for ( long i = 0; i < 10000000; ++i )
std::sqrt( 123.456L ); // burn some time
boost::chrono::duration
else
std::cout << "Boost Library is not available.\n";
endif
} ```
- Language Test
cpp #ifdef USE_FEATURE_TEST if (print.general_features) show("C++ GENERAL", cxx); if (print.cxx11 && print.core_features) show("C++11 CORE", cxx11); if (print.cxx14 && print.core_features) show("C++14 CORE", cxx14); if (print.cxx14 && print.lib_features ) show("C++14 LIB" , cxx14lib); if (print.cxx17 && print.core_features) show("C++17 CORE", cxx17); if (print.cxx17 && print.lib_features ) show("C++17 LIB" , cxx17lib); if (print.cxx20 && print.core_features) show("C++20 CORE", cxx20); if (print.cxx20 && print.lib_features ) show("C++20 LIB" , cxx20lib); if (print.cxx23 && print.core_features) show("C++23 CORE", cxx23); if (print.cxx23 && print.lib_features ) show("C++23 LIB" , cxx23lib); if (print.attributes) show("ATTRIBUTES", attributes); #else std::cout << "Test Feature is not available.\n"; #endif - Config Test ```cpp
include "config.hpp"
include
std::cout << "========CONFIG TEST========" << std::endl;
std::cout << "Project Name : " << PROJECT_NAME << std::endl;
std::cout << "Project Description : " << PROJECT_DESCRIPTION << std::endl;
std::cout << "Project Homepage Url : " << PROJECT_HOMEPAGE_URL << std::endl;
std::cout << "Project Language : " << PROJECT_LANGUAGES << std::endl;
std::cout << "Project Full Version : " << PROJECT_VERSION_STRING << std::endl;
std::cout << "Project Creator : " << PROJECT_CREATOR << std::endl;
std::cout << "Project License Type : " << PROJECT_LICENSE_TYPE << std::endl;
std::cout << "========CONFIG TEST========" << std::endl;
```
If you want donate, Bitcoin address is here! <3

TOOD
- Bug fixing.
- Add new exception handler.
- Add new features.
- Support new libraries.
- Tell me your opinion about which other items should be added.
Contribution
- Bug fixes, docs, and enhancements welcome! Please let me know kambiz.ceo@gmail.com
Owner
- Name: The Genyleap ™
- Login: genyleap
- Kind: organization
- Email: info@genyleap.com
- Location: Worldwide
- Website: https://genyleap.com
- Twitter: genyleap
- Repositories: 3
- Profile: https://github.com/genyleap
Revolution of the software leap.
Citation (CITATION.md)
cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: "Asadzadeh" given-names: "Kambiz" orcid: "https://orcid.org/0009-0009-2065-3977" title: "PT" version: 1.1.222 date-released: 2023-04-25 url: "https://kambizasadzadeh.com" repository-code: "https://github.com/genyleap/Project-Template"
GitHub Events
Total
- Watch event: 1
- Fork event: 1
Last Year
- Watch event: 1
- Fork event: 1
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- actions/checkout v2 composite