├── 1_Intro └── .gitkeep ├── 3_Outro └── .gitkeep ├── 2_CMake ├── 13_LTO │ ├── .gitignore │ ├── external │ │ └── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── my_lib.h │ │ │ ├── my_lib.cc │ │ │ └── CMakeLists.txt │ ├── .gitmodules │ ├── configured │ │ ├── CMakeLists.txt │ │ └── config.hpp.in │ ├── Makefile │ ├── cmake │ │ ├── Docs.cmake │ │ ├── LTO.cmake │ │ ├── AddGitSubmodule.cmake │ │ ├── Warnings.cmake │ │ └── Sanitizer.cmake │ ├── .vscode │ │ ├── settings.json │ │ └── launch.json │ ├── tests │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── docs │ │ └── Doxyfile │ └── CMakeLists.txt ├── 14_CPM │ ├── .gitignore │ ├── external │ │ └── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── my_lib.h │ │ │ ├── my_lib.cc │ │ │ └── CMakeLists.txt │ ├── .gitmodules │ ├── configured │ │ ├── CMakeLists.txt │ │ └── config.hpp.in │ ├── Makefile │ ├── cmake │ │ ├── Docs.cmake │ │ ├── LTO.cmake │ │ ├── AddGitSubmodule.cmake │ │ ├── Warnings.cmake │ │ └── Sanitizer.cmake │ ├── .vscode │ │ ├── settings.json │ │ └── launch.json │ ├── tests │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ └── docs │ │ └── Doxyfile ├── 15_Conan │ ├── .gitignore │ ├── external │ │ └── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── my_lib.h │ │ │ ├── my_lib.cc │ │ │ └── CMakeLists.txt │ ├── .gitmodules │ ├── configured │ │ ├── CMakeLists.txt │ │ └── config.hpp.in │ ├── cmake │ │ ├── Docs.cmake │ │ ├── LTO.cmake │ │ ├── AddGitSubmodule.cmake │ │ ├── Warnings.cmake │ │ └── Sanitizer.cmake │ ├── Makefile │ ├── .vscode │ │ ├── settings.json │ │ └── launch.json │ ├── tests │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── ConanInstall.md │ ├── conanfile.py │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ └── docs │ │ └── Doxyfile ├── 16_VCPKG │ ├── .gitignore │ ├── external │ │ └── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── my_lib.h │ │ │ ├── my_lib.cc │ │ │ └── CMakeLists.txt │ ├── .gitmodules │ ├── configured │ │ ├── CMakeLists.txt │ │ └── config.hpp.in │ ├── VCPKG_Install.md │ ├── cmake │ │ ├── Docs.cmake │ │ ├── LTO.cmake │ │ ├── AddGitSubmodule.cmake │ │ ├── Warnings.cmake │ │ └── Sanitizer.cmake │ ├── Makefile │ ├── .vscode │ │ ├── settings.json │ │ └── launch.json │ ├── tests │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── conanfile.py │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── vcpkg.json │ └── docs │ │ └── Doxyfile ├── 07_Submodules │ ├── .gitignore │ ├── external │ │ └── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── my_lib.h │ │ │ ├── my_lib.cc │ │ │ └── CMakeLists.txt │ ├── .gitmodules │ ├── configured │ │ ├── CMakeLists.txt │ │ └── config.hpp.in │ ├── .vscode │ │ └── settings.json │ ├── Makefile │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── CMakeLists.txt │ └── cmake │ │ └── AddGitSubmodule.cmake ├── 09_Doxygen │ ├── .gitignore │ ├── external │ │ └── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── my_lib.h │ │ │ ├── my_lib.cc │ │ │ └── CMakeLists.txt │ ├── .gitmodules │ ├── configured │ │ ├── CMakeLists.txt │ │ └── config.hpp.in │ ├── .vscode │ │ └── settings.json │ ├── Makefile │ ├── cmake │ │ ├── Docs.cmake │ │ └── AddGitSubmodule.cmake │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── CMakeLists.txt │ └── docs │ │ └── Doxyfile ├── 10_UnitTest │ ├── .gitignore │ ├── external │ │ └── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── my_lib.h │ │ │ ├── my_lib.cc │ │ │ └── CMakeLists.txt │ ├── .gitmodules │ ├── configured │ │ ├── CMakeLists.txt │ │ └── config.hpp.in │ ├── Makefile │ ├── cmake │ │ ├── Docs.cmake │ │ └── AddGitSubmodule.cmake │ ├── .vscode │ │ ├── settings.json │ │ ├── tasks.json │ │ └── launch.json │ ├── tests │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── CMakeLists.txt │ └── docs │ │ └── Doxyfile ├── 11_Warnings │ ├── .gitignore │ ├── external │ │ └── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── my_lib.h │ │ │ ├── my_lib.cc │ │ │ └── CMakeLists.txt │ ├── .gitmodules │ ├── configured │ │ ├── CMakeLists.txt │ │ └── config.hpp.in │ ├── .vscode │ │ ├── settings.json │ │ └── launch.json │ ├── Makefile │ ├── cmake │ │ ├── Docs.cmake │ │ ├── AddGitSubmodule.cmake │ │ └── Warnings.cmake │ ├── tests │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── docs │ │ └── Doxyfile │ └── CMakeLists.txt ├── 12_Sanitizers │ ├── .gitignore │ ├── external │ │ └── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── my_lib.h │ │ │ ├── my_lib.cc │ │ │ └── CMakeLists.txt │ ├── .gitmodules │ ├── configured │ │ ├── CMakeLists.txt │ │ └── config.hpp.in │ ├── Makefile │ ├── cmake │ │ ├── Docs.cmake │ │ ├── AddGitSubmodule.cmake │ │ ├── Warnings.cmake │ │ └── Sanitizer.cmake │ ├── .vscode │ │ ├── settings.json │ │ └── launch.json │ ├── tests │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── docs │ │ └── Doxyfile │ └── CMakeLists.txt ├── 07_ExternalGit │ ├── .gitignore │ ├── external │ │ └── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── my_lib.h │ │ │ ├── my_lib.cc │ │ │ └── CMakeLists.txt │ ├── .gitmodules │ ├── configured │ │ ├── CMakeLists.txt │ │ └── config.hpp.in │ ├── .vscode │ │ └── settings.json │ ├── Makefile │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── CMakeLists.txt │ └── cmake │ │ └── AddGitSubmodule.cmake ├── 08_FetchContent │ ├── .gitignore │ ├── external │ │ └── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── my_lib.h │ │ │ ├── my_lib.cc │ │ │ └── CMakeLists.txt │ ├── .gitmodules │ ├── configured │ │ ├── CMakeLists.txt │ │ └── config.hpp.in │ ├── .vscode │ │ └── settings.json │ ├── Makefile │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── cmake │ │ └── AddGitSubmodule.cmake │ └── CMakeLists.txt ├── _Additional │ ├── PreCompiledLib_Find │ │ ├── external │ │ │ ├── lib │ │ │ │ └── .gitkeep │ │ │ └── inc │ │ │ │ └── lib.h │ │ ├── main.cc │ │ ├── CmakeLists.txt │ │ └── cmake │ │ │ └── FindLibExample.cmake │ ├── PreCompiledLib_Self │ │ ├── external │ │ │ ├── lib │ │ │ │ └── .gitkeep │ │ │ └── inc │ │ │ │ └── lib.h │ │ ├── main.cc │ │ └── CmakeLists.txt │ ├── LibExample │ │ ├── inc │ │ │ └── lib.h │ │ ├── src │ │ │ └── lib.cc │ │ └── CmakeLists.txt │ ├── ListString │ │ ├── inc │ │ │ └── lib.h │ │ ├── src │ │ │ └── lib.cc │ │ └── CMakeLists.txt │ ├── CrossCompiler │ │ ├── inc │ │ │ └── lib.h │ │ ├── src │ │ │ └── lib.cc │ │ ├── CMakeLists.txt │ │ ├── Toolchains │ │ │ ├── x86-64-native-toolchain.cmake │ │ │ ├── arm32-native-toolchain.cmake │ │ │ ├── arm32-cross-toolchain.cmake │ │ │ └── x86-64-mingw-toolchain.cmake │ │ └── README.md │ ├── GeneratorExpression │ │ ├── inc │ │ │ └── lib.h │ │ ├── src │ │ │ └── lib.cc │ │ ├── .gitattributes │ │ ├── .editorconfig │ │ ├── CMakeLists.txt │ │ └── .gitignore │ ├── CustomCommand │ │ ├── src │ │ │ ├── CMakeLists.txt │ │ │ └── main.cc │ │ ├── HeaderLib │ │ │ ├── Lib.h │ │ │ └── CMakeLists.txt │ │ ├── CMakeLists.txt │ │ ├── cmake │ │ │ └── CustomPythonTarget.cmake │ │ └── scripts │ │ │ └── CustomPythonTarget.py │ ├── CustomTarget │ │ ├── src │ │ │ ├── CMakeLists.txt │ │ │ └── main.cc │ │ ├── HeaderLib │ │ │ ├── Lib.h │ │ │ └── CMakeLists.txt │ │ ├── CMakeLists.txt │ │ ├── cmake │ │ │ └── CustomPythonTarget.cmake │ │ └── scripts │ │ │ └── CustomPythonTarget.py │ └── HeaderOnlyLib │ │ ├── src │ │ ├── CMakeLists.txt │ │ └── main.cc │ │ ├── HeaderLib │ │ ├── Lib.h │ │ └── CMakeLists.txt │ │ └── CMakeLists.txt ├── 05_ConfigureFile │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── my_lib.h │ │ │ ├── my_lib.cc │ │ │ └── CMakeLists.txt │ ├── Makefile │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── .vscode │ │ └── settings.json │ ├── configured │ │ ├── CMakeLists.txt │ │ └── config.hpp.in │ └── CMakeLists.txt ├── 06_BetterProject │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── my_lib.h │ │ │ ├── my_lib.cc │ │ │ └── CMakeLists.txt │ ├── Makefile │ ├── configured │ │ ├── CMakeLists.txt │ │ └── config.hpp.in │ ├── .vscode │ │ └── settings.json │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ └── CMakeLists.txt ├── 04_VariablesOptions │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── my_lib.h │ │ │ ├── CMakeLists.txt │ │ │ └── my_lib.cc │ ├── Makefile │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── .vscode │ │ └── settings.json │ └── CMakeLists.txt ├── 06_SourcesAndHeaders │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── my_lib.h │ │ │ ├── my_lib.cc │ │ │ └── CMakeLists.txt │ ├── Makefile │ ├── configured │ │ ├── CMakeLists.txt │ │ └── config.hpp.in │ ├── .vscode │ │ └── settings.json │ ├── app │ │ ├── main.cc │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── 03_IntermediateProject_2 │ ├── inc │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── my_lib.h │ │ │ └── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── CMakeLists.txt │ │ │ └── my_lib.cc │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── .vscode │ │ └── settings.json │ └── CMakeLists.txt ├── 03_IntermediateProject_3 │ ├── src │ │ ├── CMakeLists.txt │ │ └── my_lib │ │ │ ├── inc │ │ │ ├── my_lib.h │ │ │ └── CMakeLists.txt │ │ │ ├── CMakeLists.txt │ │ │ └── src │ │ │ ├── CMakeLists.txt │ │ │ └── my_lib.cc │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── .vscode │ │ └── settings.json │ └── CMakeLists.txt ├── 02_BasicProject │ ├── my_lib.h │ ├── my_lib.cc │ ├── main.cc │ ├── .vscode │ │ └── settings.json │ └── CMakeLists.txt ├── Final_Link.md ├── 03_IntermediateProject │ ├── src │ │ ├── my_lib │ │ │ ├── my_lib.h │ │ │ ├── my_lib.cc │ │ │ └── CMakeLists.txt │ │ └── CMakeLists.txt │ ├── app │ │ ├── CMakeLists.txt │ │ └── main.cc │ ├── .vscode │ │ └── settings.json │ └── CMakeLists.txt ├── 01_HelloWorld │ ├── main.cc │ ├── .vscode │ │ └── settings.json │ └── CMakeLists.txt ├── VCPKG_Install.md ├── Makefile ├── ConanInstall.md └── Doxyfile ├── .gitattributes ├── Makefile ├── .editorconfig ├── README.md ├── .pre-commit-config.yaml ├── .clang-tidy ├── LICENSE └── .gitignore /1_Intro/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /3_Outro/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /2_CMake/07_Submodules/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2_CMake/07_ExternalGit/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /2_CMake/07_ExternalGit/external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2_CMake/07_Submodules/external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2_CMake/08_FetchContent/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /2_CMake/08_FetchContent/external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/_Additional/PreCompiledLib_Find/external/lib/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2_CMake/_Additional/PreCompiledLib_Self/external/lib/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/05_ConfigureFile/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/06_BetterProject/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/07_ExternalGit/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/07_Submodules/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/08_FetchContent/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/04_VariablesOptions/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/06_SourcesAndHeaders/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_2/inc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_2/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_3/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(my_lib) 2 | -------------------------------------------------------------------------------- /2_CMake/05_ConfigureFile/Makefile: -------------------------------------------------------------------------------- 1 | prepare: 2 | rm -rf build 3 | mkdir build 4 | -------------------------------------------------------------------------------- /2_CMake/06_BetterProject/Makefile: -------------------------------------------------------------------------------- 1 | prepare: 2 | rm -rf build 3 | mkdir build 4 | -------------------------------------------------------------------------------- /2_CMake/_Additional/LibExample/inc/lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void Function(); 4 | -------------------------------------------------------------------------------- /2_CMake/_Additional/ListString/inc/lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void Function(); 4 | -------------------------------------------------------------------------------- /2_CMake/02_BasicProject/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | -------------------------------------------------------------------------------- /2_CMake/04_VariablesOptions/Makefile: -------------------------------------------------------------------------------- 1 | prepare: 2 | rm -rf build 3 | mkdir build 4 | -------------------------------------------------------------------------------- /2_CMake/06_SourcesAndHeaders/Makefile: -------------------------------------------------------------------------------- 1 | prepare: 2 | rm -rf build 3 | mkdir build 4 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CrossCompiler/inc/lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void Function(); 4 | -------------------------------------------------------------------------------- /2_CMake/07_Submodules/src/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | -------------------------------------------------------------------------------- /2_CMake/Final_Link.md: -------------------------------------------------------------------------------- 1 | # Link 2 | 3 | 4 | -------------------------------------------------------------------------------- /2_CMake/_Additional/GeneratorExpression/inc/lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void Function(); 4 | -------------------------------------------------------------------------------- /2_CMake/05_ConfigureFile/src/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | -------------------------------------------------------------------------------- /2_CMake/06_BetterProject/src/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | -------------------------------------------------------------------------------- /2_CMake/07_ExternalGit/src/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | -------------------------------------------------------------------------------- /2_CMake/08_FetchContent/src/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject/src/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | -------------------------------------------------------------------------------- /2_CMake/04_VariablesOptions/src/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | -------------------------------------------------------------------------------- /2_CMake/06_SourcesAndHeaders/src/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | -------------------------------------------------------------------------------- /2_CMake/_Additional/PreCompiledLib_Find/external/inc/lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void Function(); 4 | -------------------------------------------------------------------------------- /2_CMake/_Additional/PreCompiledLib_Self/external/inc/lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void Function(); 4 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_2/inc/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_3/src/my_lib/inc/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_2/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(${LIBRARY_NAME} STATIC "my_lib.cc") 2 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_3/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(src) 2 | add_subdirectory(inc) 3 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_2/inc/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_include_directories(${LIBRARY_NAME} PUBLIC "./") 2 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_3/src/my_lib/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(${LIBRARY_NAME} STATIC "my_lib.cc") 2 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_3/src/my_lib/inc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_include_directories(${LIBRARY_NAME} PUBLIC "./") 2 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/json"] 2 | path = external/json 3 | url = https://github.com/nlohmann/json 4 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/json"] 2 | path = external/json 3 | url = https://github.com/nlohmann/json 4 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/json"] 2 | path = external/json 3 | url = https://github.com/nlohmann/json 4 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/json"] 2 | path = external/json 3 | url = https://github.com/nlohmann/json 4 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/json"] 2 | path = external/json 3 | url = https://github.com/nlohmann/json 4 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/json"] 2 | path = external/json 3 | url = https://github.com/nlohmann/json 4 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/json"] 2 | path = external/json 3 | url = https://github.com/nlohmann/json 4 | -------------------------------------------------------------------------------- /2_CMake/07_ExternalGit/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/json"] 2 | path = external/json 3 | url = https://github.com/nlohmann/json 4 | -------------------------------------------------------------------------------- /2_CMake/07_Submodules/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/json"] 2 | path = external/json 3 | url = https://github.com/nlohmann/json 4 | -------------------------------------------------------------------------------- /2_CMake/08_FetchContent/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/json"] 2 | path = external/json 3 | url = https://github.com/nlohmann/json 4 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/json"] 2 | path = external/json 3 | url = https://github.com/nlohmann/json 4 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CustomCommand/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(Main main.cc) 2 | target_link_libraries(Main PRIVATE HeaderLib) 3 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CustomTarget/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(Main main.cc) 2 | target_link_libraries(Main PRIVATE HeaderLib) 3 | -------------------------------------------------------------------------------- /2_CMake/_Additional/HeaderOnlyLib/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(Main main.cc) 2 | target_link_libraries(Main PRIVATE HeaderLib) 3 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/src/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | 5 | std::uint32_t factorial(std::uint32_t number); 6 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/src/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | 5 | std::uint32_t factorial(std::uint32_t number); 6 | -------------------------------------------------------------------------------- /2_CMake/_Additional/PreCompiledLib_Find/main.cc: -------------------------------------------------------------------------------- 1 | #include "lib.h" 2 | 3 | int main() 4 | { 5 | Function(); 6 | 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/_Additional/PreCompiledLib_Self/main.cc: -------------------------------------------------------------------------------- 1 | #include "lib.h" 2 | 3 | int main() 4 | { 5 | Function(); 6 | 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/01_HelloWorld/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | std::cout << "Hello World\n"; 6 | 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/src/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | 5 | std::uint32_t factorial(std::uint32_t number); 6 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/src/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | 5 | std::uint32_t factorial(std::uint32_t number); 6 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/src/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | 5 | std::uint32_t factorial(std::uint32_t number); 6 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/src/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | 5 | std::uint32_t factorial(std::uint32_t number); 6 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/src/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void print_hello_world(); 4 | 5 | std::uint32_t factorial(std::uint32_t number); 6 | -------------------------------------------------------------------------------- /2_CMake/05_ConfigureFile/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(${EXECUTABLE_NAME} "main.cc") 2 | target_link_libraries(${EXECUTABLE_NAME} PUBLIC ${LIBRARY_NAME}) 3 | -------------------------------------------------------------------------------- /2_CMake/_Additional/LibExample/src/lib.cc: -------------------------------------------------------------------------------- 1 | #include "lib.h" 2 | 3 | #include 4 | 5 | void Function() 6 | { 7 | std::cout << "Called\n"; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/_Additional/ListString/src/lib.cc: -------------------------------------------------------------------------------- 1 | #include "lib.h" 2 | 3 | #include 4 | 5 | void Function() 6 | { 7 | std::cout << "Called\n"; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(${EXECUTABLE_NAME} "main.cc") 2 | target_link_libraries(${EXECUTABLE_NAME} PUBLIC ${LIBRARY_NAME}) 3 | -------------------------------------------------------------------------------- /2_CMake/04_VariablesOptions/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(${EXECUTABLE_NAME} "main.cc") 2 | target_link_libraries(${EXECUTABLE_NAME} PUBLIC ${LIBRARY_NAME}) 3 | -------------------------------------------------------------------------------- /2_CMake/04_VariablesOptions/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(${LIBRARY_NAME} STATIC "my_lib.cc") 2 | target_include_directories(${LIBRARY_NAME} PUBLIC "./") 3 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/src/my_lib/my_lib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /** 4 | * @brief Prints out hello world to the console 5 | * 6 | */ 7 | void print_hello_world(); 8 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CrossCompiler/src/lib.cc: -------------------------------------------------------------------------------- 1 | #include "lib.h" 2 | 3 | #include 4 | 5 | void Function() 6 | { 7 | std::cout << "Called\n"; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CustomTarget/src/main.cc: -------------------------------------------------------------------------------- 1 | #include "Lib.h" 2 | 3 | int main(int argc, char const *argv[]) 4 | { 5 | printer(1); 6 | 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/02_BasicProject/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | void print_hello_world() 6 | { 7 | std::cout << "Hello World!\n"; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_2/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(${EXECUTABLE_NAME} "main.cc") 2 | target_link_libraries(${EXECUTABLE_NAME} PUBLIC ${LIBRARY_NAME}) 3 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_3/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(${EXECUTABLE_NAME} "main.cc") 2 | target_link_libraries(${EXECUTABLE_NAME} PUBLIC ${LIBRARY_NAME}) 3 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/configured/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file( 2 | "config.hpp.in" 3 | "${CMAKE_BINARY_DIR}/configured_files/include/config.hpp" ESCAPE_QUOTES 4 | ) 5 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/configured/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file( 2 | "config.hpp.in" 3 | "${CMAKE_BINARY_DIR}/configured_files/include/config.hpp" ESCAPE_QUOTES 4 | ) 5 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/configured/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file( 2 | "config.hpp.in" 3 | "${CMAKE_BINARY_DIR}/configured_files/include/config.hpp" ESCAPE_QUOTES 4 | ) 5 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/configured/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file( 2 | "config.hpp.in" 3 | "${CMAKE_BINARY_DIR}/configured_files/include/config.hpp" ESCAPE_QUOTES 4 | ) 5 | -------------------------------------------------------------------------------- /2_CMake/_Additional/GeneratorExpression/src/lib.cc: -------------------------------------------------------------------------------- 1 | #include "lib.h" 2 | 3 | #include 4 | 5 | void Function() 6 | { 7 | std::cout << "Called\n"; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/_Additional/HeaderOnlyLib/src/main.cc: -------------------------------------------------------------------------------- 1 | #include "Lib.h" 2 | 3 | int main(int argc, char const *argv[]) 4 | { 5 | printer(1); 6 | 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/07_ExternalGit/configured/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file( 2 | "config.hpp.in" 3 | "${CMAKE_BINARY_DIR}/configured_files/include/config.hpp" ESCAPE_QUOTES 4 | ) 5 | -------------------------------------------------------------------------------- /2_CMake/07_Submodules/configured/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file( 2 | "config.hpp.in" 3 | "${CMAKE_BINARY_DIR}/configured_files/include/config.hpp" ESCAPE_QUOTES 4 | ) 5 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/configured/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file( 2 | "config.hpp.in" 3 | "${CMAKE_BINARY_DIR}/configured_files/include/config.hpp" ESCAPE_QUOTES 4 | ) 5 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/configured/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file( 2 | "config.hpp.in" 3 | "${CMAKE_BINARY_DIR}/configured_files/include/config.hpp" ESCAPE_QUOTES 4 | ) 5 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/configured/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file( 2 | "config.hpp.in" 3 | "${CMAKE_BINARY_DIR}/configured_files/include/config.hpp" ESCAPE_QUOTES 4 | ) 5 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/configured/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file( 2 | "config.hpp.in" 3 | "${CMAKE_BINARY_DIR}/configured_files/include/config.hpp" ESCAPE_QUOTES 4 | ) 5 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CustomCommand/HeaderLib/Lib.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | template 4 | void printer(N value) 5 | { 6 | std::cout << value << "\n"; 7 | } 8 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CustomTarget/HeaderLib/Lib.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | template 4 | void printer(N value) 5 | { 6 | std::cout << value << "\n"; 7 | } 8 | -------------------------------------------------------------------------------- /2_CMake/_Additional/HeaderOnlyLib/HeaderLib/Lib.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | template 4 | void printer(N value) 5 | { 6 | std::cout << value << "\n"; 7 | } 8 | -------------------------------------------------------------------------------- /2_CMake/01_HelloWorld/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible" 4 | } 5 | -------------------------------------------------------------------------------- /2_CMake/02_BasicProject/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | int main() 6 | { 7 | print_hello_world(); 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /2_CMake/05_ConfigureFile/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | void print_hello_world() 6 | { 7 | std::cout << "Hello World!\n"; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/06_BetterProject/configured/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file( 2 | "config.hpp.in" 3 | "${CMAKE_BINARY_DIR}/configured_files/include/config.hpp" ESCAPE_QUOTES 4 | ) 5 | -------------------------------------------------------------------------------- /2_CMake/06_BetterProject/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | void print_hello_world() 6 | { 7 | std::cout << "Hello World!\n"; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/07_ExternalGit/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible" 4 | } 5 | -------------------------------------------------------------------------------- /2_CMake/07_ExternalGit/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | void print_hello_world() 6 | { 7 | std::cout << "Hello World!\n"; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/07_Submodules/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible" 4 | } 5 | -------------------------------------------------------------------------------- /2_CMake/07_Submodules/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | void print_hello_world() 6 | { 7 | std::cout << "Hello World!\n"; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/08_FetchContent/configured/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file( 2 | "config.hpp.in" 3 | "${CMAKE_BINARY_DIR}/configured_files/include/config.hpp" ESCAPE_QUOTES 4 | ) 5 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible" 4 | } 5 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible" 4 | } 5 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/Makefile: -------------------------------------------------------------------------------- 1 | dependency: 2 | cd build && cmake .. --graphviz=graph.dot && dot -Tpng graph.dot -o graphImage.png 3 | 4 | prepare: 5 | rm -rf build 6 | mkdir build 7 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/Makefile: -------------------------------------------------------------------------------- 1 | dependency: 2 | cd build && cmake .. --graphviz=graph.dot && dot -Tpng graph.dot -o graphImage.png 3 | 4 | prepare: 5 | rm -rf build 6 | mkdir build 7 | -------------------------------------------------------------------------------- /2_CMake/02_BasicProject/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible" 4 | } 5 | -------------------------------------------------------------------------------- /2_CMake/04_VariablesOptions/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible" 4 | } 5 | -------------------------------------------------------------------------------- /2_CMake/04_VariablesOptions/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | int main() 6 | { 7 | print_hello_world(); 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /2_CMake/04_VariablesOptions/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | void print_hello_world() 6 | { 7 | std::cout << "Hello World!\n"; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/05_ConfigureFile/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible" 4 | } 5 | -------------------------------------------------------------------------------- /2_CMake/06_BetterProject/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible" 4 | } 5 | -------------------------------------------------------------------------------- /2_CMake/06_SourcesAndHeaders/configured/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file( 2 | "config.hpp.in" 3 | "${CMAKE_BINARY_DIR}/configured_files/include/config.hpp" ESCAPE_QUOTES 4 | ) 5 | -------------------------------------------------------------------------------- /2_CMake/06_SourcesAndHeaders/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | void print_hello_world() 6 | { 7 | std::cout << "Hello World!\n"; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/07_ExternalGit/Makefile: -------------------------------------------------------------------------------- 1 | dependency: 2 | cd build && cmake .. --graphviz=graph.dot && dot -Tpng graph.dot -o graphImage.png 3 | 4 | prepare: 5 | rm -rf build 6 | mkdir build 7 | -------------------------------------------------------------------------------- /2_CMake/07_Submodules/Makefile: -------------------------------------------------------------------------------- 1 | dependency: 2 | cd build && cmake .. --graphviz=graph.dot && dot -Tpng graph.dot -o graphImage.png 3 | 4 | prepare: 5 | rm -rf build 6 | mkdir build 7 | -------------------------------------------------------------------------------- /2_CMake/08_FetchContent/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible" 4 | } 5 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/Makefile: -------------------------------------------------------------------------------- 1 | dependency: 2 | cd build && cmake .. --graphviz=graph.dot && dot -Tpng graph.dot -o graphImage.png 3 | 4 | prepare: 5 | rm -rf build 6 | mkdir build 7 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/Makefile: -------------------------------------------------------------------------------- 1 | dependency: 2 | cd build && cmake .. --graphviz=graph.dot && dot -Tpng graph.dot -o graphImage.png 3 | 4 | prepare: 5 | rm -rf build 6 | mkdir build 7 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/Makefile: -------------------------------------------------------------------------------- 1 | dependency: 2 | cd build && cmake .. --graphviz=graph.dot && dot -Tpng graph.dot -o graphImage.png 3 | 4 | prepare: 5 | rm -rf build 6 | mkdir build 7 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/Makefile: -------------------------------------------------------------------------------- 1 | dependency: 2 | cd build && cmake .. --graphviz=graph.dot && dot -Tpng graph.dot -o graphImage.png 3 | 4 | prepare: 5 | rm -rf build 6 | mkdir build 7 | -------------------------------------------------------------------------------- /2_CMake/_Additional/HeaderOnlyLib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(HeaderOnlyLibExample) 2 | cmake_minimum_required(VERSION 3.20) 3 | 4 | add_subdirectory(HeaderLib) 5 | add_subdirectory(src) 6 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible" 4 | } 5 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | int main() 6 | { 7 | print_hello_world(); 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | void print_hello_world() 6 | { 7 | std::cout << "Hello World!\n"; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_2/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible" 4 | } 5 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_2/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | int main() 6 | { 7 | print_hello_world(); 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_2/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | void print_hello_world() 6 | { 7 | std::cout << "Hello World!\n"; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_3/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible" 4 | } 5 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_3/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | int main() 6 | { 7 | print_hello_world(); 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /2_CMake/06_SourcesAndHeaders/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible" 4 | } 5 | -------------------------------------------------------------------------------- /2_CMake/08_FetchContent/Makefile: -------------------------------------------------------------------------------- 1 | dependency: 2 | cd build && cmake .. --graphviz=graph.dot && dot -Tpng graph.dot -o graphImage.png 3 | 4 | prepare: 5 | rm -rf build 6 | mkdir build 7 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_3/src/my_lib/src/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | void print_hello_world() 6 | { 7 | std::cout << "Hello World!\n"; 8 | } 9 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CustomCommand/src/main.cc: -------------------------------------------------------------------------------- 1 | #include "Lib.h" 2 | 3 | int main(int argc, char const *argv[]) 4 | { 5 | printer(1); 6 | printer(2); 7 | 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CustomTarget/HeaderLib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Create the header-only library target 2 | add_library(HeaderLib INTERFACE) 3 | target_include_directories(HeaderLib INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 4 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CustomCommand/HeaderLib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Create the header-only library target 2 | add_library(HeaderLib INTERFACE) 3 | target_include_directories(HeaderLib INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 4 | -------------------------------------------------------------------------------- /2_CMake/_Additional/HeaderOnlyLib/HeaderLib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Create the header-only library target 2 | add_library(HeaderLib INTERFACE) 3 | target_include_directories(HeaderLib INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 4 | -------------------------------------------------------------------------------- /2_CMake/05_ConfigureFile/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(${LIBRARY_NAME} STATIC "my_lib.cc") 2 | target_include_directories(${LIBRARY_NAME} PUBLIC 3 | "./" 4 | "${CMAKE_BINARY_DIR}/configured_files/include") 5 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Just add the inner dir for our library 2 | # This src dir can have multiple libs included 3 | # For example subdirs like: "my_lib1", "my_lib2", etc. 4 | add_subdirectory(my_lib) 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior for all files. 2 | * text=auto eol=lf 3 | 4 | # Normalized and converts to native line endings on checkout. 5 | *.c text 6 | *.cc text 7 | *.cxx 8 | *.cpp text 9 | *.h text 10 | *.hxx text 11 | *.hpp text 12 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | clean: 2 | find . -name build -type d -print0|xargs -0 rm -rf -- 3 | find . -name *.exe -type f -print0|xargs -0 rm -rf -- 4 | find . -name *.out -type f -print0|xargs -0 rm -rf -- 5 | find . -name *.o -type f -print0|xargs -0 rm -rf -- 6 | 7 | .phony: clean 8 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(CppProjectTemplate VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(EXECUTABLE_NAME Executable) 6 | set(LIBRARY_NAME Library) 7 | 8 | add_subdirectory(src) 9 | add_subdirectory(app) 10 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(CppProjectTemplate VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(EXECUTABLE_NAME Executable) 6 | set(LIBRARY_NAME Library) 7 | 8 | add_subdirectory(src) 9 | add_subdirectory(app) 10 | -------------------------------------------------------------------------------- /2_CMake/VCPKG_Install.md: -------------------------------------------------------------------------------- 1 | # How to install VCPKG 2 | 3 | Official Link: 4 | 5 | ```cmd 6 | cd external 7 | git clone https://github.com/Microsoft/vcpkg.git 8 | .\vcpkg\bootstrap-vcpkg.bat # windows 9 | ./vcpkg/bootstrap-vcpkg.sh # Unix 10 | ``` 11 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CustomCommand/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.28) 2 | 3 | project(CustomTargetExample) 4 | 5 | set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") 6 | include(CustomPythonTarget) 7 | 8 | add_subdirectory(HeaderLib) 9 | add_subdirectory(src) 10 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CustomTarget/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.28) 2 | 3 | project(CustomTargetExample) 4 | 5 | set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") 6 | include(CustomPythonTarget) 7 | 8 | add_subdirectory(HeaderLib) 9 | add_subdirectory(src) 10 | -------------------------------------------------------------------------------- /2_CMake/06_BetterProject/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(EXE_SOURCES "main.cc") 2 | set(EXE_INCLUDES "./") 3 | 4 | add_executable(${EXECUTABLE_NAME} ${EXE_SOURCES}) 5 | target_include_directories(${EXECUTABLE_NAME} PUBLIC ${EXE_INCLUDES}) 6 | target_link_libraries(${EXECUTABLE_NAME} PUBLIC ${LIBRARY_NAME}) 7 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/VCPKG_Install.md: -------------------------------------------------------------------------------- 1 | # How to install VCPKG 2 | 3 | Official Link: 4 | 5 | ```cmd 6 | cd external 7 | git clone https://github.com/Microsoft/vcpkg.git 8 | .\vcpkg\bootstrap-vcpkg.bat # windows 9 | ./vcpkg/bootstrap-vcpkg.sh # Unix 10 | ``` 11 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CrossCompiler/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(LibExample VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(LIBRARY_NAME LibExample) 6 | 7 | add_library(${LIBRARY_NAME} STATIC src/lib.cc) 8 | target_include_directories(${LIBRARY_NAME} PUBLIC inc/) 9 | -------------------------------------------------------------------------------- /2_CMake/_Additional/GeneratorExpression/.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior for all files. 2 | * text=auto eol=lf 3 | 4 | # Normalized and converts to native line endings on checkout. 5 | *.c text 6 | *.cc text 7 | *.cxx 8 | *.cpp text 9 | *.h text 10 | *.hxx text 11 | *.hpp text 12 | -------------------------------------------------------------------------------- /2_CMake/_Additional/LibExample/CmakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(LibExample VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(LIBRARY_NAME LibExample) 6 | 7 | add_library(${LIBRARY_NAME} STATIC src/lib.cc) 8 | target_include_directories(${LIBRARY_NAME} PUBLIC inc/) 9 | -------------------------------------------------------------------------------- /2_CMake/_Additional/ListString/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(LibExample VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(LIBRARY_NAME LibExample) 6 | 7 | add_library(${LIBRARY_NAME} STATIC src/lib.cc) 8 | target_include_directories(${LIBRARY_NAME} PUBLIC inc/) 9 | -------------------------------------------------------------------------------- /2_CMake/05_ConfigureFile/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "config.hpp" 4 | #include "my_lib.h" 5 | 6 | int main() 7 | { 8 | std::cout << project_name << '\n'; 9 | std::cout << project_version << '\n'; 10 | 11 | print_hello_world(); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /2_CMake/06_BetterProject/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "config.hpp" 4 | #include "my_lib.h" 5 | 6 | int main() 7 | { 8 | std::cout << project_name << '\n'; 9 | std::cout << project_version << '\n'; 10 | 11 | print_hello_world(); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /2_CMake/06_SourcesAndHeaders/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "config.hpp" 4 | #include "my_lib.h" 5 | 6 | int main() 7 | { 8 | std::cout << project_name << '\n'; 9 | std::cout << project_version << '\n'; 10 | 11 | print_hello_world(); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/cmake/Docs.cmake: -------------------------------------------------------------------------------- 1 | find_package(Doxygen) 2 | 3 | if (DOXYGEN_FOUND) 4 | add_custom_target(docs 5 | COMMAND ${DOXYGEN_EXECUTABLE} 6 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs 7 | COMMENT "Generating HTML documentation with Doxygen" 8 | ) 9 | endif() 10 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/cmake/Docs.cmake: -------------------------------------------------------------------------------- 1 | find_package(Doxygen) 2 | 3 | if (DOXYGEN_FOUND) 4 | add_custom_target(docs 5 | COMMAND ${DOXYGEN_EXECUTABLE} 6 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs 7 | COMMENT "Generating HTML documentation with Doxygen" 8 | ) 9 | endif() 10 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/cmake/Docs.cmake: -------------------------------------------------------------------------------- 1 | find_package(Doxygen) 2 | 3 | if (DOXYGEN_FOUND) 4 | add_custom_target(docs 5 | COMMAND ${DOXYGEN_EXECUTABLE} 6 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs 7 | COMMENT "Generating HTML documentation with Doxygen" 8 | ) 9 | endif() 10 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/cmake/Docs.cmake: -------------------------------------------------------------------------------- 1 | find_package(Doxygen) 2 | 3 | if (DOXYGEN_FOUND) 4 | add_custom_target(docs 5 | COMMAND ${DOXYGEN_EXECUTABLE} 6 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs 7 | COMMENT "Generating HTML documentation with Doxygen" 8 | ) 9 | endif() 10 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/cmake/Docs.cmake: -------------------------------------------------------------------------------- 1 | find_package(Doxygen) 2 | 3 | if (DOXYGEN_FOUND) 4 | add_custom_target(docs 5 | COMMAND ${DOXYGEN_EXECUTABLE} 6 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs 7 | COMMENT "Generating HTML documentation with Doxygen" 8 | ) 9 | endif() 10 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/cmake/Docs.cmake: -------------------------------------------------------------------------------- 1 | find_package(Doxygen) 2 | 3 | if (DOXYGEN_FOUND) 4 | add_custom_target(docs 5 | COMMAND ${DOXYGEN_EXECUTABLE} 6 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs 7 | COMMENT "Generating HTML documentation with Doxygen" 8 | ) 9 | endif() 10 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/cmake/Docs.cmake: -------------------------------------------------------------------------------- 1 | find_package(Doxygen) 2 | 3 | if (DOXYGEN_FOUND) 4 | add_custom_target(docs 5 | COMMAND ${DOXYGEN_EXECUTABLE} 6 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs 7 | COMMENT "Generating HTML documentation with Doxygen" 8 | ) 9 | endif() 10 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/cmake/Docs.cmake: -------------------------------------------------------------------------------- 1 | find_package(Doxygen) 2 | 3 | if (DOXYGEN_FOUND) 4 | add_custom_target(docs 5 | COMMAND ${DOXYGEN_EXECUTABLE} 6 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs 7 | COMMENT "Generating HTML documentation with Doxygen" 8 | ) 9 | endif() 10 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject_2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(CppProjectTemplate VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(EXECUTABLE_NAME Executable) 6 | set(LIBRARY_NAME Library) 7 | 8 | add_subdirectory(src) 9 | add_subdirectory(inc) 10 | add_subdirectory(app) 11 | -------------------------------------------------------------------------------- /2_CMake/06_SourcesAndHeaders/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(EXE_SOURCES 2 | "main.cc") 3 | set(EXE_INCLUDES 4 | "./") 5 | 6 | add_executable(${EXECUTABLE_NAME} ${EXE_SOURCES}) 7 | target_include_directories(${EXECUTABLE_NAME} PUBLIC ${EXE_INCLUDES}) 8 | target_link_libraries(${EXECUTABLE_NAME} PUBLIC ${LIBRARY_NAME}) 9 | -------------------------------------------------------------------------------- /2_CMake/Makefile: -------------------------------------------------------------------------------- 1 | dependency: 2 | cd build && cmake .. --graphviz=graph.dot && dot -Tpng graph.dot -o graphImage.png 3 | 4 | prepare: 5 | rm -rf build 6 | mkdir build 7 | 8 | install: 9 | sudo apt-get install gcovr lcov 10 | 11 | install_doc: 12 | pip install jinja2 Pygments 13 | sudo apt-get install doxygen 14 | -------------------------------------------------------------------------------- /2_CMake/03_IntermediateProject/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(${LIBRARY_NAME} STATIC "my_lib.cc") 2 | # Include dir to header files 3 | # This does not have to be set, to be able to compile the program 4 | # However, for MSVC builds this is needed, to have the headers listed in VS. 5 | target_include_directories(${LIBRARY_NAME} PUBLIC "./") 6 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/Makefile: -------------------------------------------------------------------------------- 1 | conan_d: 2 | rm -rf build 3 | mkdir build 4 | cd build && conan install .. -s build_type=Debug -s compiler.cppstd=17 --output-folder=. --build missing 5 | 6 | conan_r: 7 | rm -rf build 8 | mkdir build 9 | cd build && conan install .. -s build_type=Release -s compiler.cppstd=17 --output-folder=. --build missing 10 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/Makefile: -------------------------------------------------------------------------------- 1 | conan_d: 2 | rm -rf build 3 | mkdir build 4 | cd build && conan install .. -s build_type=Debug -s compiler.cppstd=17 --output-folder=. --build missing 5 | 6 | conan_r: 7 | rm -rf build 8 | mkdir build 9 | cd build && conan install .. -s build_type=Release -s compiler.cppstd=17 --output-folder=. --build missing 10 | -------------------------------------------------------------------------------- /2_CMake/05_ConfigureFile/configured/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Note: If you open the config.hhp.in file in VSCode it is normal that the code has red squiggly lines. 2 | # VSCode think its a normal header file, which it isnt. 3 | # But thats okay. 4 | configure_file( 5 | "config.hpp.in" 6 | "${CMAKE_BINARY_DIR}/configured_files/include/config.hpp" ESCAPE_QUOTES 7 | ) 8 | -------------------------------------------------------------------------------- /2_CMake/06_BetterProject/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIBRARY_SOURCES 2 | "my_lib.cc") 3 | set(LIBRARY_HEADERS 4 | "my_lib.h") 5 | 6 | add_library(${LIBRARY_NAME} STATIC 7 | ${LIBRARY_SOURCES} 8 | ${LIBRARY_HEADERS}) 9 | target_include_directories(${LIBRARY_NAME} PUBLIC 10 | "./" 11 | "${CMAKE_BINARY_DIR}/configured_files/include") 12 | -------------------------------------------------------------------------------- /2_CMake/07_ExternalGit/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIBRARY_SOURCES 2 | "my_lib.cc") 3 | set(LIBRARY_HEADERS 4 | "my_lib.h") 5 | 6 | add_library(${LIBRARY_NAME} STATIC 7 | ${LIBRARY_SOURCES} 8 | ${LIBRARY_HEADERS}) 9 | target_include_directories(${LIBRARY_NAME} PUBLIC 10 | "./" 11 | "${CMAKE_BINARY_DIR}/configured_files/include") 12 | -------------------------------------------------------------------------------- /2_CMake/07_Submodules/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIBRARY_SOURCES 2 | "my_lib.cc") 3 | set(LIBRARY_HEADERS 4 | "my_lib.h") 5 | 6 | add_library(${LIBRARY_NAME} STATIC 7 | ${LIBRARY_SOURCES} 8 | ${LIBRARY_HEADERS}) 9 | target_include_directories(${LIBRARY_NAME} PUBLIC 10 | "./" 11 | "${CMAKE_BINARY_DIR}/configured_files/include") 12 | -------------------------------------------------------------------------------- /2_CMake/06_SourcesAndHeaders/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIBRARY_SOURCES 2 | "my_lib.cc") 3 | set(LIBRARY_HEADERS 4 | "my_lib.h") 5 | 6 | add_library(${LIBRARY_NAME} STATIC 7 | ${LIBRARY_SOURCES} 8 | ${LIBRARY_HEADERS}) 9 | target_include_directories(${LIBRARY_NAME} PUBLIC 10 | "./" 11 | "${CMAKE_BINARY_DIR}/configured_files/include") 12 | -------------------------------------------------------------------------------- /2_CMake/07_ExternalGit/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(EXE_SOURCES 2 | "main.cc") 3 | set(EXE_INCLUDES 4 | "./") 5 | 6 | add_executable(${EXECUTABLE_NAME} 7 | ${EXE_SOURCES}) 8 | target_include_directories(${EXECUTABLE_NAME} PUBLIC 9 | ${EXE_INCLUDES}) 10 | target_link_libraries(${EXECUTABLE_NAME} PUBLIC 11 | ${LIBRARY_NAME} 12 | nlohmann_json) 13 | -------------------------------------------------------------------------------- /2_CMake/07_Submodules/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(EXE_SOURCES 2 | "main.cc") 3 | set(EXE_INCLUDES 4 | "./") 5 | 6 | add_executable(${EXECUTABLE_NAME} 7 | ${EXE_SOURCES}) 8 | target_include_directories(${EXECUTABLE_NAME} PUBLIC 9 | ${EXE_INCLUDES}) 10 | target_link_libraries(${EXECUTABLE_NAME} PUBLIC 11 | ${LIBRARY_NAME} 12 | nlohmann_json) 13 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 4 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | end_of_line = lf 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [Makefile] 16 | indent_style = tab 17 | trim_trailing_whitespace = false 18 | -------------------------------------------------------------------------------- /2_CMake/02_BasicProject/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(CppProjectTemplate VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(EXECUTABLE_NAME Executable) 6 | set(LIBRARY_NAME Library) 7 | 8 | add_library(${LIBRARY_NAME} my_lib.cc) 9 | 10 | add_executable(${EXECUTABLE_NAME} main.cc) 11 | 12 | target_link_libraries(${EXECUTABLE_NAME} ${LIBRARY_NAME}) 13 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include "my_lib.h" 6 | 7 | void print_hello_world() 8 | { 9 | std::cout << "Hello World!\n"; 10 | 11 | std::cout << "JSON Lib Version:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 12 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 13 | } 14 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible", 4 | "files.associations": { 5 | "*.pyx": "cython", 6 | ".clang*": "yaml", 7 | "*.gpj": "jsonc", 8 | "*.gvw": "jsonc", 9 | "*.hpp.in": "cpp", 10 | "limits": "cpp" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible", 4 | "files.associations": { 5 | "*.pyx": "cython", 6 | ".clang*": "yaml", 7 | "*.gpj": "jsonc", 8 | "*.gvw": "jsonc", 9 | "*.hpp.in": "cpp", 10 | "limits": "cpp" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /2_CMake/08_FetchContent/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include "my_lib.h" 6 | 7 | void print_hello_world() 8 | { 9 | std::cout << "Hello World!\n"; 10 | 11 | std::cout << "JSON Lib Version:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 12 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 13 | } 14 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible", 4 | "files.associations": { 5 | "*.pyx": "cython", 6 | ".clang*": "yaml", 7 | "*.gpj": "jsonc", 8 | "*.gvw": "jsonc", 9 | "*.hpp.in": "cpp", 10 | "limits": "cpp" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(Catch) 2 | 3 | set(TEST_MAIN "unit_tests") 4 | set(TEST_SOURCES "main.cc") 5 | set(TEST_INCLUDES "./") 6 | 7 | add_executable(${TEST_MAIN} ${TEST_SOURCES}) 8 | target_include_directories(${TEST_MAIN} PUBLIC ${TEST_INCLUDES}) 9 | target_link_libraries(${TEST_MAIN} PUBLIC ${LIBRARY_NAME} Catch2::Catch2WithMain) 10 | 11 | catch_discover_tests(${TEST_MAIN}) 12 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(Catch) 2 | 3 | set(TEST_MAIN "unit_tests") 4 | set(TEST_SOURCES "main.cc") 5 | set(TEST_INCLUDES "./") 6 | 7 | add_executable(${TEST_MAIN} ${TEST_SOURCES}) 8 | target_include_directories(${TEST_MAIN} PUBLIC ${TEST_INCLUDES}) 9 | target_link_libraries(${TEST_MAIN} PUBLIC ${LIBRARY_NAME} Catch2::Catch2WithMain) 10 | 11 | catch_discover_tests(${TEST_MAIN}) 12 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible", 4 | "files.associations": { 5 | "*.pyx": "cython", 6 | ".clang*": "yaml", 7 | "*.gpj": "jsonc", 8 | "*.gvw": "jsonc", 9 | "*.hpp.in": "cpp", 10 | "limits": "cpp" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(Catch) 2 | 3 | set(TEST_MAIN "unit_tests") 4 | set(TEST_SOURCES "main.cc") 5 | set(TEST_INCLUDES "./") 6 | 7 | add_executable(${TEST_MAIN} ${TEST_SOURCES}) 8 | target_include_directories(${TEST_MAIN} PUBLIC ${TEST_INCLUDES}) 9 | target_link_libraries(${TEST_MAIN} PUBLIC ${LIBRARY_NAME} Catch2::Catch2WithMain) 10 | 11 | catch_discover_tests(${TEST_MAIN}) 12 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible", 4 | "files.associations": { 5 | "*.pyx": "cython", 6 | ".clang*": "yaml", 7 | "*.gpj": "jsonc", 8 | "*.gvw": "jsonc", 9 | "*.hpp.in": "cpp", 10 | "limits": "cpp" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(Catch) 2 | 3 | set(TEST_MAIN "unit_tests") 4 | set(TEST_SOURCES "main.cc") 5 | set(TEST_INCLUDES "./") 6 | 7 | add_executable(${TEST_MAIN} ${TEST_SOURCES}) 8 | target_include_directories(${TEST_MAIN} PUBLIC ${TEST_INCLUDES}) 9 | target_link_libraries(${TEST_MAIN} PUBLIC ${LIBRARY_NAME} Catch2::Catch2WithMain) 10 | 11 | catch_discover_tests(${TEST_MAIN}) 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CMake, Testing and Tooling for C/C++ 2 | 3 | This is the code to my Udemy course: 4 | *CMake, Testing and Tooling for C/C++* by Jan Schaffranek. 5 | 6 | ## Sale-Coupons 7 | 8 | Link to my sale coupons: [Link](https://github.com/franneck94/YoutubeVideos/blob/master/EnglishCourses.md) 9 | 10 | ## CMake Readme 11 | 12 | The CMake Readme is in Chapter 2 see [here](./2_CMake/README.md) 13 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(Catch) 2 | 3 | set(TEST_MAIN "unit_tests") 4 | set(TEST_SOURCES "main.cc") 5 | set(TEST_INCLUDES "./") 6 | 7 | add_executable(${TEST_MAIN} ${TEST_SOURCES}) 8 | target_include_directories(${TEST_MAIN} PUBLIC ${TEST_INCLUDES}) 9 | target_link_libraries(${TEST_MAIN} PUBLIC ${LIBRARY_NAME} Catch2::Catch2WithMain) 10 | 11 | catch_discover_tests(${TEST_MAIN}) 12 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(Catch) 2 | 3 | set(TEST_MAIN "unit_tests") 4 | set(TEST_SOURCES "main.cc") 5 | set(TEST_INCLUDES "./") 6 | 7 | add_executable(${TEST_MAIN} ${TEST_SOURCES}) 8 | target_include_directories(${TEST_MAIN} PUBLIC ${TEST_INCLUDES}) 9 | target_link_libraries(${TEST_MAIN} PUBLIC ${LIBRARY_NAME} Catch2::Catch2WithMain) 10 | 11 | catch_discover_tests(${TEST_MAIN}) 12 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.options.statusBarVisibility": "visible", 4 | "files.associations": { 5 | "*.pyx": "cython", 6 | ".clang*": "yaml", 7 | "*.gpj": "jsonc", 8 | "*.gvw": "jsonc", 9 | "*.hpp.in": "cpp", 10 | "limits": "cpp" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(Catch) 2 | 3 | set(TEST_MAIN "unit_tests") 4 | set(TEST_SOURCES "main.cc") 5 | set(TEST_INCLUDES "./") 6 | 7 | add_executable(${TEST_MAIN} ${TEST_SOURCES}) 8 | target_include_directories(${TEST_MAIN} PUBLIC ${TEST_INCLUDES}) 9 | target_link_libraries(${TEST_MAIN} PUBLIC ${LIBRARY_NAME} Catch2::Catch2WithMain) 10 | 11 | catch_discover_tests(${TEST_MAIN}) 12 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CrossCompiler/Toolchains/x86-64-native-toolchain.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR x86_64) 3 | 4 | set(CMAKE_C_COMPILER gcc) 5 | set(CMAKE_CXX_COMPILER g++) 6 | 7 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 8 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 9 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 10 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 11 | -------------------------------------------------------------------------------- /2_CMake/_Additional/GeneratorExpression/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 4 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | end_of_line = lf 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [Makefile] 16 | indent_style = tab 17 | trim_trailing_whitespace = false 18 | -------------------------------------------------------------------------------- /2_CMake/08_FetchContent/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(EXE_SOURCES "main.cc") 2 | set(EXE_INCLUDES "./") 3 | 4 | add_executable(${EXECUTABLE_NAME} ${EXE_SOURCES}) 5 | target_include_directories(${EXECUTABLE_NAME} PUBLIC ${EXE_INCLUDES}) 6 | target_link_libraries( 7 | ${EXECUTABLE_NAME} PUBLIC 8 | ${LIBRARY_NAME} 9 | nlohmann_json::nlohmann_json 10 | fmt::fmt 11 | spdlog::spdlog 12 | cxxopts::cxxopts) 13 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(EXE_SOURCES 2 | "main.cc") 3 | set(EXE_INCLUDES 4 | "./") 5 | 6 | add_executable(${EXECUTABLE_NAME} ${EXE_SOURCES}) 7 | target_include_directories(${EXECUTABLE_NAME} PUBLIC 8 | ${EXE_INCLUDES}) 9 | target_link_libraries(${EXECUTABLE_NAME} PUBLIC 10 | ${LIBRARY_NAME} 11 | nlohmann_json::nlohmann_json 12 | fmt::fmt 13 | spdlog::spdlog 14 | cxxopts::cxxopts) 15 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(EXE_SOURCES 2 | "main.cc") 3 | set(EXE_INCLUDES 4 | "./") 5 | 6 | add_executable(${EXECUTABLE_NAME} ${EXE_SOURCES}) 7 | target_include_directories(${EXECUTABLE_NAME} PUBLIC 8 | ${EXE_INCLUDES}) 9 | target_link_libraries(${EXECUTABLE_NAME} PUBLIC 10 | ${LIBRARY_NAME} 11 | nlohmann_json::nlohmann_json 12 | fmt::fmt 13 | spdlog::spdlog 14 | cxxopts::cxxopts) 15 | -------------------------------------------------------------------------------- /2_CMake/05_ConfigureFile/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(CppProjectTemplate VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | set(CMAKE_CXX_EXTENSIONS OFF) 8 | 9 | set(LIBRARY_NAME Library) 10 | set(EXECUTABLE_NAME Executable) 11 | 12 | add_subdirectory(configured) 13 | add_subdirectory(src) 14 | add_subdirectory(app) 15 | -------------------------------------------------------------------------------- /2_CMake/06_BetterProject/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(CppProjectTemplate VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | set(CMAKE_CXX_EXTENSIONS OFF) 8 | 9 | set(LIBRARY_NAME Library) 10 | set(EXECUTABLE_NAME Executable) 11 | 12 | add_subdirectory(configured) 13 | add_subdirectory(src) 14 | add_subdirectory(app) 15 | -------------------------------------------------------------------------------- /2_CMake/06_SourcesAndHeaders/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(CppProjectTemplate VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | set(CMAKE_CXX_EXTENSIONS OFF) 8 | 9 | set(LIBRARY_NAME Library) 10 | set(EXECUTABLE_NAME Executable) 11 | 12 | add_subdirectory(configured) 13 | add_subdirectory(src) 14 | add_subdirectory(app) 15 | -------------------------------------------------------------------------------- /2_CMake/01_HelloWorld/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 0.) Create Source and CMakeFile 2 | # 1.) mkdir build 3 | # 2.) cd build 4 | # 3.) cmake .. - Generting the Build Files / Configure the Project 5 | # 4.) cmake --build . 6 | # 5.) ./Executable 7 | 8 | cmake_minimum_required(VERSION 3.22) 9 | 10 | project(CppProjectTemplate VERSION 1.0.0 LANGUAGES C CXX) 11 | 12 | # User defined name 13 | # v 14 | add_executable(Executable main.cc) 15 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CrossCompiler/Toolchains/arm32-native-toolchain.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR arm) 3 | 4 | set(CMAKE_C_COMPILER gcc) 5 | set(CMAKE_C_FLAGS -static) 6 | set(CMAKE_CXX_COMPILER g++) 7 | set(CMAKE_CXX_FLAGS -static) 8 | 9 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 10 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 11 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 12 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 13 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | fail_fast: false 2 | repos: 3 | - repo: https://github.com/pre-commit/pre-commit-hooks 4 | rev: v4.4.0 5 | hooks: 6 | - id: check-yaml 7 | - id: check-json 8 | exclude: .vscode 9 | - id: end-of-file-fixer 10 | - id: trailing-whitespace 11 | 12 | - repo: https://github.com/pre-commit/mirrors-clang-format 13 | rev: 'v16.0.3' 14 | hooks: 15 | - id: clang-format 16 | exclude_types: [javascript, json] 17 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CrossCompiler/Toolchains/arm32-cross-toolchain.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR arm) 3 | 4 | set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) 5 | set(CMAKE_C_FLAGS -static) 6 | set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) 7 | set(CMAKE_CXX_FLAGS -static) 8 | 9 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 10 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 11 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 12 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 13 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CustomTarget/cmake/CustomPythonTarget.cmake: -------------------------------------------------------------------------------- 1 | set(CUSTOM_TARGET_NAME "CustomPythonTarget") 2 | if(NOT TARGET ${CUSTOM_TARGET_NAME}) 3 | add_custom_target( 4 | ${CUSTOM_TARGET_NAME} 5 | COMMAND python CustomPythonTarget.py --input_dir ${PROJECT_SOURCE_DIR}/src --output_dir ${PROJECT_BINARY_DIR} 6 | WORKING_DIRECTORY 7 | ${PROJECT_SOURCE_DIR}/scripts 8 | # DEPENDS Main 9 | ) 10 | add_dependencies(${CUSTOM_TARGET_NAME} Main) 11 | endif() 12 | -------------------------------------------------------------------------------- /2_CMake/07_Submodules/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include "config.hpp" 6 | #include "my_lib.h" 7 | 8 | int main() 9 | { 10 | std::cout << project_name << '\n'; 11 | std::cout << project_version << '\n'; 12 | 13 | std::cout << "JSON Lib Version:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 14 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 15 | 16 | print_hello_world(); 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/configured/config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | static constexpr std::string_view project_name = "@PROJECT_NAME@"; 7 | static constexpr std::string_view project_version = "@PROJECT_VERSION@"; 8 | 9 | static constexpr std::int32_t project_version_major{@PROJECT_VERSION_MAJOR@}; 10 | static constexpr std::int32_t project_version_minor{@PROJECT_VERSION_MINOR@}; 11 | static constexpr std::int32_t project_version_patch{@PROJECT_VERSION_PATCH@}; 12 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/configured/config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | static constexpr std::string_view project_name = "@PROJECT_NAME@"; 7 | static constexpr std::string_view project_version = "@PROJECT_VERSION@"; 8 | 9 | static constexpr std::int32_t project_version_major{@PROJECT_VERSION_MAJOR@}; 10 | static constexpr std::int32_t project_version_minor{@PROJECT_VERSION_MINOR@}; 11 | static constexpr std::int32_t project_version_patch{@PROJECT_VERSION_PATCH@}; 12 | -------------------------------------------------------------------------------- /2_CMake/ConanInstall.md: -------------------------------------------------------------------------------- 1 | # How to install the Conan Package Manager 2 | 3 | Official installation guide is [here](https://docs.conan.io/2/). 4 | 5 | The conan database is [here](https://conan.io/center/). 6 | 7 | ## Installation Steps 8 | 9 | 1. Install Python (3.7+) 10 | 2. Type ``pip install --user -U conan`` into the terminal 11 | 1. Unix: Append conan to the PATH by: ``source ~/.profile`` 12 | 3. Run the conan command: ``conan`` 13 | 4. conan profile detect --force 14 | 5. conan profile path default 15 | -------------------------------------------------------------------------------- /2_CMake/07_ExternalGit/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include "config.hpp" 6 | #include "my_lib.h" 7 | 8 | int main() 9 | { 10 | std::cout << project_name << '\n'; 11 | std::cout << project_version << '\n'; 12 | 13 | std::cout << "JSON Lib Version:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 14 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 15 | 16 | print_hello_world(); 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/configured/config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | static constexpr std::string_view project_name = "@PROJECT_NAME@"; 7 | static constexpr std::string_view project_version = "@PROJECT_VERSION@"; 8 | 9 | static constexpr std::int32_t project_version_major{@PROJECT_VERSION_MAJOR@}; 10 | static constexpr std::int32_t project_version_minor{@PROJECT_VERSION_MINOR@}; 11 | static constexpr std::int32_t project_version_patch{@PROJECT_VERSION_PATCH@}; 12 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/configured/config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | static constexpr std::string_view project_name = "@PROJECT_NAME@"; 7 | static constexpr std::string_view project_version = "@PROJECT_VERSION@"; 8 | 9 | static constexpr std::int32_t project_version_major{@PROJECT_VERSION_MAJOR@}; 10 | static constexpr std::int32_t project_version_minor{@PROJECT_VERSION_MINOR@}; 11 | static constexpr std::int32_t project_version_patch{@PROJECT_VERSION_PATCH@}; 12 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/configured/config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | static constexpr std::string_view project_name = "@PROJECT_NAME@"; 7 | static constexpr std::string_view project_version = "@PROJECT_VERSION@"; 8 | 9 | static constexpr std::int32_t project_version_major{@PROJECT_VERSION_MAJOR@}; 10 | static constexpr std::int32_t project_version_minor{@PROJECT_VERSION_MINOR@}; 11 | static constexpr std::int32_t project_version_patch{@PROJECT_VERSION_PATCH@}; 12 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/configured/config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | static constexpr std::string_view project_name = "@PROJECT_NAME@"; 7 | static constexpr std::string_view project_version = "@PROJECT_VERSION@"; 8 | 9 | static constexpr std::int32_t project_version_major{@PROJECT_VERSION_MAJOR@}; 10 | static constexpr std::int32_t project_version_minor{@PROJECT_VERSION_MINOR@}; 11 | static constexpr std::int32_t project_version_patch{@PROJECT_VERSION_PATCH@}; 12 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/configured/config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | static constexpr std::string_view project_name = "@PROJECT_NAME@"; 7 | static constexpr std::string_view project_version = "@PROJECT_VERSION@"; 8 | 9 | static constexpr std::int32_t project_version_major{@PROJECT_VERSION_MAJOR@}; 10 | static constexpr std::int32_t project_version_minor{@PROJECT_VERSION_MINOR@}; 11 | static constexpr std::int32_t project_version_patch{@PROJECT_VERSION_PATCH@}; 12 | -------------------------------------------------------------------------------- /2_CMake/05_ConfigureFile/configured/config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | static constexpr std::string_view project_name = "@PROJECT_NAME@"; 7 | static constexpr std::string_view project_version = "@PROJECT_VERSION@"; 8 | 9 | static constexpr std::int32_t project_version_major{@PROJECT_VERSION_MAJOR@}; 10 | static constexpr std::int32_t project_version_minor{@PROJECT_VERSION_MINOR@}; 11 | static constexpr std::int32_t project_version_patch{@PROJECT_VERSION_PATCH@}; 12 | -------------------------------------------------------------------------------- /2_CMake/06_BetterProject/configured/config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | static constexpr std::string_view project_name = "@PROJECT_NAME@"; 7 | static constexpr std::string_view project_version = "@PROJECT_VERSION@"; 8 | 9 | static constexpr std::int32_t project_version_major{@PROJECT_VERSION_MAJOR@}; 10 | static constexpr std::int32_t project_version_minor{@PROJECT_VERSION_MINOR@}; 11 | static constexpr std::int32_t project_version_patch{@PROJECT_VERSION_PATCH@}; 12 | -------------------------------------------------------------------------------- /2_CMake/07_ExternalGit/configured/config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | static constexpr std::string_view project_name = "@PROJECT_NAME@"; 7 | static constexpr std::string_view project_version = "@PROJECT_VERSION@"; 8 | 9 | static constexpr std::int32_t project_version_major{@PROJECT_VERSION_MAJOR@}; 10 | static constexpr std::int32_t project_version_minor{@PROJECT_VERSION_MINOR@}; 11 | static constexpr std::int32_t project_version_patch{@PROJECT_VERSION_PATCH@}; 12 | -------------------------------------------------------------------------------- /2_CMake/07_Submodules/configured/config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | static constexpr std::string_view project_name = "@PROJECT_NAME@"; 7 | static constexpr std::string_view project_version = "@PROJECT_VERSION@"; 8 | 9 | static constexpr std::int32_t project_version_major{@PROJECT_VERSION_MAJOR@}; 10 | static constexpr std::int32_t project_version_minor{@PROJECT_VERSION_MINOR@}; 11 | static constexpr std::int32_t project_version_patch{@PROJECT_VERSION_PATCH@}; 12 | -------------------------------------------------------------------------------- /2_CMake/08_FetchContent/configured/config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | static constexpr std::string_view project_name = "@PROJECT_NAME@"; 7 | static constexpr std::string_view project_version = "@PROJECT_VERSION@"; 8 | 9 | static constexpr std::int32_t project_version_major{@PROJECT_VERSION_MAJOR@}; 10 | static constexpr std::int32_t project_version_minor{@PROJECT_VERSION_MINOR@}; 11 | static constexpr std::int32_t project_version_patch{@PROJECT_VERSION_PATCH@}; 12 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/configured/config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | static constexpr std::string_view project_name = "@PROJECT_NAME@"; 7 | static constexpr std::string_view project_version = "@PROJECT_VERSION@"; 8 | 9 | static constexpr std::int32_t project_version_major{@PROJECT_VERSION_MAJOR@}; 10 | static constexpr std::int32_t project_version_minor{@PROJECT_VERSION_MINOR@}; 11 | static constexpr std::int32_t project_version_patch{@PROJECT_VERSION_PATCH@}; 12 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/ConanInstall.md: -------------------------------------------------------------------------------- 1 | # How to install the Conan Package Manager 2 | 3 | Official installation guide is [here](https://docs.conan.io/2/). 4 | 5 | The conan database is [here](https://conan.io/center/). 6 | 7 | ## Installation Steps 8 | 9 | 1. Install Python (3.7+) 10 | 2. Type ``pip install --user -U conan`` into the terminal 11 | 1. Unix: Append conan to the PATH by: ``source ~/.profile`` 12 | 3. Run the conan command: ``conan`` 13 | 4. conan profile detect --force 14 | 5. conan profile path default 15 | -------------------------------------------------------------------------------- /2_CMake/_Additional/PreCompiledLib_Find/CmakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(PreCompiledLibExample VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(EXECUTABLE_NAME MyExecutable) 6 | 7 | set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") 8 | find_package(LibExample REQUIRED) 9 | 10 | add_executable(${EXECUTABLE_NAME} main.cc) 11 | target_link_libraries(${EXECUTABLE_NAME} PUBLIC ${LibExample_LIBRARIES}) 12 | target_include_directories(${EXECUTABLE_NAME} PUBLIC ${LibExample_INCLUDE_DIRS}) 13 | -------------------------------------------------------------------------------- /2_CMake/04_VariablesOptions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(CppProjectTemplate VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | set(CMAKE_CXX_EXTENSIONS OFF) 8 | 9 | set(LIBRARY_NAME Library) 10 | set(EXECUTABLE_NAME Executable) 11 | 12 | option(COMPILE_EXECUTABLE "Whether to compile the executable" ON) 13 | 14 | add_subdirectory(src) 15 | if (COMPILE_EXECUTABLE) 16 | add_subdirectory(app) 17 | endif() 18 | -------------------------------------------------------------------------------- /2_CMake/06_SourcesAndHeaders/configured/config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | static constexpr std::string_view project_name = "@PROJECT_NAME@"; 7 | static constexpr std::string_view project_version = "@PROJECT_VERSION@"; 8 | 9 | static constexpr std::int32_t project_version_major{@PROJECT_VERSION_MAJOR@}; 10 | static constexpr std::int32_t project_version_minor{@PROJECT_VERSION_MINOR@}; 11 | static constexpr std::int32_t project_version_patch{@PROJECT_VERSION_PATCH@}; 12 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/cmake/LTO.cmake: -------------------------------------------------------------------------------- 1 | function(target_enable_lto TARGET ENABLE) 2 | if(NOT ${ENABLE}) 3 | return() 4 | endif() 5 | 6 | include(CheckIPOSupported) 7 | check_ipo_supported(RESULT result OUTPUT output) 8 | 9 | if(result) 10 | message(STATUS "IPO/LTO is supported!") 11 | set_property(TARGET ${TARGET} PROPERTY INTERPROCEDURAL_OPTIMIZATION ${ENABLE}) 12 | else() 13 | message(WARNING "IPO/LTO is not supported!") 14 | endif() 15 | endfunction(target_enable_lto) 16 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/cmake/LTO.cmake: -------------------------------------------------------------------------------- 1 | function(target_enable_lto TARGET ENABLE) 2 | if(NOT ${ENABLE}) 3 | return() 4 | endif() 5 | 6 | include(CheckIPOSupported) 7 | check_ipo_supported(RESULT result OUTPUT output) 8 | 9 | if(result) 10 | message(STATUS "IPO/LTO is supported!") 11 | set_property(TARGET ${TARGET} PROPERTY INTERPROCEDURAL_OPTIMIZATION ${ENABLE}) 12 | else() 13 | message(WARNING "IPO/LTO is not supported!") 14 | endif() 15 | endfunction(target_enable_lto) 16 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/cmake/LTO.cmake: -------------------------------------------------------------------------------- 1 | function(target_enable_lto TARGET ENABLE) 2 | if(NOT ${ENABLE}) 3 | return() 4 | endif() 5 | 6 | include(CheckIPOSupported) 7 | check_ipo_supported(RESULT result OUTPUT output) 8 | 9 | if(result) 10 | message(STATUS "IPO/LTO is supported!") 11 | set_property(TARGET ${TARGET} PROPERTY INTERPROCEDURAL_OPTIMIZATION ${ENABLE}) 12 | else() 13 | message(WARNING "IPO/LTO is not supported!") 14 | endif() 15 | endfunction(target_enable_lto) 16 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/cmake/LTO.cmake: -------------------------------------------------------------------------------- 1 | function(target_enable_lto TARGET ENABLE) 2 | if(NOT ${ENABLE}) 3 | return() 4 | endif() 5 | 6 | include(CheckIPOSupported) 7 | check_ipo_supported(RESULT result OUTPUT output) 8 | 9 | if(result) 10 | message(STATUS "IPO/LTO is supported!") 11 | set_property(TARGET ${TARGET} PROPERTY INTERPROCEDURAL_OPTIMIZATION ${ENABLE}) 12 | else() 13 | message(WARNING "IPO/LTO is not supported!") 14 | endif() 15 | endfunction(target_enable_lto) 16 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIBRARY_SOURCES 2 | "my_lib.cc") 3 | set(LIBRARY_HEADERS 4 | "my_lib.h") 5 | set(LIBRARY_INCLUDES 6 | "./" 7 | "${CMAKE_BINARY_DIR}/configured_files/include") 8 | 9 | add_library(${LIBRARY_NAME} STATIC 10 | ${LIBRARY_SOURCES} 11 | ${LIBRARY_HEADERS}) 12 | target_include_directories(${LIBRARY_NAME} PUBLIC 13 | ${LIBRARY_INCLUDES}) 14 | target_link_libraries(${LIBRARY_NAME} PUBLIC 15 | nlohmann_json::nlohmann_json 16 | fmt::fmt 17 | spdlog::spdlog 18 | cxxopts::cxxopts) 19 | -------------------------------------------------------------------------------- /2_CMake/08_FetchContent/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIBRARY_SOURCES 2 | "my_lib.cc") 3 | set(LIBRARY_HEADERS 4 | "my_lib.h") 5 | set(LIBRARY_INCLUDES 6 | "./" 7 | "${CMAKE_BINARY_DIR}/configured_files/include") 8 | 9 | add_library(${LIBRARY_NAME} STATIC 10 | ${LIBRARY_SOURCES} 11 | ${LIBRARY_HEADERS}) 12 | target_include_directories(${LIBRARY_NAME} PUBLIC 13 | ${LIBRARY_INCLUDES}) 14 | target_link_libraries(${LIBRARY_NAME} PUBLIC 15 | nlohmann_json::nlohmann_json 16 | fmt::fmt 17 | spdlog::spdlog 18 | cxxopts::cxxopts) 19 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CrossCompiler/Toolchains/x86-64-mingw-toolchain.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Windows) 2 | set(CMAKE_SYSTEM_PROCESSOR x86_64) 3 | 4 | set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) 5 | 6 | set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc-posix) 7 | set(CMAKE_C_FLAGS "-static") 8 | set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++-posix) 9 | set(CMAKE_CXX_FLAGS "-static") 10 | 11 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 15 | -------------------------------------------------------------------------------- /2_CMake/07_ExternalGit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(CppProjectTemplate VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | set(CMAKE_CXX_EXTENSIONS OFF) 8 | 9 | set(LIBRARY_NAME Library) 10 | set(EXECUTABLE_NAME Executable) 11 | 12 | set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") 13 | include(AddGitSubmodule) 14 | 15 | add_git_submodule(external/json) 16 | 17 | add_subdirectory(configured) 18 | add_subdirectory(external) 19 | add_subdirectory(src) 20 | add_subdirectory(app) 21 | -------------------------------------------------------------------------------- /2_CMake/07_Submodules/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(CppProjectTemplate VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | set(CMAKE_CXX_EXTENSIONS OFF) 8 | 9 | set(LIBRARY_NAME Library) 10 | set(EXECUTABLE_NAME Executable) 11 | 12 | set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") 13 | include(AddGitSubmodule) 14 | 15 | add_git_submodule(external/json) 16 | 17 | add_subdirectory(configured) 18 | add_subdirectory(external) 19 | add_subdirectory(src) 20 | add_subdirectory(app) 21 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(EXE_SOURCES 2 | "main.cc") 3 | set(EXE_INCLUDES 4 | "./") 5 | 6 | add_executable(${EXECUTABLE_NAME} ${EXE_SOURCES}) 7 | target_include_directories(${EXECUTABLE_NAME} PUBLIC 8 | ${EXE_INCLUDES}) 9 | 10 | target_link_libraries( 11 | ${EXECUTABLE_NAME} 12 | PUBLIC ${LIBRARY_NAME} 13 | nlohmann_json::nlohmann_json 14 | fmt::fmt 15 | spdlog::spdlog 16 | cxxopts::cxxopts) 17 | 18 | if (ENABLE_WARNINGS) 19 | target_set_warnings( 20 | ${EXECUTABLE_NAME} 21 | ON 22 | OFF 23 | ) 24 | endif() 25 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(EXE_SOURCES 2 | "main.cc") 3 | set(EXE_INCLUDES 4 | "./") 5 | 6 | add_executable(${EXECUTABLE_NAME} ${EXE_SOURCES}) 7 | target_include_directories(${EXECUTABLE_NAME} PUBLIC 8 | ${EXE_INCLUDES}) 9 | 10 | target_link_libraries( 11 | ${EXECUTABLE_NAME} 12 | PUBLIC ${LIBRARY_NAME} 13 | nlohmann_json::nlohmann_json 14 | fmt::fmt 15 | spdlog::spdlog 16 | cxxopts::cxxopts) 17 | 18 | 19 | if (ENABLE_WARNINGS) 20 | target_set_warnings( 21 | ${EXECUTABLE_NAME} 22 | ON 23 | OFF 24 | ) 25 | endif() 26 | -------------------------------------------------------------------------------- /2_CMake/_Additional/PreCompiledLib_Find/cmake/FindLibExample.cmake: -------------------------------------------------------------------------------- 1 | # FindYourLibraryName.cmake 2 | set(LibExample_ROOT_DIR ${PROJECT_SOURCE_DIR}/external/) 3 | set(LibExample_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/external/inc/) 4 | 5 | if(MSVC) 6 | set(LibExample_LIBRARIES ${PROJECT_SOURCE_DIR}/external/lib/LibExample.lib) 7 | else() 8 | set(LibExample_LIBRARIES ${PROJECT_SOURCE_DIR}/external/lib/libLibExample.a) 9 | endif() 10 | 11 | if(EXISTS ${LibExample_LIBRARIES}) 12 | set(LibExample_FOUND TRUE) 13 | else() 14 | set(LibExample_FOUND FALSE) 15 | message("LibExample Lib not found!") 16 | endif() 17 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include "my_lib.h" 7 | 8 | /** 9 | * @brief Prints out hello world and tests the JSON Lib. 10 | * 11 | */ 12 | void print_hello_world() 13 | { 14 | std::cout << "Hello World!\n"; 15 | 16 | std::cout << "JSON Lib Version:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 17 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 18 | } 19 | 20 | std::uint32_t factorial(std::uint32_t number) 21 | { 22 | return number <= 1 ? 1 : factorial(number - 1) * number; 23 | } 24 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include "my_lib.h" 7 | 8 | /** 9 | * @brief Prints out hello world and tests the JSON Lib. 10 | * 11 | */ 12 | void print_hello_world() 13 | { 14 | std::cout << "Hello World!\n"; 15 | 16 | std::cout << "JSON Lib Version:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 17 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 18 | } 19 | 20 | std::uint32_t factorial(std::uint32_t number) 21 | { 22 | return number <= 1 ? 1 : factorial(number - 1) * number; 23 | } 24 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include "my_lib.h" 7 | 8 | /** 9 | * @brief Prints out hello world and tests the JSON Lib. 10 | * 11 | */ 12 | void print_hello_world() 13 | { 14 | std::cout << "Hello World!\n"; 15 | 16 | std::cout << "JSON Lib Version:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 17 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 18 | } 19 | 20 | std::uint32_t factorial(std::uint32_t number) 21 | { 22 | return number <= 1 ? 1 : factorial(number - 1) * number; 23 | } 24 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include "my_lib.h" 7 | 8 | /** 9 | * @brief Prints out hello world and tests the JSON Lib. 10 | * 11 | */ 12 | void print_hello_world() 13 | { 14 | std::cout << "Hello World!\n"; 15 | 16 | std::cout << "JSON Lib Version:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 17 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 18 | } 19 | 20 | std::uint32_t factorial(std::uint32_t number) 21 | { 22 | return number <= 1 ? 1 : factorial(number - 1) * number; 23 | } 24 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include "my_lib.h" 7 | 8 | /** 9 | * @brief Prints out hello world and tests the JSON Lib. 10 | * 11 | */ 12 | void print_hello_world() 13 | { 14 | std::cout << "Hello World!\n"; 15 | 16 | std::cout << "JSON Lib Version:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 17 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 18 | } 19 | 20 | std::uint32_t factorial(std::uint32_t number) 21 | { 22 | return number <= 1 ? 1 : factorial(number - 1) * number; 23 | } 24 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include "my_lib.h" 7 | 8 | /** 9 | * @brief Prints out hello world and tests the JSON Lib. 10 | * 11 | */ 12 | void print_hello_world() 13 | { 14 | std::cout << "Hello World!\n"; 15 | 16 | std::cout << "JSON Lib Version:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 17 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 18 | } 19 | 20 | std::uint32_t factorial(std::uint32_t number) 21 | { 22 | return number <= 1 ? 1 : factorial(number - 1) * number; 23 | } 24 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/src/my_lib/my_lib.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include "my_lib.h" 7 | 8 | /** 9 | * @brief Prints out hello world and tests the JSON Lib. 10 | * 11 | */ 12 | void print_hello_world() 13 | { 14 | std::cout << "Hello World!\n"; 15 | 16 | std::cout << "JSON Lib Version:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 17 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 18 | } 19 | 20 | std::uint32_t factorial(std::uint32_t number) 21 | { 22 | return number <= 1 ? 1 : factorial(number - 1) * number; 23 | } 24 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/conanfile.py: -------------------------------------------------------------------------------- 1 | from conan import ConanFile 2 | from conan.tools.cmake import CMakeToolchain 3 | 4 | 5 | class CompressorRecipe(ConanFile): 6 | settings = "os", "compiler", "build_type", "arch" 7 | generators = "CMakeDeps" 8 | 9 | def requirements(self): 10 | self.requires("nlohmann_json/3.11.3") 11 | self.requires("fmt/10.2.1") 12 | self.requires("spdlog/1.13.0") 13 | self.requires("catch2/3.5.3") 14 | self.requires("cxxopts/3.1.1") 15 | 16 | def generate(self): 17 | tc = CMakeToolchain(self) 18 | tc.user_presets_path = False 19 | tc.generate() 20 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/conanfile.py: -------------------------------------------------------------------------------- 1 | from conan import ConanFile 2 | from conan.tools.cmake import CMakeToolchain 3 | 4 | 5 | class CompressorRecipe(ConanFile): 6 | settings = "os", "compiler", "build_type", "arch" 7 | generators = "CMakeDeps" 8 | 9 | def requirements(self): 10 | self.requires("nlohmann_json/3.11.3") 11 | self.requires("fmt/10.2.1") 12 | self.requires("spdlog/1.13.0") 13 | self.requires("catch2/3.5.3") 14 | self.requires("cxxopts/3.1.1") 15 | 16 | def generate(self): 17 | tc = CMakeToolchain(self) 18 | tc.user_presets_path = False 19 | tc.generate() 20 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIBRARY_SOURCES 2 | "my_lib.cc") 3 | set(LIBRARY_HEADERS 4 | "my_lib.h") 5 | set(LIBRARY_INCLUDES 6 | "./" 7 | "${CMAKE_BINARY_DIR}/configured_files/include") 8 | 9 | add_library(${LIBRARY_NAME} STATIC 10 | ${LIBRARY_SOURCES} 11 | ${LIBRARY_HEADERS}) 12 | target_include_directories(${LIBRARY_NAME} PUBLIC 13 | ${LIBRARY_INCLUDES}) 14 | target_link_libraries(${LIBRARY_NAME} PUBLIC 15 | nlohmann_json::nlohmann_json 16 | fmt::fmt 17 | spdlog::spdlog 18 | cxxopts::cxxopts) 19 | target_include_directories(${LIBRARY_NAME} PUBLIC 20 | ${LIBRARY_INCLUDES}) 21 | -------------------------------------------------------------------------------- /.clang-tidy: -------------------------------------------------------------------------------- 1 | --- 2 | Checks: 'clang-analyzer-*,bugprone-*,readability-*,cppcoreguidelines-*,-readability-avoid-const-params-in-decls,-cppcoreguidelines-avoid-non-const-global-variables,-bugprone-easily-swappable-parameters,-altera-*,-readability-uppercase-literal-suffix,-bugprone-branch-clone,-cppcoreguidelines-pro-*,-readability-function-cognitive-complexity,-cppcoreguidelines-avoid-magic-numbers,-clang-analyzer-security.insecureAPI.*' 3 | WarningsAsErrors: '' 4 | HeaderFilterRegex: '' 5 | CheckOptions: 6 | - key: readability-magic-numbers.IgnoredFloatingPointValues 7 | value: '0.0;1.0;100.0;' 8 | - key: readability-magic-numbers.IgnoredIntegerValues 9 | value: '0;1;2;3;4;5;6;7;8;9;' 10 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(EXE_SOURCES 2 | "main.cc") 3 | set(EXE_INCLUDES 4 | "./") 5 | 6 | add_executable(${EXECUTABLE_NAME} ${EXE_SOURCES}) 7 | target_include_directories(${EXECUTABLE_NAME} PUBLIC 8 | ${EXE_INCLUDES}) 9 | 10 | target_link_libraries( 11 | ${EXECUTABLE_NAME} 12 | PUBLIC ${LIBRARY_NAME} 13 | nlohmann_json::nlohmann_json 14 | fmt::fmt 15 | spdlog::spdlog 16 | cxxopts::cxxopts) 17 | 18 | if (ENABLE_WARNINGS) 19 | target_set_warnings( 20 | ${EXECUTABLE_NAME} 21 | ON 22 | OFF 23 | ) 24 | endif() 25 | 26 | if (ENABLE_LTO) 27 | target_enable_lto( 28 | ${EXECUTABLE_NAME} 29 | ${ENABLE_LTO} 30 | ) 31 | endif() 32 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/cmake/AddGitSubmodule.cmake: -------------------------------------------------------------------------------- 1 | function(add_git_submodule relative_dir) 2 | find_package(Git REQUIRED) 3 | 4 | set(FULL_DIR ${CMAKE_SOURCE_DIR}/${relative_dir}) 5 | 6 | if (NOT EXISTS ${FULL_DIR}/CMakeLists.txt) 7 | execute_process(COMMAND ${GIT_EXECUTABLE} 8 | submodule update --init --recursive -- ${relative_dir} 9 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) 10 | endif() 11 | 12 | if (EXISTS ${FULL_DIR}/CMakeLists.txt) 13 | message("Submodule is CMake Project: ${FULL_DIR}/CMakeLists.txt") 14 | add_subdirectory(${FULL_DIR}) 15 | else() 16 | message("Submodule is NO CMake Project: ${FULL_DIR}") 17 | endif() 18 | endfunction(add_git_submodule) 19 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(EXE_SOURCES 2 | "main.cc") 3 | set(EXE_INCLUDES 4 | "./") 5 | 6 | add_executable(${EXECUTABLE_NAME} ${EXE_SOURCES}) 7 | target_include_directories(${EXECUTABLE_NAME} PUBLIC 8 | ${EXE_INCLUDES}) 9 | 10 | target_link_libraries( 11 | ${EXECUTABLE_NAME} 12 | PUBLIC ${LIBRARY_NAME} 13 | nlohmann_json::nlohmann_json 14 | fmt::fmt 15 | spdlog::spdlog 16 | cxxopts::cxxopts) 17 | 18 | if (ENABLE_WARNINGS) 19 | target_set_warnings( 20 | ${EXECUTABLE_NAME} 21 | ON 22 | OFF 23 | ) 24 | endif() 25 | 26 | if (ENABLE_LTO) 27 | target_enable_lto( 28 | ${EXECUTABLE_NAME} 29 | ${ENABLE_LTO} 30 | ) 31 | endif() 32 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/cmake/AddGitSubmodule.cmake: -------------------------------------------------------------------------------- 1 | function(add_git_submodule relative_dir) 2 | find_package(Git REQUIRED) 3 | 4 | set(FULL_DIR ${CMAKE_SOURCE_DIR}/${relative_dir}) 5 | 6 | if (NOT EXISTS ${FULL_DIR}/CMakeLists.txt) 7 | execute_process(COMMAND ${GIT_EXECUTABLE} 8 | submodule update --init --recursive -- ${relative_dir} 9 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) 10 | endif() 11 | 12 | if (EXISTS ${FULL_DIR}/CMakeLists.txt) 13 | message("Submodule is CMake Project: ${FULL_DIR}/CMakeLists.txt") 14 | add_subdirectory(${FULL_DIR}) 15 | else() 16 | message("Submodule is NO CMake Project: ${FULL_DIR}") 17 | endif() 18 | endfunction(add_git_submodule) 19 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/cmake/AddGitSubmodule.cmake: -------------------------------------------------------------------------------- 1 | function(add_git_submodule relative_dir) 2 | find_package(Git REQUIRED) 3 | 4 | set(FULL_DIR ${CMAKE_SOURCE_DIR}/${relative_dir}) 5 | 6 | if (NOT EXISTS ${FULL_DIR}/CMakeLists.txt) 7 | execute_process(COMMAND ${GIT_EXECUTABLE} 8 | submodule update --init --recursive -- ${relative_dir} 9 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) 10 | endif() 11 | 12 | if (EXISTS ${FULL_DIR}/CMakeLists.txt) 13 | message("Submodule is CMake Project: ${FULL_DIR}/CMakeLists.txt") 14 | add_subdirectory(${FULL_DIR}) 15 | else() 16 | message("Submodule is NO CMake Project: ${FULL_DIR}") 17 | endif() 18 | endfunction(add_git_submodule) 19 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/cmake/AddGitSubmodule.cmake: -------------------------------------------------------------------------------- 1 | function(add_git_submodule relative_dir) 2 | find_package(Git REQUIRED) 3 | 4 | set(FULL_DIR ${CMAKE_SOURCE_DIR}/${relative_dir}) 5 | 6 | if (NOT EXISTS ${FULL_DIR}/CMakeLists.txt) 7 | execute_process(COMMAND ${GIT_EXECUTABLE} 8 | submodule update --init --recursive -- ${relative_dir} 9 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) 10 | endif() 11 | 12 | if (EXISTS ${FULL_DIR}/CMakeLists.txt) 13 | message("Submodule is CMake Project: ${FULL_DIR}/CMakeLists.txt") 14 | add_subdirectory(${FULL_DIR}) 15 | else() 16 | message("Submodule is NO CMake Project: ${FULL_DIR}") 17 | endif() 18 | endfunction(add_git_submodule) 19 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/cmake/AddGitSubmodule.cmake: -------------------------------------------------------------------------------- 1 | function(add_git_submodule relative_dir) 2 | find_package(Git REQUIRED) 3 | 4 | set(FULL_DIR ${CMAKE_SOURCE_DIR}/${relative_dir}) 5 | 6 | if (NOT EXISTS ${FULL_DIR}/CMakeLists.txt) 7 | execute_process(COMMAND ${GIT_EXECUTABLE} 8 | submodule update --init --recursive -- ${relative_dir} 9 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) 10 | endif() 11 | 12 | if (EXISTS ${FULL_DIR}/CMakeLists.txt) 13 | message("Submodule is CMake Project: ${FULL_DIR}/CMakeLists.txt") 14 | add_subdirectory(${FULL_DIR}) 15 | else() 16 | message("Submodule is NO CMake Project: ${FULL_DIR}") 17 | endif() 18 | endfunction(add_git_submodule) 19 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(EXE_SOURCES 2 | "main.cc") 3 | set(EXE_INCLUDES 4 | "./") 5 | 6 | add_executable(${EXECUTABLE_NAME} ${EXE_SOURCES}) 7 | target_include_directories(${EXECUTABLE_NAME} PUBLIC 8 | ${EXE_INCLUDES}) 9 | 10 | target_link_libraries( 11 | ${EXECUTABLE_NAME} 12 | PUBLIC ${LIBRARY_NAME} 13 | nlohmann_json::nlohmann_json 14 | fmt::fmt 15 | spdlog::spdlog 16 | cxxopts::cxxopts) 17 | 18 | if (ENABLE_WARNINGS) 19 | target_set_warnings( 20 | ${EXECUTABLE_NAME} 21 | ON 22 | OFF 23 | ) 24 | endif() 25 | 26 | if (ENABLE_LTO) 27 | target_enable_lto( 28 | ${EXECUTABLE_NAME} 29 | ${ENABLE_LTO} 30 | ) 31 | endif() 32 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/cmake/AddGitSubmodule.cmake: -------------------------------------------------------------------------------- 1 | function(add_git_submodule relative_dir) 2 | find_package(Git REQUIRED) 3 | 4 | set(FULL_DIR ${CMAKE_SOURCE_DIR}/${relative_dir}) 5 | 6 | if (NOT EXISTS ${FULL_DIR}/CMakeLists.txt) 7 | execute_process(COMMAND ${GIT_EXECUTABLE} 8 | submodule update --init --recursive -- ${relative_dir} 9 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) 10 | endif() 11 | 12 | if (EXISTS ${FULL_DIR}/CMakeLists.txt) 13 | message("Submodule is CMake Project: ${FULL_DIR}/CMakeLists.txt") 14 | add_subdirectory(${FULL_DIR}) 15 | else() 16 | message("Submodule is NO CMake Project: ${FULL_DIR}") 17 | endif() 18 | endfunction(add_git_submodule) 19 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(EXE_SOURCES 2 | "main.cc") 3 | set(EXE_INCLUDES 4 | "./") 5 | 6 | add_executable(${EXECUTABLE_NAME} ${EXE_SOURCES}) 7 | target_include_directories(${EXECUTABLE_NAME} PUBLIC 8 | ${EXE_INCLUDES}) 9 | 10 | target_link_libraries( 11 | ${EXECUTABLE_NAME} 12 | PUBLIC ${LIBRARY_NAME} 13 | nlohmann_json::nlohmann_json 14 | fmt::fmt 15 | spdlog::spdlog 16 | cxxopts::cxxopts) 17 | 18 | if (ENABLE_WARNINGS) 19 | target_set_warnings( 20 | ${EXECUTABLE_NAME} 21 | ON 22 | OFF 23 | ) 24 | endif() 25 | 26 | if (ENABLE_LTO) 27 | target_enable_lto( 28 | ${EXECUTABLE_NAME} 29 | ${ENABLE_LTO} 30 | ) 31 | endif() 32 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/cmake/AddGitSubmodule.cmake: -------------------------------------------------------------------------------- 1 | function(add_git_submodule relative_dir) 2 | find_package(Git REQUIRED) 3 | 4 | set(FULL_DIR ${CMAKE_SOURCE_DIR}/${relative_dir}) 5 | 6 | if (NOT EXISTS ${FULL_DIR}/CMakeLists.txt) 7 | execute_process(COMMAND ${GIT_EXECUTABLE} 8 | submodule update --init --recursive -- ${relative_dir} 9 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) 10 | endif() 11 | 12 | if (EXISTS ${FULL_DIR}/CMakeLists.txt) 13 | message("Submodule is CMake Project: ${FULL_DIR}/CMakeLists.txt") 14 | add_subdirectory(${FULL_DIR}) 15 | else() 16 | message("Submodule is NO CMake Project: ${FULL_DIR}") 17 | endif() 18 | endfunction(add_git_submodule) 19 | -------------------------------------------------------------------------------- /2_CMake/07_ExternalGit/cmake/AddGitSubmodule.cmake: -------------------------------------------------------------------------------- 1 | function(add_git_submodule relative_dir) 2 | find_package(Git REQUIRED) 3 | 4 | set(FULL_DIR ${CMAKE_SOURCE_DIR}/${relative_dir}) 5 | 6 | if (NOT EXISTS ${FULL_DIR}/CMakeLists.txt) 7 | execute_process(COMMAND ${GIT_EXECUTABLE} 8 | submodule update --init --recursive -- ${relative_dir} 9 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) 10 | endif() 11 | 12 | if (EXISTS ${FULL_DIR}/CMakeLists.txt) 13 | message("Submodule is CMake Project: ${FULL_DIR}/CMakeLists.txt") 14 | add_subdirectory(${FULL_DIR}) 15 | else() 16 | message("Submodule is NO CMake Project: ${FULL_DIR}") 17 | endif() 18 | endfunction(add_git_submodule) 19 | -------------------------------------------------------------------------------- /2_CMake/07_Submodules/cmake/AddGitSubmodule.cmake: -------------------------------------------------------------------------------- 1 | function(add_git_submodule relative_dir) 2 | find_package(Git REQUIRED) 3 | 4 | set(FULL_DIR ${CMAKE_SOURCE_DIR}/${relative_dir}) 5 | 6 | if (NOT EXISTS ${FULL_DIR}/CMakeLists.txt) 7 | execute_process(COMMAND ${GIT_EXECUTABLE} 8 | submodule update --init --recursive -- ${relative_dir} 9 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) 10 | endif() 11 | 12 | if (EXISTS ${FULL_DIR}/CMakeLists.txt) 13 | message("Submodule is CMake Project: ${FULL_DIR}/CMakeLists.txt") 14 | add_subdirectory(${FULL_DIR}) 15 | else() 16 | message("Submodule is NO CMake Project: ${FULL_DIR}") 17 | endif() 18 | endfunction(add_git_submodule) 19 | -------------------------------------------------------------------------------- /2_CMake/08_FetchContent/cmake/AddGitSubmodule.cmake: -------------------------------------------------------------------------------- 1 | function(add_git_submodule relative_dir) 2 | find_package(Git REQUIRED) 3 | 4 | set(FULL_DIR ${CMAKE_SOURCE_DIR}/${relative_dir}) 5 | 6 | if (NOT EXISTS ${FULL_DIR}/CMakeLists.txt) 7 | execute_process(COMMAND ${GIT_EXECUTABLE} 8 | submodule update --init --recursive -- ${relative_dir} 9 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) 10 | endif() 11 | 12 | if (EXISTS ${FULL_DIR}/CMakeLists.txt) 13 | message("Submodule is CMake Project: ${FULL_DIR}/CMakeLists.txt") 14 | add_subdirectory(${FULL_DIR}) 15 | else() 16 | message("Submodule is NO CMake Project: ${FULL_DIR}") 17 | endif() 18 | endfunction(add_git_submodule) 19 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/cmake/AddGitSubmodule.cmake: -------------------------------------------------------------------------------- 1 | function(add_git_submodule relative_dir) 2 | find_package(Git REQUIRED) 3 | 4 | set(FULL_DIR ${CMAKE_SOURCE_DIR}/${relative_dir}) 5 | 6 | if (NOT EXISTS ${FULL_DIR}/CMakeLists.txt) 7 | execute_process(COMMAND ${GIT_EXECUTABLE} 8 | submodule update --init --recursive -- ${relative_dir} 9 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) 10 | endif() 11 | 12 | if (EXISTS ${FULL_DIR}/CMakeLists.txt) 13 | message("Submodule is CMake Project: ${FULL_DIR}/CMakeLists.txt") 14 | add_subdirectory(${FULL_DIR}) 15 | else() 16 | message("Submodule is NO CMake Project: ${FULL_DIR}") 17 | endif() 18 | endfunction(add_git_submodule) 19 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CustomCommand/cmake/CustomPythonTarget.cmake: -------------------------------------------------------------------------------- 1 | # Note: 2 | # configure_file: Copy a file to another location and modify its contents. 3 | # add_custom_command: Creates a new file 4 | 5 | set(CUSTOM_TARGET_NAME "CustomPythonTarget") 6 | if(NOT TARGET ${CUSTOM_TARGET_NAME}) 7 | add_custom_target(${CUSTOM_TARGET_NAME} 8 | DEPENDS "${PROJECT_BINARY_DIR}/Stats.txt") 9 | 10 | add_custom_command( 11 | OUTPUT "${PROJECT_BINARY_DIR}/Stats.txt" 12 | COMMAND python CustomPythonTarget.py --input_dir 13 | ${PROJECT_SOURCE_DIR}/src --output_dir ${PROJECT_BINARY_DIR} 14 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/scripts 15 | DEPENDS ${PROJECT_SOURCE_DIR}/src/main.cc) 16 | endif() 17 | -------------------------------------------------------------------------------- /2_CMake/_Additional/PreCompiledLib_Self/CmakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project( 4 | PreCompiledLibExample 5 | VERSION 1.0.0 6 | LANGUAGES C CXX) 7 | 8 | set(EXECUTABLE_NAME MyExecutable) 9 | 10 | add_executable(${EXECUTABLE_NAME} main.cc) 11 | 12 | target_include_directories(${EXECUTABLE_NAME} 13 | PUBLIC ${CMAKE_SOURCE_DIR}/external/inc) 14 | 15 | # .lib/.a (static) 16 | # .dll/.so (dynamic) 17 | if(MSVC) 18 | target_link_libraries( 19 | ${EXECUTABLE_NAME} 20 | PUBLIC ${CMAKE_SOURCE_DIR}/external/lib/LibExample.lib) 21 | else() 22 | target_link_libraries( 23 | ${EXECUTABLE_NAME} 24 | PUBLIC ${CMAKE_SOURCE_DIR}/external/lib/libLibExample.a) 25 | endif() 26 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Sources and Headers 2 | set(LIBRARY_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/my_lib.cc") 3 | set(LIBRARY_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/my_lib.h") 4 | set(LIBRARY_INCLUDES "./" "${CMAKE_BINARY_DIR}/configured_files/include") 5 | 6 | # MyLib Library 7 | add_library(${LIBRARY_NAME} STATIC ${LIBRARY_SOURCES} ${LIBRARY_HEADERS}) 8 | target_include_directories(${LIBRARY_NAME} PUBLIC ${LIBRARY_INCLUDES}) 9 | target_link_libraries( 10 | ${LIBRARY_NAME} 11 | PRIVATE nlohmann_json::nlohmann_json 12 | fmt::fmt 13 | spdlog::spdlog 14 | cxxopts::cxxopts) 15 | 16 | if (ENABLE_WARNINGS) 17 | target_set_warnings( 18 | ${LIBRARY_NAME} 19 | ON 20 | OFF 21 | ) 22 | endif() 23 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIBRARY_SOURCES 2 | "my_lib.cc") 3 | set(LIBRARY_HEADERS 4 | "my_lib.h") 5 | set(LIBRARY_INCLUDES 6 | "./" 7 | "${CMAKE_BINARY_DIR}/configured_files/include") 8 | 9 | add_library(${LIBRARY_NAME} STATIC 10 | ${LIBRARY_SOURCES} 11 | ${LIBRARY_HEADERS}) 12 | target_include_directories(${LIBRARY_NAME} PUBLIC 13 | ${LIBRARY_INCLUDES}) 14 | target_link_libraries(${LIBRARY_NAME} PUBLIC 15 | nlohmann_json::nlohmann_json 16 | fmt::fmt 17 | spdlog::spdlog 18 | cxxopts::cxxopts) 19 | target_include_directories(${LIBRARY_NAME} PUBLIC 20 | ${LIBRARY_INCLUDES}) 21 | 22 | if (ENABLE_WARNINGS) 23 | target_set_warnings( 24 | ${LIBRARY_NAME} 25 | ON 26 | OFF 27 | ) 28 | endif() 29 | -------------------------------------------------------------------------------- /2_CMake/_Additional/GeneratorExpression/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project( 4 | LibExample 5 | VERSION 1.0.0 6 | LANGUAGES C CXX) 7 | 8 | set(LIBRARY_NAME LibExample) 9 | 10 | add_library(${LIBRARY_NAME} STATIC src/lib.cc) 11 | target_include_directories(${LIBRARY_NAME} PUBLIC inc/) 12 | 13 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") 14 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") 15 | add_compile_definitions("/Wall /Werror") 16 | else() 17 | add_compile_definitions("/Wall") 18 | endif() 19 | endif() 20 | 21 | if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 22 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") 23 | add_compile_definitions("/W4 /Wx") 24 | else() 25 | add_compile_definitions("/W4") 26 | endif() 27 | endif() 28 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cpptemplateproject", 3 | "version-string": "1.0.0", 4 | "dependencies": [ 5 | { 6 | "name": "cxxopts", 7 | "version>=": "3.1.1" 8 | }, 9 | { 10 | "name": "fmt", 11 | "version>=": "9.1.0" 12 | }, 13 | { 14 | "name": "nlohmann-json", 15 | "version>=": "3.11.2" 16 | }, 17 | { 18 | "name": "spdlog", 19 | "version>=": "1.11.0" 20 | }, 21 | { 22 | "name": "catch2", 23 | "version>=": "3.5.2" 24 | } 25 | ], 26 | "overrides": [ 27 | { 28 | "name": "catch2", 29 | "version": "3.5.2" 30 | } 31 | ], 32 | "builtin-baseline": "40619a55c3e76dc4005c8d1b7395071471bb8b96" 33 | } 34 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": [ 3 | { 4 | "type": "cppbuild", 5 | "label": "C/C++: g++.exe build active file", 6 | "command": "C:\\cygwin64\\bin\\g++.exe", 7 | "args": [ 8 | "-fdiagnostics-color=always", 9 | "-g", 10 | "${file}", 11 | "-o", 12 | "${fileDirname}\\${fileBasenameNoExtension}.exe" 13 | ], 14 | "options": { 15 | "cwd": "${fileDirname}" 16 | }, 17 | "problemMatcher": [ 18 | "$gcc" 19 | ], 20 | "group": { 21 | "kind": "build", 22 | "isDefault": true 23 | }, 24 | "detail": "Task generated by Debugger." 25 | } 26 | ], 27 | "version": "2.0.0" 28 | } 29 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "config.hpp" 9 | #include "my_lib.h" 10 | 11 | int main() 12 | { 13 | std::cout << project_name << '\n'; 14 | std::cout << project_version << '\n'; 15 | 16 | std::cout << "JSON:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 17 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 18 | 19 | std::cout << "FMT:" << FMT_VERSION << "\n"; 20 | 21 | std::cout << "CXXOPTS:" << CXXOPTS__VERSION_MAJOR << "." << CXXOPTS__VERSION_MINOR << "." << CXXOPTS__VERSION_PATCH 22 | << "\n"; 23 | 24 | std::cout << "SPDLOG:" << SPDLOG_VER_MAJOR << "." << SPDLOG_VER_MINOR << "." << SPDLOG_VER_PATCH << "\n"; 25 | 26 | print_hello_world(); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "config.hpp" 9 | #include "my_lib.h" 10 | 11 | int main() 12 | { 13 | std::cout << project_name << '\n'; 14 | std::cout << project_version << '\n'; 15 | 16 | std::cout << "JSON:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 17 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 18 | 19 | std::cout << "FMT:" << FMT_VERSION << "\n"; 20 | 21 | std::cout << "CXXOPTS:" << CXXOPTS__VERSION_MAJOR << "." << CXXOPTS__VERSION_MINOR << "." << CXXOPTS__VERSION_PATCH 22 | << "\n"; 23 | 24 | std::cout << "SPDLOG:" << SPDLOG_VER_MAJOR << "." << SPDLOG_VER_MINOR << "." << SPDLOG_VER_PATCH << "\n"; 25 | 26 | print_hello_world(); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "config.hpp" 9 | #include "my_lib.h" 10 | 11 | int main() 12 | { 13 | std::cout << project_name << '\n'; 14 | std::cout << project_version << '\n'; 15 | 16 | std::cout << "JSON:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 17 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 18 | 19 | std::cout << "FMT:" << FMT_VERSION << "\n"; 20 | 21 | std::cout << "CXXOPTS:" << CXXOPTS__VERSION_MAJOR << "." << CXXOPTS__VERSION_MINOR << "." << CXXOPTS__VERSION_PATCH 22 | << "\n"; 23 | 24 | std::cout << "SPDLOG:" << SPDLOG_VER_MAJOR << "." << SPDLOG_VER_MINOR << "." << SPDLOG_VER_PATCH << "\n"; 25 | 26 | print_hello_world(); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "config.hpp" 9 | #include "my_lib.h" 10 | 11 | int main() 12 | { 13 | std::cout << project_name << '\n'; 14 | std::cout << project_version << '\n'; 15 | 16 | std::cout << "JSON:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 17 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 18 | 19 | std::cout << "FMT:" << FMT_VERSION << "\n"; 20 | 21 | std::cout << "CXXOPTS:" << CXXOPTS__VERSION_MAJOR << "." << CXXOPTS__VERSION_MINOR << "." << CXXOPTS__VERSION_PATCH 22 | << "\n"; 23 | 24 | std::cout << "SPDLOG:" << SPDLOG_VER_MAJOR << "." << SPDLOG_VER_MINOR << "." << SPDLOG_VER_PATCH << "\n"; 25 | 26 | print_hello_world(); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "config.hpp" 9 | #include "my_lib.h" 10 | 11 | int main() 12 | { 13 | std::cout << project_name << '\n'; 14 | std::cout << project_version << '\n'; 15 | 16 | std::cout << "JSON:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 17 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 18 | 19 | std::cout << "FMT:" << FMT_VERSION << "\n"; 20 | 21 | std::cout << "CXXOPTS:" << CXXOPTS__VERSION_MAJOR << "." << CXXOPTS__VERSION_MINOR << "." << CXXOPTS__VERSION_PATCH 22 | << "\n"; 23 | 24 | std::cout << "SPDLOG:" << SPDLOG_VER_MAJOR << "." << SPDLOG_VER_MINOR << "." << SPDLOG_VER_PATCH << "\n"; 25 | 26 | print_hello_world(); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "config.hpp" 9 | #include "my_lib.h" 10 | 11 | int main() 12 | { 13 | std::cout << project_name << '\n'; 14 | std::cout << project_version << '\n'; 15 | 16 | std::cout << "JSON:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 17 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 18 | 19 | std::cout << "FMT:" << FMT_VERSION << "\n"; 20 | 21 | std::cout << "CXXOPTS:" << CXXOPTS__VERSION_MAJOR << "." << CXXOPTS__VERSION_MINOR << "." << CXXOPTS__VERSION_PATCH 22 | << "\n"; 23 | 24 | std::cout << "SPDLOG:" << SPDLOG_VER_MAJOR << "." << SPDLOG_VER_MINOR << "." << SPDLOG_VER_PATCH << "\n"; 25 | 26 | print_hello_world(); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /2_CMake/08_FetchContent/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "config.hpp" 9 | #include "my_lib.h" 10 | 11 | int main() 12 | { 13 | std::cout << project_name << '\n'; 14 | std::cout << project_version << '\n'; 15 | 16 | std::cout << "JSON:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 17 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 18 | 19 | std::cout << "FMT:" << FMT_VERSION << "\n"; 20 | 21 | std::cout << "CXXOPTS:" << CXXOPTS__VERSION_MAJOR << "." << CXXOPTS__VERSION_MINOR << "." << CXXOPTS__VERSION_PATCH 22 | << "\n"; 23 | 24 | std::cout << "SPDLOG:" << SPDLOG_VER_MAJOR << "." << SPDLOG_VER_MINOR << "." << SPDLOG_VER_PATCH << "\n"; 25 | 26 | print_hello_world(); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIBRARY_SOURCES 2 | "my_lib.cc") 3 | set(LIBRARY_HEADERS 4 | "my_lib.h") 5 | set(LIBRARY_INCLUDES 6 | "./" 7 | "${CMAKE_BINARY_DIR}/configured_files/include") 8 | 9 | add_library(${LIBRARY_NAME} STATIC 10 | ${LIBRARY_SOURCES} 11 | ${LIBRARY_HEADERS}) 12 | target_include_directories(${LIBRARY_NAME} PUBLIC 13 | ${LIBRARY_INCLUDES}) 14 | target_link_libraries(${LIBRARY_NAME} PUBLIC 15 | nlohmann_json::nlohmann_json 16 | fmt::fmt 17 | spdlog::spdlog 18 | cxxopts::cxxopts) 19 | target_include_directories(${LIBRARY_NAME} PUBLIC 20 | ${LIBRARY_INCLUDES}) 21 | 22 | if (ENABLE_WARNINGS) 23 | target_set_warnings( 24 | ${LIBRARY_NAME} 25 | ON 26 | OFF 27 | ) 28 | endif() 29 | 30 | if (ENABLE_LTO) 31 | target_enable_lto( 32 | ${LIBRARY_NAME} 33 | ${ENABLE_LTO} 34 | ) 35 | endif() 36 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIBRARY_SOURCES 2 | "my_lib.cc") 3 | set(LIBRARY_HEADERS 4 | "my_lib.h") 5 | set(LIBRARY_INCLUDES 6 | "./" 7 | "${CMAKE_BINARY_DIR}/configured_files/include") 8 | 9 | add_library(${LIBRARY_NAME} STATIC 10 | ${LIBRARY_SOURCES} 11 | ${LIBRARY_HEADERS}) 12 | target_include_directories(${LIBRARY_NAME} PUBLIC 13 | ${LIBRARY_INCLUDES}) 14 | target_link_libraries(${LIBRARY_NAME} PUBLIC 15 | nlohmann_json::nlohmann_json 16 | fmt::fmt 17 | spdlog::spdlog 18 | cxxopts::cxxopts) 19 | target_include_directories(${LIBRARY_NAME} PUBLIC 20 | ${LIBRARY_INCLUDES}) 21 | 22 | if (ENABLE_WARNINGS) 23 | target_set_warnings( 24 | ${LIBRARY_NAME} 25 | ON 26 | OFF 27 | ) 28 | endif() 29 | 30 | if (ENABLE_LTO) 31 | target_enable_lto( 32 | ${LIBRARY_NAME} 33 | ${ENABLE_LTO} 34 | ) 35 | endif() 36 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIBRARY_SOURCES 2 | "my_lib.cc") 3 | set(LIBRARY_HEADERS 4 | "my_lib.h") 5 | set(LIBRARY_INCLUDES 6 | "./" 7 | "${CMAKE_BINARY_DIR}/configured_files/include") 8 | 9 | add_library(${LIBRARY_NAME} STATIC 10 | ${LIBRARY_SOURCES} 11 | ${LIBRARY_HEADERS}) 12 | target_include_directories(${LIBRARY_NAME} PUBLIC 13 | ${LIBRARY_INCLUDES}) 14 | target_link_libraries(${LIBRARY_NAME} PUBLIC 15 | nlohmann_json::nlohmann_json 16 | fmt::fmt 17 | spdlog::spdlog 18 | cxxopts::cxxopts) 19 | target_include_directories(${LIBRARY_NAME} PUBLIC 20 | ${LIBRARY_INCLUDES}) 21 | 22 | if (ENABLE_WARNINGS) 23 | target_set_warnings( 24 | ${LIBRARY_NAME} 25 | ON 26 | OFF 27 | ) 28 | endif() 29 | 30 | if (ENABLE_LTO) 31 | target_enable_lto( 32 | ${LIBRARY_NAME} 33 | ${ENABLE_LTO} 34 | ) 35 | endif() 36 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/src/my_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIBRARY_SOURCES 2 | "my_lib.cc") 3 | set(LIBRARY_HEADERS 4 | "my_lib.h") 5 | set(LIBRARY_INCLUDES 6 | "./" 7 | "${CMAKE_BINARY_DIR}/configured_files/include") 8 | 9 | add_library(${LIBRARY_NAME} STATIC 10 | ${LIBRARY_SOURCES} 11 | ${LIBRARY_HEADERS}) 12 | target_include_directories(${LIBRARY_NAME} PUBLIC 13 | ${LIBRARY_INCLUDES}) 14 | target_link_libraries(${LIBRARY_NAME} PUBLIC 15 | nlohmann_json::nlohmann_json 16 | fmt::fmt 17 | spdlog::spdlog 18 | cxxopts::cxxopts) 19 | target_include_directories(${LIBRARY_NAME} PUBLIC 20 | ${LIBRARY_INCLUDES}) 21 | 22 | if (ENABLE_WARNINGS) 23 | target_set_warnings( 24 | ${LIBRARY_NAME} 25 | ON 26 | OFF 27 | ) 28 | endif() 29 | 30 | if (ENABLE_LTO) 31 | target_enable_lto( 32 | ${LIBRARY_NAME} 33 | ${ENABLE_LTO} 34 | ) 35 | endif() 36 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "config.hpp" 9 | #include "my_lib.h" 10 | 11 | int main() 12 | { 13 | std::cout << project_name << '\n'; 14 | std::cout << project_version << '\n'; 15 | 16 | int i; 17 | 18 | char x[10]; 19 | x[11] = 1; 20 | 21 | std::cout << "JSON:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 22 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 23 | 24 | std::cout << "FMT:" << FMT_VERSION << "\n"; 25 | 26 | std::cout << "CXXOPTS:" << CXXOPTS__VERSION_MAJOR << "." << CXXOPTS__VERSION_MINOR << "." << CXXOPTS__VERSION_PATCH 27 | << "\n"; 28 | 29 | std::cout << "SPDLOG:" << SPDLOG_VER_MAJOR << "." << SPDLOG_VER_MINOR << "." << SPDLOG_VER_PATCH << "\n"; 30 | 31 | print_hello_world(); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/app/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "config.hpp" 9 | #include "my_lib.h" 10 | 11 | int main() 12 | { 13 | std::cout << project_name << '\n'; 14 | std::cout << project_version << '\n'; 15 | 16 | int i; 17 | 18 | char x[10]; 19 | x[11] = 1; 20 | 21 | std::cout << "JSON:" << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." 22 | << NLOHMANN_JSON_VERSION_PATCH << "\n"; 23 | 24 | std::cout << "FMT:" << FMT_VERSION << "\n"; 25 | 26 | std::cout << "CXXOPTS:" << CXXOPTS__VERSION_MAJOR << "." << CXXOPTS__VERSION_MINOR << "." << CXXOPTS__VERSION_PATCH 27 | << "\n"; 28 | 29 | std::cout << "SPDLOG:" << SPDLOG_VER_MAJOR << "." << SPDLOG_VER_MINOR << "." << SPDLOG_VER_PATCH << "\n"; 30 | 31 | print_hello_world(); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CustomTarget/scripts/CustomPythonTarget.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import glob 3 | from pathlib import Path 4 | 5 | 6 | def num_lines(fname: str) -> int: 7 | return sum(1 for _ in open(fname)) 8 | 9 | 10 | def main() -> None: 11 | parser = argparse.ArgumentParser( 12 | description="CustomPythonTarget", 13 | ) 14 | 15 | parser.add_argument( 16 | "--input_dir", 17 | type=str, 18 | required=True, 19 | ) 20 | 21 | parser.add_argument( 22 | "--output_dir", 23 | type=str, 24 | required=True, 25 | ) 26 | 27 | args = parser.parse_args() 28 | input_dir: str = args.input_dir 29 | output_dir: str = args.output_dir 30 | 31 | content = [] 32 | for file in glob.glob(f"{input_dir}/*.cc"): 33 | content.append(f"File: {file} has {num_lines(file)} lines") 34 | 35 | output_file = Path(output_dir) / "Stats.txt" 36 | with output_file.open("w") as f: 37 | f.writelines(content) 38 | 39 | 40 | if __name__ == "__main__": 41 | main() 42 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CustomCommand/scripts/CustomPythonTarget.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import glob 3 | from pathlib import Path 4 | 5 | 6 | def num_lines(fname: str) -> int: 7 | return sum(1 for _ in open(fname)) 8 | 9 | 10 | def main() -> None: 11 | parser = argparse.ArgumentParser( 12 | description="CustomPythonTarget", 13 | ) 14 | 15 | parser.add_argument( 16 | "--input_dir", 17 | type=str, 18 | required=True, 19 | ) 20 | 21 | parser.add_argument( 22 | "--output_dir", 23 | type=str, 24 | required=True, 25 | ) 26 | 27 | args = parser.parse_args() 28 | input_dir: str = args.input_dir 29 | output_dir: str = args.output_dir 30 | 31 | print("Running the CustomPythonTarget script") 32 | 33 | content = [] 34 | for file in glob.glob(f"{input_dir}/*.cc"): 35 | content.append(f"File: {file} has {num_lines(file)} lines") 36 | 37 | output_file = Path(output_dir) / "Stats.txt" 38 | with output_file.open("w") as f: 39 | f.writelines(content) 40 | 41 | 42 | if __name__ == "__main__": 43 | main() 44 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/cmake/Warnings.cmake: -------------------------------------------------------------------------------- 1 | function(target_set_warnings TARGET ENABLED ENABLED_AS_ERRORS) 2 | if (NOT ${ENABLED}) 3 | message(STATUS "Warnings Disabled for: ${TARGET}") 4 | return() 5 | endif() 6 | 7 | set(MSVC_WARNINGS 8 | /W4 9 | /permissive-) 10 | 11 | set(CLANG_WARNINGS 12 | -Wall 13 | -Wextra 14 | -Wpedantic) 15 | 16 | set(GCC_WARNINGS 17 | ${CLANG_WARNINGS}) 18 | 19 | if(${ENABLED_AS_ERRORS}) 20 | set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX) 21 | set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror) 22 | set(GCC_WARNINGS ${GCC_WARNINGS} -Werror) 23 | endif() 24 | 25 | if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 26 | set(WARNINGS ${MSVC_WARNINGS}) 27 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 28 | set(WARNINGS ${CLANG_WARNINGS}) 29 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") 30 | set(WARNINGS ${GCC_WARNINGS}) 31 | endif() 32 | 33 | target_compile_options(${TARGET} PRIVATE ${WARNINGS}) 34 | message(STATUS ${WARNINGS}) 35 | 36 | endfunction(target_set_warnings) 37 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/cmake/Warnings.cmake: -------------------------------------------------------------------------------- 1 | function(target_set_warnings TARGET ENABLED ENABLED_AS_ERRORS) 2 | if (NOT ${ENABLED}) 3 | message(STATUS "Warnings Disabled for: ${TARGET}") 4 | return() 5 | endif() 6 | 7 | set(MSVC_WARNINGS 8 | /W4 9 | /permissive-) 10 | 11 | set(CLANG_WARNINGS 12 | -Wall 13 | -Wextra 14 | -Wpedantic) 15 | 16 | set(GCC_WARNINGS 17 | ${CLANG_WARNINGS}) 18 | 19 | if(${ENABLED_AS_ERRORS}) 20 | set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX) 21 | set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror) 22 | set(GCC_WARNINGS ${GCC_WARNINGS} -Werror) 23 | endif() 24 | 25 | if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 26 | set(WARNINGS ${MSVC_WARNINGS}) 27 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 28 | set(WARNINGS ${CLANG_WARNINGS}) 29 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") 30 | set(WARNINGS ${GCC_WARNINGS}) 31 | endif() 32 | 33 | target_compile_options(${TARGET} PRIVATE ${WARNINGS}) 34 | message(STATUS ${WARNINGS}) 35 | 36 | endfunction(target_set_warnings) 37 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/cmake/Warnings.cmake: -------------------------------------------------------------------------------- 1 | function(target_set_warnings TARGET ENABLED ENABLED_AS_ERRORS) 2 | if (NOT ${ENABLED}) 3 | message(STATUS "Warnings Disabled for: ${TARGET}") 4 | return() 5 | endif() 6 | 7 | set(MSVC_WARNINGS 8 | /W4 9 | /permissive-) 10 | 11 | set(CLANG_WARNINGS 12 | -Wall 13 | -Wextra 14 | -Wpedantic) 15 | 16 | set(GCC_WARNINGS 17 | ${CLANG_WARNINGS}) 18 | 19 | if(${ENABLED_AS_ERRORS}) 20 | set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX) 21 | set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror) 22 | set(GCC_WARNINGS ${GCC_WARNINGS} -Werror) 23 | endif() 24 | 25 | if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 26 | set(WARNINGS ${MSVC_WARNINGS}) 27 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 28 | set(WARNINGS ${CLANG_WARNINGS}) 29 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") 30 | set(WARNINGS ${GCC_WARNINGS}) 31 | endif() 32 | 33 | target_compile_options(${TARGET} PRIVATE ${WARNINGS}) 34 | message(STATUS ${WARNINGS}) 35 | 36 | endfunction(target_set_warnings) 37 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/cmake/Warnings.cmake: -------------------------------------------------------------------------------- 1 | function(target_set_warnings TARGET ENABLED ENABLED_AS_ERRORS) 2 | if (NOT ${ENABLED}) 3 | message(STATUS "Warnings Disabled for: ${TARGET}") 4 | return() 5 | endif() 6 | 7 | set(MSVC_WARNINGS 8 | /W4 9 | /permissive-) 10 | 11 | set(CLANG_WARNINGS 12 | -Wall 13 | -Wextra 14 | -Wpedantic) 15 | 16 | set(GCC_WARNINGS 17 | ${CLANG_WARNINGS}) 18 | 19 | if(${ENABLED_AS_ERRORS}) 20 | set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX) 21 | set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror) 22 | set(GCC_WARNINGS ${GCC_WARNINGS} -Werror) 23 | endif() 24 | 25 | if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 26 | set(WARNINGS ${MSVC_WARNINGS}) 27 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 28 | set(WARNINGS ${CLANG_WARNINGS}) 29 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") 30 | set(WARNINGS ${GCC_WARNINGS}) 31 | endif() 32 | 33 | target_compile_options(${TARGET} PRIVATE ${WARNINGS}) 34 | message(STATUS ${WARNINGS}) 35 | 36 | endfunction(target_set_warnings) 37 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/cmake/Warnings.cmake: -------------------------------------------------------------------------------- 1 | function(target_set_warnings TARGET ENABLED ENABLED_AS_ERRORS) 2 | if (NOT ${ENABLED}) 3 | message(STATUS "Warnings Disabled for: ${TARGET}") 4 | return() 5 | endif() 6 | 7 | set(MSVC_WARNINGS 8 | /W4 9 | /permissive-) 10 | 11 | set(CLANG_WARNINGS 12 | -Wall 13 | -Wextra 14 | -Wpedantic) 15 | 16 | set(GCC_WARNINGS 17 | ${CLANG_WARNINGS}) 18 | 19 | if(${ENABLED_AS_ERRORS}) 20 | set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX) 21 | set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror) 22 | set(GCC_WARNINGS ${GCC_WARNINGS} -Werror) 23 | endif() 24 | 25 | if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 26 | set(WARNINGS ${MSVC_WARNINGS}) 27 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 28 | set(WARNINGS ${CLANG_WARNINGS}) 29 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") 30 | set(WARNINGS ${GCC_WARNINGS}) 31 | endif() 32 | 33 | target_compile_options(${TARGET} PRIVATE ${WARNINGS}) 34 | message(STATUS ${WARNINGS}) 35 | 36 | endfunction(target_set_warnings) 37 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/cmake/Warnings.cmake: -------------------------------------------------------------------------------- 1 | function(target_set_warnings TARGET ENABLED ENABLED_AS_ERRORS) 2 | if (NOT ${ENABLED}) 3 | message(STATUS "Warnings Disabled for: ${TARGET}") 4 | return() 5 | endif() 6 | 7 | set(MSVC_WARNINGS 8 | /W4 9 | /permissive-) 10 | 11 | set(CLANG_WARNINGS 12 | -Wall 13 | -Wextra 14 | -Wpedantic) 15 | 16 | set(GCC_WARNINGS 17 | ${CLANG_WARNINGS}) 18 | 19 | if(${ENABLED_AS_ERRORS}) 20 | set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX) 21 | set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror) 22 | set(GCC_WARNINGS ${GCC_WARNINGS} -Werror) 23 | endif() 24 | 25 | if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 26 | set(WARNINGS ${MSVC_WARNINGS}) 27 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 28 | set(WARNINGS ${CLANG_WARNINGS}) 29 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") 30 | set(WARNINGS ${GCC_WARNINGS}) 31 | endif() 32 | 33 | target_compile_options(${TARGET} PRIVATE ${WARNINGS}) 34 | message(STATUS ${WARNINGS}) 35 | 36 | endfunction(target_set_warnings) 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Jan Schaffranek 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /2_CMake/_Additional/CrossCompiler/README.md: -------------------------------------------------------------------------------- 1 | # Cross Compilation with Toolchain Files 2 | 3 | ## Install ARM Compiler on x86 64 Ubuntu 4 | 5 | ```shell 6 | sudo apt update 7 | sudo apt install libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-gnueabi libncurses5-dev build-essential bison flex libssl-dev bc 8 | 9 | sudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf 10 | sudo apt install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi 11 | ``` 12 | 13 | ## Install MingW Cross Compiler on x86 64 Ubuntu 14 | 15 | ```shell 16 | sudo apt-get install mingw-w64 17 | ``` 18 | 19 | ## ARM 32 Cross 20 | 21 | ```shell 22 | cmake -B build_arm32 -DCMAKE_TOOLCHAIN_FILE=Toolchains/arm32-cross-toolchain.cmake 23 | cmake --build build_arm32 -j8 24 | ``` 25 | 26 | ## ARM 32 Native 27 | 28 | ```shell 29 | cmake -B build -DCMAKE_TOOLCHAIN_FILE=Toolchains/arm32-native-toolchain.cmake 30 | cmake --build build -j8 31 | ``` 32 | 33 | ## x86 64 MingW 34 | 35 | ```shell 36 | cmake -B build_mingw -DCMAKE_TOOLCHAIN_FILE=Toolchains/x86-64-mingw-toolchain.cmake 37 | cmake --build build_mingw -j8 38 | ``` 39 | 40 | ## x86 64 Native 41 | 42 | ```shell 43 | cmake -B build -DCMAKE_TOOLCHAIN_FILE=Toolchains/x86-64-native-toolchain.cmake 44 | cmake --build build -j8 45 | ``` 46 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/cmake/Sanitizer.cmake: -------------------------------------------------------------------------------- 1 | function(add_sanitizer_flags enable_sanitize_addr enable_sanitize_undef) 2 | if (NOT enable_sanitize_addr AND NOT enable_sanitize_undef) 3 | message(STATUS "Sanitizers deactivated.") 4 | return() 5 | endif() 6 | 7 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") 8 | add_compile_options("-fno-omit-frame-pointer") 9 | add_link_options("-fno-omit-frame-pointer") 10 | 11 | if(enable_sanitize_addr) 12 | add_compile_options("-fsanitize=address") 13 | add_link_options("-fsanitize=address") 14 | endif() 15 | 16 | if(enable_sanitize_undef) 17 | add_compile_options("-fsanitize=undefined") 18 | add_link_options("-fsanitize=undefined") 19 | endif() 20 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 21 | if(enable_sanitize_addr) 22 | add_compile_options("/fsanitize=address") 23 | endif() 24 | 25 | if(enable_sanitize_undef) 26 | message(STATUS "Undefined sanitizer not impl. for MSVC!") 27 | endif() 28 | else() 29 | message(STATUS "Sanitizer not supported in this environment!") 30 | endif() 31 | endfunction(add_sanitizer_flags) 32 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/cmake/Sanitizer.cmake: -------------------------------------------------------------------------------- 1 | function(add_sanitizer_flags enable_sanitize_addr enable_sanitize_undef) 2 | if (NOT enable_sanitize_addr AND NOT enable_sanitize_undef) 3 | message(STATUS "Sanitizers deactivated.") 4 | return() 5 | endif() 6 | 7 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") 8 | add_compile_options("-fno-omit-frame-pointer") 9 | add_link_options("-fno-omit-frame-pointer") 10 | 11 | if(enable_sanitize_addr) 12 | add_compile_options("-fsanitize=address") 13 | add_link_options("-fsanitize=address") 14 | endif() 15 | 16 | if(enable_sanitize_undef) 17 | add_compile_options("-fsanitize=undefined") 18 | add_link_options("-fsanitize=undefined") 19 | endif() 20 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 21 | if(enable_sanitize_addr) 22 | add_compile_options("/fsanitize=address") 23 | endif() 24 | 25 | if(enable_sanitize_undef) 26 | message(STATUS "Undefined sanitizer not impl. for MSVC!") 27 | endif() 28 | else() 29 | message(STATUS "Sanitizer not supported in this environment!") 30 | endif() 31 | endfunction(add_sanitizer_flags) 32 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/cmake/Sanitizer.cmake: -------------------------------------------------------------------------------- 1 | function(add_sanitizer_flags enable_sanitize_addr enable_sanitize_undef) 2 | if (NOT enable_sanitize_addr AND NOT enable_sanitize_undef) 3 | message(STATUS "Sanitizers deactivated.") 4 | return() 5 | endif() 6 | 7 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") 8 | add_compile_options("-fno-omit-frame-pointer") 9 | add_link_options("-fno-omit-frame-pointer") 10 | 11 | if(enable_sanitize_addr) 12 | add_compile_options("-fsanitize=address") 13 | add_link_options("-fsanitize=address") 14 | endif() 15 | 16 | if(enable_sanitize_undef) 17 | add_compile_options("-fsanitize=undefined") 18 | add_link_options("-fsanitize=undefined") 19 | endif() 20 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 21 | if(enable_sanitize_addr) 22 | add_compile_options("/fsanitize=address") 23 | endif() 24 | 25 | if(enable_sanitize_undef) 26 | message(STATUS "Undefined sanitizer not impl. for MSVC!") 27 | endif() 28 | else() 29 | message(STATUS "Sanitizer not supported in this environment!") 30 | endif() 31 | endfunction(add_sanitizer_flags) 32 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/cmake/Sanitizer.cmake: -------------------------------------------------------------------------------- 1 | function(add_sanitizer_flags enable_sanitize_addr enable_sanitize_undef) 2 | if (NOT enable_sanitize_addr AND NOT enable_sanitize_undef) 3 | message(STATUS "Sanitizers deactivated.") 4 | return() 5 | endif() 6 | 7 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") 8 | add_compile_options("-fno-omit-frame-pointer") 9 | add_link_options("-fno-omit-frame-pointer") 10 | 11 | if(enable_sanitize_addr) 12 | add_compile_options("-fsanitize=address") 13 | add_link_options("-fsanitize=address") 14 | endif() 15 | 16 | if(enable_sanitize_undef) 17 | add_compile_options("-fsanitize=undefined") 18 | add_link_options("-fsanitize=undefined") 19 | endif() 20 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 21 | if(enable_sanitize_addr) 22 | add_compile_options("/fsanitize=address") 23 | endif() 24 | 25 | if(enable_sanitize_undef) 26 | message(STATUS "Undefined sanitizer not impl. for MSVC!") 27 | endif() 28 | else() 29 | message(STATUS "Sanitizer not supported in this environment!") 30 | endif() 31 | endfunction(add_sanitizer_flags) 32 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/cmake/Sanitizer.cmake: -------------------------------------------------------------------------------- 1 | function(add_sanitizer_flags enable_sanitize_addr enable_sanitize_undef) 2 | if (NOT enable_sanitize_addr AND NOT enable_sanitize_undef) 3 | message(STATUS "Sanitizers deactivated.") 4 | return() 5 | endif() 6 | 7 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") 8 | add_compile_options("-fno-omit-frame-pointer") 9 | add_link_options("-fno-omit-frame-pointer") 10 | 11 | if(enable_sanitize_addr) 12 | add_compile_options("-fsanitize=address") 13 | add_link_options("-fsanitize=address") 14 | endif() 15 | 16 | if(enable_sanitize_undef) 17 | add_compile_options("-fsanitize=undefined") 18 | add_link_options("-fsanitize=undefined") 19 | endif() 20 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 21 | if(enable_sanitize_addr) 22 | add_compile_options("/fsanitize=address") 23 | endif() 24 | 25 | if(enable_sanitize_undef) 26 | message(STATUS "Undefined sanitizer not impl. for MSVC!") 27 | endif() 28 | else() 29 | message(STATUS "Sanitizer not supported in this environment!") 30 | endif() 31 | endfunction(add_sanitizer_flags) 32 | -------------------------------------------------------------------------------- /2_CMake/08_FetchContent/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(CppProjectTemplate VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | set(CMAKE_CXX_EXTENSIONS OFF) 8 | 9 | set(LIBRARY_NAME Library) 10 | set(EXECUTABLE_NAME Executable) 11 | 12 | set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") 13 | include(AddGitSubmodule) 14 | include(FetchContent) 15 | 16 | FetchContent_Declare( 17 | nlohmann_json 18 | GIT_REPOSITORY https://github.com/nlohmann/json 19 | GIT_TAG v3.11.3 20 | GIT_SHALLOW TRUE) 21 | FetchContent_MakeAvailable(nlohmann_json) 22 | 23 | FetchContent_Declare( 24 | fmt 25 | GIT_REPOSITORY https://github.com/fmtlib/fmt 26 | GIT_TAG 10.2.1 27 | GIT_SHALLOW TRUE) 28 | FetchContent_MakeAvailable(fmt) 29 | 30 | FetchContent_Declare( 31 | spdlog 32 | GIT_REPOSITORY https://github.com/gabime/spdlog 33 | GIT_TAG v1.13.0 34 | GIT_SHALLOW TRUE) 35 | FetchContent_MakeAvailable(spdlog) 36 | 37 | FetchContent_Declare( 38 | cxxopts 39 | GIT_REPOSITORY https://github.com/jarro2783/cxxopts 40 | GIT_TAG v3.1.1 41 | GIT_SHALLOW TRUE) 42 | FetchContent_MakeAvailable(cxxopts) 43 | 44 | FetchContent_Declare( 45 | Catch2 46 | GIT_REPOSITORY https://github.com/catchorg/Catch2 47 | GIT_TAG v2.13.9 48 | GIT_SHALLOW TRUE) 49 | FetchContent_MakeAvailable(Catch2) 50 | 51 | add_subdirectory(configured) 52 | add_subdirectory(external) 53 | add_subdirectory(src) 54 | add_subdirectory(app) 55 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(CppProjectTemplate VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | set(CMAKE_CXX_EXTENSIONS OFF) 8 | 9 | set(LIBRARY_NAME Library) 10 | set(EXECUTABLE_NAME Executable) 11 | 12 | set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") 13 | include(AddGitSubmodule) 14 | include(FetchContent) 15 | include(Docs) 16 | 17 | FetchContent_Declare( 18 | nlohmann_json 19 | GIT_REPOSITORY https://github.com/nlohmann/json 20 | GIT_TAG v3.11.3 21 | GIT_SHALLOW TRUE) 22 | FetchContent_MakeAvailable(nlohmann_json) 23 | 24 | FetchContent_Declare( 25 | fmt 26 | GIT_REPOSITORY https://github.com/fmtlib/fmt 27 | GIT_TAG 10.2.1 28 | GIT_SHALLOW TRUE) 29 | FetchContent_MakeAvailable(fmt) 30 | 31 | FetchContent_Declare( 32 | spdlog 33 | GIT_REPOSITORY https://github.com/gabime/spdlog 34 | GIT_TAG v1.13.0 35 | GIT_SHALLOW TRUE) 36 | FetchContent_MakeAvailable(spdlog) 37 | 38 | FetchContent_Declare( 39 | cxxopts 40 | GIT_REPOSITORY https://github.com/jarro2783/cxxopts 41 | GIT_TAG v3.1.1 42 | GIT_SHALLOW TRUE) 43 | FetchContent_MakeAvailable(cxxopts) 44 | 45 | FetchContent_Declare( 46 | Catch2 47 | GIT_REPOSITORY https://github.com/catchorg/Catch2 48 | GIT_TAG v2.13.9 49 | GIT_SHALLOW TRUE) 50 | FetchContent_MakeAvailable(Catch2) 51 | 52 | add_subdirectory(configured) 53 | add_subdirectory(external) 54 | add_subdirectory(src) 55 | add_subdirectory(app) 56 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/tests/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | TEST_CASE("factorial1") 6 | { 7 | REQUIRE(factorial(0) == 1); 8 | REQUIRE(factorial(1) == 1); 9 | REQUIRE(factorial(2) == 2); 10 | REQUIRE(factorial(3) == 6); 11 | REQUIRE(factorial(10) == 3628800); 12 | } 13 | 14 | TEST_CASE("factorial2") 15 | { 16 | REQUIRE(factorial(0) == 1); 17 | REQUIRE(factorial(1) == 1); 18 | REQUIRE(factorial(2) == 2); 19 | REQUIRE(factorial(3) == 6); 20 | REQUIRE(factorial(10) == 3628800); 21 | } 22 | 23 | TEST_CASE("vectors can be sized and resized", "[vector]") 24 | { 25 | // This setup will be done 4 times in total, once for each section 26 | std::vector v(5); 27 | 28 | REQUIRE(v.size() == 5); 29 | REQUIRE(v.capacity() >= 5); 30 | 31 | SECTION("resizing bigger changes size and capacity") 32 | { 33 | v.resize(10); 34 | 35 | REQUIRE(v.size() == 10); 36 | REQUIRE(v.capacity() >= 10); 37 | } 38 | SECTION("resizing smaller changes size but not capacity") 39 | { 40 | v.resize(0); 41 | 42 | REQUIRE(v.size() == 0); 43 | REQUIRE(v.capacity() >= 5); 44 | } 45 | SECTION("reserving bigger changes capacity but not size") 46 | { 47 | v.reserve(10); 48 | 49 | REQUIRE(v.size() == 5); 50 | REQUIRE(v.capacity() >= 10); 51 | } 52 | SECTION("reserving smaller does not change size or capacity") 53 | { 54 | v.reserve(0); 55 | 56 | REQUIRE(v.size() == 5); 57 | REQUIRE(v.capacity() >= 5); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/tests/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | TEST_CASE("factorial1") 6 | { 7 | REQUIRE(factorial(0) == 1); 8 | REQUIRE(factorial(1) == 1); 9 | REQUIRE(factorial(2) == 2); 10 | REQUIRE(factorial(3) == 6); 11 | REQUIRE(factorial(10) == 3628800); 12 | } 13 | 14 | TEST_CASE("factorial2") 15 | { 16 | REQUIRE(factorial(0) == 1); 17 | REQUIRE(factorial(1) == 1); 18 | REQUIRE(factorial(2) == 2); 19 | REQUIRE(factorial(3) == 6); 20 | REQUIRE(factorial(10) == 3628800); 21 | } 22 | 23 | TEST_CASE("vectors can be sized and resized", "[vector]") 24 | { 25 | // This setup will be done 4 times in total, once for each section 26 | std::vector v(5); 27 | 28 | REQUIRE(v.size() == 5); 29 | REQUIRE(v.capacity() >= 5); 30 | 31 | SECTION("resizing bigger changes size and capacity") 32 | { 33 | v.resize(10); 34 | 35 | REQUIRE(v.size() == 10); 36 | REQUIRE(v.capacity() >= 10); 37 | } 38 | SECTION("resizing smaller changes size but not capacity") 39 | { 40 | v.resize(0); 41 | 42 | REQUIRE(v.size() == 0); 43 | REQUIRE(v.capacity() >= 5); 44 | } 45 | SECTION("reserving bigger changes capacity but not size") 46 | { 47 | v.reserve(10); 48 | 49 | REQUIRE(v.size() == 5); 50 | REQUIRE(v.capacity() >= 10); 51 | } 52 | SECTION("reserving smaller does not change size or capacity") 53 | { 54 | v.reserve(0); 55 | 56 | REQUIRE(v.size() == 5); 57 | REQUIRE(v.capacity() >= 5); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/tests/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | TEST_CASE("factorial1") 6 | { 7 | REQUIRE(factorial(0) == 1); 8 | REQUIRE(factorial(1) == 1); 9 | REQUIRE(factorial(2) == 2); 10 | REQUIRE(factorial(3) == 6); 11 | REQUIRE(factorial(10) == 3628800); 12 | } 13 | 14 | TEST_CASE("factorial2") 15 | { 16 | REQUIRE(factorial(0) == 1); 17 | REQUIRE(factorial(1) == 1); 18 | REQUIRE(factorial(2) == 2); 19 | REQUIRE(factorial(3) == 6); 20 | REQUIRE(factorial(10) == 3628800); 21 | } 22 | 23 | TEST_CASE("vectors can be sized and resized", "[vector]") 24 | { 25 | // This setup will be done 4 times in total, once for each section 26 | std::vector v(5); 27 | 28 | REQUIRE(v.size() == 5); 29 | REQUIRE(v.capacity() >= 5); 30 | 31 | SECTION("resizing bigger changes size and capacity") 32 | { 33 | v.resize(10); 34 | 35 | REQUIRE(v.size() == 10); 36 | REQUIRE(v.capacity() >= 10); 37 | } 38 | SECTION("resizing smaller changes size but not capacity") 39 | { 40 | v.resize(0); 41 | 42 | REQUIRE(v.size() == 0); 43 | REQUIRE(v.capacity() >= 5); 44 | } 45 | SECTION("reserving bigger changes capacity but not size") 46 | { 47 | v.reserve(10); 48 | 49 | REQUIRE(v.size() == 5); 50 | REQUIRE(v.capacity() >= 10); 51 | } 52 | SECTION("reserving smaller does not change size or capacity") 53 | { 54 | v.reserve(0); 55 | 56 | REQUIRE(v.size() == 5); 57 | REQUIRE(v.capacity() >= 5); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/tests/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | TEST_CASE("factorial1") 6 | { 7 | REQUIRE(factorial(0) == 1); 8 | REQUIRE(factorial(1) == 1); 9 | REQUIRE(factorial(2) == 2); 10 | REQUIRE(factorial(3) == 6); 11 | REQUIRE(factorial(10) == 3628800); 12 | } 13 | 14 | TEST_CASE("factorial2") 15 | { 16 | REQUIRE(factorial(0) == 1); 17 | REQUIRE(factorial(1) == 1); 18 | REQUIRE(factorial(2) == 2); 19 | REQUIRE(factorial(3) == 6); 20 | REQUIRE(factorial(10) == 3628800); 21 | } 22 | 23 | TEST_CASE("vectors can be sized and resized", "[vector]") 24 | { 25 | // This setup will be done 4 times in total, once for each section 26 | std::vector v(5); 27 | 28 | REQUIRE(v.size() == 5); 29 | REQUIRE(v.capacity() >= 5); 30 | 31 | SECTION("resizing bigger changes size and capacity") 32 | { 33 | v.resize(10); 34 | 35 | REQUIRE(v.size() == 10); 36 | REQUIRE(v.capacity() >= 10); 37 | } 38 | SECTION("resizing smaller changes size but not capacity") 39 | { 40 | v.resize(0); 41 | 42 | REQUIRE(v.size() == 0); 43 | REQUIRE(v.capacity() >= 5); 44 | } 45 | SECTION("reserving bigger changes capacity but not size") 46 | { 47 | v.reserve(10); 48 | 49 | REQUIRE(v.size() == 5); 50 | REQUIRE(v.capacity() >= 10); 51 | } 52 | SECTION("reserving smaller does not change size or capacity") 53 | { 54 | v.reserve(0); 55 | 56 | REQUIRE(v.size() == 5); 57 | REQUIRE(v.capacity() >= 5); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/tests/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | TEST_CASE("factorial1") 6 | { 7 | REQUIRE(factorial(0) == 1); 8 | REQUIRE(factorial(1) == 1); 9 | REQUIRE(factorial(2) == 2); 10 | REQUIRE(factorial(3) == 6); 11 | REQUIRE(factorial(10) == 3628800); 12 | } 13 | 14 | TEST_CASE("factorial2") 15 | { 16 | REQUIRE(factorial(0) == 1); 17 | REQUIRE(factorial(1) == 1); 18 | REQUIRE(factorial(2) == 2); 19 | REQUIRE(factorial(3) == 6); 20 | REQUIRE(factorial(10) == 3628800); 21 | } 22 | 23 | TEST_CASE("vectors can be sized and resized", "[vector]") 24 | { 25 | // This setup will be done 4 times in total, once for each section 26 | std::vector v(5); 27 | 28 | REQUIRE(v.size() == 5); 29 | REQUIRE(v.capacity() >= 5); 30 | 31 | SECTION("resizing bigger changes size and capacity") 32 | { 33 | v.resize(10); 34 | 35 | REQUIRE(v.size() == 10); 36 | REQUIRE(v.capacity() >= 10); 37 | } 38 | SECTION("resizing smaller changes size but not capacity") 39 | { 40 | v.resize(0); 41 | 42 | REQUIRE(v.size() == 0); 43 | REQUIRE(v.capacity() >= 5); 44 | } 45 | SECTION("reserving bigger changes capacity but not size") 46 | { 47 | v.reserve(10); 48 | 49 | REQUIRE(v.size() == 5); 50 | REQUIRE(v.capacity() >= 10); 51 | } 52 | SECTION("reserving smaller does not change size or capacity") 53 | { 54 | v.reserve(0); 55 | 56 | REQUIRE(v.size() == 5); 57 | REQUIRE(v.capacity() >= 5); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/tests/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | TEST_CASE("factorial1") 6 | { 7 | REQUIRE(factorial(0) == 1); 8 | REQUIRE(factorial(1) == 1); 9 | REQUIRE(factorial(2) == 2); 10 | REQUIRE(factorial(3) == 6); 11 | REQUIRE(factorial(10) == 3628800); 12 | } 13 | 14 | TEST_CASE("factorial2") 15 | { 16 | REQUIRE(factorial(0) == 1); 17 | REQUIRE(factorial(1) == 1); 18 | REQUIRE(factorial(2) == 2); 19 | REQUIRE(factorial(3) == 6); 20 | REQUIRE(factorial(10) == 3628800); 21 | } 22 | 23 | TEST_CASE("vectors can be sized and resized", "[vector]") 24 | { 25 | // This setup will be done 4 times in total, once for each section 26 | std::vector v(5); 27 | 28 | REQUIRE(v.size() == 5); 29 | REQUIRE(v.capacity() >= 5); 30 | 31 | SECTION("resizing bigger changes size and capacity") 32 | { 33 | v.resize(10); 34 | 35 | REQUIRE(v.size() == 10); 36 | REQUIRE(v.capacity() >= 10); 37 | } 38 | SECTION("resizing smaller changes size but not capacity") 39 | { 40 | v.resize(0); 41 | 42 | REQUIRE(v.size() == 0); 43 | REQUIRE(v.capacity() >= 5); 44 | } 45 | SECTION("reserving bigger changes capacity but not size") 46 | { 47 | v.reserve(10); 48 | 49 | REQUIRE(v.size() == 5); 50 | REQUIRE(v.capacity() >= 10); 51 | } 52 | SECTION("reserving smaller does not change size or capacity") 53 | { 54 | v.reserve(0); 55 | 56 | REQUIRE(v.size() == 5); 57 | REQUIRE(v.capacity() >= 5); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/tests/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_lib.h" 4 | 5 | TEST_CASE("factorial1") 6 | { 7 | REQUIRE(factorial(0) == 1); 8 | REQUIRE(factorial(1) == 1); 9 | REQUIRE(factorial(2) == 2); 10 | REQUIRE(factorial(3) == 6); 11 | REQUIRE(factorial(10) == 3628800); 12 | } 13 | 14 | TEST_CASE("factorial2") 15 | { 16 | REQUIRE(factorial(0) == 1); 17 | REQUIRE(factorial(1) == 1); 18 | REQUIRE(factorial(2) == 2); 19 | REQUIRE(factorial(3) == 6); 20 | REQUIRE(factorial(10) == 3628800); 21 | } 22 | 23 | TEST_CASE("vectors can be sized and resized", "[vector]") 24 | { 25 | // This setup will be done 4 times in total, once for each section 26 | std::vector v(5); 27 | 28 | REQUIRE(v.size() == 5); 29 | REQUIRE(v.capacity() >= 5); 30 | 31 | SECTION("resizing bigger changes size and capacity") 32 | { 33 | v.resize(10); 34 | 35 | REQUIRE(v.size() == 10); 36 | REQUIRE(v.capacity() >= 10); 37 | } 38 | SECTION("resizing smaller changes size but not capacity") 39 | { 40 | v.resize(0); 41 | 42 | REQUIRE(v.size() == 0); 43 | REQUIRE(v.capacity() >= 5); 44 | } 45 | SECTION("reserving bigger changes capacity but not size") 46 | { 47 | v.reserve(10); 48 | 49 | REQUIRE(v.size() == 5); 50 | REQUIRE(v.capacity() >= 10); 51 | } 52 | SECTION("reserving smaller does not change size or capacity") 53 | { 54 | v.reserve(0); 55 | 56 | REQUIRE(v.size() == 5); 57 | REQUIRE(v.capacity() >= 5); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project( 4 | CppProjectTemplate 5 | VERSION 1.0.0 6 | LANGUAGES C CXX) 7 | 8 | set(CMAKE_CXX_STANDARD 17) 9 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 10 | set(CMAKE_CXX_EXTENSIONS OFF) 11 | 12 | option(ENABLE_TESTING "Enable a Unit Testing Build" ON) 13 | 14 | set(LIBRARY_NAME "Library") 15 | set(EXECUTABLE_NAME "Executable") 16 | 17 | set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") 18 | include(AddGitSubmodule) 19 | include(FetchContent) 20 | include(Docs) 21 | 22 | FetchContent_Declare( 23 | nlohmann_json 24 | GIT_REPOSITORY https://github.com/nlohmann/json 25 | GIT_TAG v3.11.3 26 | GIT_SHALLOW TRUE) 27 | FetchContent_MakeAvailable(nlohmann_json) 28 | 29 | FetchContent_Declare( 30 | fmt 31 | GIT_REPOSITORY https://github.com/fmtlib/fmt 32 | GIT_TAG 9.1.0 33 | GIT_SHALLOW TRUE) 34 | FetchContent_MakeAvailable(fmt) 35 | 36 | FetchContent_Declare( 37 | spdlog 38 | GIT_REPOSITORY https://github.com/gabime/spdlog 39 | GIT_TAG v1.13.0 40 | GIT_SHALLOW TRUE) 41 | FetchContent_MakeAvailable(spdlog) 42 | 43 | FetchContent_Declare( 44 | cxxopts 45 | GIT_REPOSITORY https://github.com/jarro2783/cxxopts 46 | GIT_TAG v3.1.1 47 | GIT_SHALLOW TRUE) 48 | FetchContent_MakeAvailable(cxxopts) 49 | 50 | if(ENABLE_TESTING) 51 | FetchContent_Declare( 52 | Catch2 53 | GIT_REPOSITORY https://github.com/catchorg/Catch2 54 | GIT_TAG v3.5.3 55 | GIT_SHALLOW TRUE) 56 | FetchContent_MakeAvailable(Catch2) 57 | list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras) 58 | endif() 59 | 60 | add_subdirectory(configured) 61 | add_subdirectory(external) 62 | add_subdirectory(src) 63 | add_subdirectory(app) 64 | if(ENABLE_TESTING) 65 | include(CTest) 66 | enable_testing() 67 | add_subdirectory(tests) 68 | endif() 69 | -------------------------------------------------------------------------------- /2_CMake/Doxyfile: -------------------------------------------------------------------------------- 1 | # Configuration for Doxygen for use with CMake 2 | # Only options that deviate from the default are included 3 | # To create a new Doxyfile containing all available options, call `doxygen -g` 4 | 5 | #--------------------------------------------------------------------------- 6 | # Project related configuration options 7 | #--------------------------------------------------------------------------- 8 | DOXYFILE_ENCODING = UTF-8 9 | PROJECT_NAME = "C++ Project Template" 10 | PROJECT_NUMBER = 1.0 11 | PROJECT_BRIEF = 12 | PROJECT_LOGO = 13 | OUTPUT_DIRECTORY = ./ 14 | OUTPUT_LANGUAGE = English 15 | MARKDOWN_SUPPORT = YES 16 | 17 | #--------------------------------------------------------------------------- 18 | # Configure Graphs 19 | #--------------------------------------------------------------------------- 20 | HAVE_DOT = YES 21 | INCLUDE_GRAPH = YES 22 | 23 | #--------------------------------------------------------------------------- 24 | # Build related configuration options 25 | #--------------------------------------------------------------------------- 26 | EXTRACT_ALL = YES 27 | RECURSIVE = YES 28 | GENERATE_HTML = YES 29 | GENERATE_LATEX = NO 30 | 31 | #--------------------------------------------------------------------------- 32 | # Configuration options related to the input files 33 | #--------------------------------------------------------------------------- 34 | INPUT = ../src \ 35 | INPUT ../include 36 | INPUT_ENCODING = UTF-8 37 | FILE_PATTERNS = *.c \ 38 | *.cc \ 39 | *.cpp \ 40 | *.c++ \ 41 | *.h \ 42 | *.hpp \ 43 | *.h++ \ 44 | *.md \ 45 | *.dox \ 46 | *.doc \ 47 | *.txt 48 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/docs/Doxyfile: -------------------------------------------------------------------------------- 1 | # Configuration for Doxygen for use with CMake 2 | # Only options that deviate from the default are included 3 | # To create a new Doxyfile containing all available options, call `doxygen -g` 4 | 5 | #--------------------------------------------------------------------------- 6 | # Project related configuration options 7 | #--------------------------------------------------------------------------- 8 | DOXYFILE_ENCODING = UTF-8 9 | PROJECT_NAME = "C++ Project Template" 10 | PROJECT_NUMBER = 1.0 11 | PROJECT_BRIEF = 12 | PROJECT_LOGO = 13 | OUTPUT_DIRECTORY = ./ 14 | OUTPUT_LANGUAGE = English 15 | MARKDOWN_SUPPORT = YES 16 | 17 | #--------------------------------------------------------------------------- 18 | # Configure Graphs 19 | #--------------------------------------------------------------------------- 20 | HAVE_DOT = YES 21 | INCLUDE_GRAPH = YES 22 | 23 | #--------------------------------------------------------------------------- 24 | # Build related configuration options 25 | #--------------------------------------------------------------------------- 26 | EXTRACT_ALL = YES 27 | RECURSIVE = YES 28 | GENERATE_HTML = YES 29 | GENERATE_LATEX = NO 30 | 31 | #--------------------------------------------------------------------------- 32 | # Configuration options related to the input files 33 | #--------------------------------------------------------------------------- 34 | INPUT = ../src \ 35 | INPUT ../include 36 | INPUT_ENCODING = UTF-8 37 | FILE_PATTERNS = *.c \ 38 | *.cc \ 39 | *.cpp \ 40 | *.c++ \ 41 | *.h \ 42 | *.hpp \ 43 | *.h++ \ 44 | *.md \ 45 | *.dox \ 46 | *.doc \ 47 | *.txt 48 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/docs/Doxyfile: -------------------------------------------------------------------------------- 1 | # Configuration for Doxygen for use with CMake 2 | # Only options that deviate from the default are included 3 | # To create a new Doxyfile containing all available options, call `doxygen -g` 4 | 5 | #--------------------------------------------------------------------------- 6 | # Project related configuration options 7 | #--------------------------------------------------------------------------- 8 | DOXYFILE_ENCODING = UTF-8 9 | PROJECT_NAME = "C++ Project Template" 10 | PROJECT_NUMBER = 1.0 11 | PROJECT_BRIEF = 12 | PROJECT_LOGO = 13 | OUTPUT_DIRECTORY = ./ 14 | OUTPUT_LANGUAGE = English 15 | MARKDOWN_SUPPORT = YES 16 | 17 | #--------------------------------------------------------------------------- 18 | # Configure Graphs 19 | #--------------------------------------------------------------------------- 20 | HAVE_DOT = YES 21 | INCLUDE_GRAPH = YES 22 | 23 | #--------------------------------------------------------------------------- 24 | # Build related configuration options 25 | #--------------------------------------------------------------------------- 26 | EXTRACT_ALL = YES 27 | RECURSIVE = YES 28 | GENERATE_HTML = YES 29 | GENERATE_LATEX = NO 30 | 31 | #--------------------------------------------------------------------------- 32 | # Configuration options related to the input files 33 | #--------------------------------------------------------------------------- 34 | INPUT = ../src \ 35 | INPUT ../include 36 | INPUT_ENCODING = UTF-8 37 | FILE_PATTERNS = *.c \ 38 | *.cc \ 39 | *.cpp \ 40 | *.c++ \ 41 | *.h \ 42 | *.hpp \ 43 | *.h++ \ 44 | *.md \ 45 | *.dox \ 46 | *.doc \ 47 | *.txt 48 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/docs/Doxyfile: -------------------------------------------------------------------------------- 1 | # Configuration for Doxygen for use with CMake 2 | # Only options that deviate from the default are included 3 | # To create a new Doxyfile containing all available options, call `doxygen -g` 4 | 5 | #--------------------------------------------------------------------------- 6 | # Project related configuration options 7 | #--------------------------------------------------------------------------- 8 | DOXYFILE_ENCODING = UTF-8 9 | PROJECT_NAME = "C++ Project Template" 10 | PROJECT_NUMBER = 1.0 11 | PROJECT_BRIEF = 12 | PROJECT_LOGO = 13 | OUTPUT_DIRECTORY = ./ 14 | OUTPUT_LANGUAGE = English 15 | MARKDOWN_SUPPORT = YES 16 | 17 | #--------------------------------------------------------------------------- 18 | # Configure Graphs 19 | #--------------------------------------------------------------------------- 20 | HAVE_DOT = YES 21 | INCLUDE_GRAPH = YES 22 | 23 | #--------------------------------------------------------------------------- 24 | # Build related configuration options 25 | #--------------------------------------------------------------------------- 26 | EXTRACT_ALL = YES 27 | RECURSIVE = YES 28 | GENERATE_HTML = YES 29 | GENERATE_LATEX = NO 30 | 31 | #--------------------------------------------------------------------------- 32 | # Configuration options related to the input files 33 | #--------------------------------------------------------------------------- 34 | INPUT = ../src \ 35 | INPUT ../include 36 | INPUT_ENCODING = UTF-8 37 | FILE_PATTERNS = *.c \ 38 | *.cc \ 39 | *.cpp \ 40 | *.c++ \ 41 | *.h \ 42 | *.hpp \ 43 | *.h++ \ 44 | *.md \ 45 | *.dox \ 46 | *.doc \ 47 | *.txt 48 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/docs/Doxyfile: -------------------------------------------------------------------------------- 1 | # Configuration for Doxygen for use with CMake 2 | # Only options that deviate from the default are included 3 | # To create a new Doxyfile containing all available options, call `doxygen -g` 4 | 5 | #--------------------------------------------------------------------------- 6 | # Project related configuration options 7 | #--------------------------------------------------------------------------- 8 | DOXYFILE_ENCODING = UTF-8 9 | PROJECT_NAME = "C++ Project Template" 10 | PROJECT_NUMBER = 1.0 11 | PROJECT_BRIEF = 12 | PROJECT_LOGO = 13 | OUTPUT_DIRECTORY = ./ 14 | OUTPUT_LANGUAGE = English 15 | MARKDOWN_SUPPORT = YES 16 | 17 | #--------------------------------------------------------------------------- 18 | # Configure Graphs 19 | #--------------------------------------------------------------------------- 20 | HAVE_DOT = YES 21 | INCLUDE_GRAPH = YES 22 | 23 | #--------------------------------------------------------------------------- 24 | # Build related configuration options 25 | #--------------------------------------------------------------------------- 26 | EXTRACT_ALL = YES 27 | RECURSIVE = YES 28 | GENERATE_HTML = YES 29 | GENERATE_LATEX = NO 30 | 31 | #--------------------------------------------------------------------------- 32 | # Configuration options related to the input files 33 | #--------------------------------------------------------------------------- 34 | INPUT = ../src \ 35 | INPUT ../include 36 | INPUT_ENCODING = UTF-8 37 | FILE_PATTERNS = *.c \ 38 | *.cc \ 39 | *.cpp \ 40 | *.c++ \ 41 | *.h \ 42 | *.hpp \ 43 | *.h++ \ 44 | *.md \ 45 | *.dox \ 46 | *.doc \ 47 | *.txt 48 | -------------------------------------------------------------------------------- /2_CMake/09_Doxygen/docs/Doxyfile: -------------------------------------------------------------------------------- 1 | # Configuration for Doxygen for use with CMake 2 | # Only options that deviate from the default are included 3 | # To create a new Doxyfile containing all available options, call `doxygen -g` 4 | 5 | #--------------------------------------------------------------------------- 6 | # Project related configuration options 7 | #--------------------------------------------------------------------------- 8 | DOXYFILE_ENCODING = UTF-8 9 | PROJECT_NAME = "C++ Project Template" 10 | PROJECT_NUMBER = 1.0 11 | PROJECT_BRIEF = 12 | PROJECT_LOGO = 13 | OUTPUT_DIRECTORY = ./ 14 | OUTPUT_LANGUAGE = English 15 | MARKDOWN_SUPPORT = YES 16 | 17 | #--------------------------------------------------------------------------- 18 | # Configure Graphs 19 | #--------------------------------------------------------------------------- 20 | HAVE_DOT = YES 21 | INCLUDE_GRAPH = YES 22 | 23 | #--------------------------------------------------------------------------- 24 | # Build related configuration options 25 | #--------------------------------------------------------------------------- 26 | EXTRACT_ALL = YES 27 | RECURSIVE = YES 28 | GENERATE_HTML = YES 29 | GENERATE_LATEX = NO 30 | 31 | #--------------------------------------------------------------------------- 32 | # Configuration options related to the input files 33 | #--------------------------------------------------------------------------- 34 | INPUT = ../src \ 35 | INPUT ../include 36 | INPUT_ENCODING = UTF-8 37 | FILE_PATTERNS = *.c \ 38 | *.cc \ 39 | *.cpp \ 40 | *.c++ \ 41 | *.h \ 42 | *.hpp \ 43 | *.h++ \ 44 | *.md \ 45 | *.dox \ 46 | *.doc \ 47 | *.txt 48 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/docs/Doxyfile: -------------------------------------------------------------------------------- 1 | # Configuration for Doxygen for use with CMake 2 | # Only options that deviate from the default are included 3 | # To create a new Doxyfile containing all available options, call `doxygen -g` 4 | 5 | #--------------------------------------------------------------------------- 6 | # Project related configuration options 7 | #--------------------------------------------------------------------------- 8 | DOXYFILE_ENCODING = UTF-8 9 | PROJECT_NAME = "C++ Project Template" 10 | PROJECT_NUMBER = 1.0 11 | PROJECT_BRIEF = 12 | PROJECT_LOGO = 13 | OUTPUT_DIRECTORY = ./ 14 | OUTPUT_LANGUAGE = English 15 | MARKDOWN_SUPPORT = YES 16 | 17 | #--------------------------------------------------------------------------- 18 | # Configure Graphs 19 | #--------------------------------------------------------------------------- 20 | HAVE_DOT = YES 21 | INCLUDE_GRAPH = YES 22 | 23 | #--------------------------------------------------------------------------- 24 | # Build related configuration options 25 | #--------------------------------------------------------------------------- 26 | EXTRACT_ALL = YES 27 | RECURSIVE = YES 28 | GENERATE_HTML = YES 29 | GENERATE_LATEX = NO 30 | 31 | #--------------------------------------------------------------------------- 32 | # Configuration options related to the input files 33 | #--------------------------------------------------------------------------- 34 | INPUT = ../src \ 35 | INPUT ../include 36 | INPUT_ENCODING = UTF-8 37 | FILE_PATTERNS = *.c \ 38 | *.cc \ 39 | *.cpp \ 40 | *.c++ \ 41 | *.h \ 42 | *.hpp \ 43 | *.h++ \ 44 | *.md \ 45 | *.dox \ 46 | *.doc \ 47 | *.txt 48 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/docs/Doxyfile: -------------------------------------------------------------------------------- 1 | # Configuration for Doxygen for use with CMake 2 | # Only options that deviate from the default are included 3 | # To create a new Doxyfile containing all available options, call `doxygen -g` 4 | 5 | #--------------------------------------------------------------------------- 6 | # Project related configuration options 7 | #--------------------------------------------------------------------------- 8 | DOXYFILE_ENCODING = UTF-8 9 | PROJECT_NAME = "C++ Project Template" 10 | PROJECT_NUMBER = 1.0 11 | PROJECT_BRIEF = 12 | PROJECT_LOGO = 13 | OUTPUT_DIRECTORY = ./ 14 | OUTPUT_LANGUAGE = English 15 | MARKDOWN_SUPPORT = YES 16 | 17 | #--------------------------------------------------------------------------- 18 | # Configure Graphs 19 | #--------------------------------------------------------------------------- 20 | HAVE_DOT = YES 21 | INCLUDE_GRAPH = YES 22 | 23 | #--------------------------------------------------------------------------- 24 | # Build related configuration options 25 | #--------------------------------------------------------------------------- 26 | EXTRACT_ALL = YES 27 | RECURSIVE = YES 28 | GENERATE_HTML = YES 29 | GENERATE_LATEX = NO 30 | 31 | #--------------------------------------------------------------------------- 32 | # Configuration options related to the input files 33 | #--------------------------------------------------------------------------- 34 | INPUT = ../src \ 35 | INPUT ../include 36 | INPUT_ENCODING = UTF-8 37 | FILE_PATTERNS = *.c \ 38 | *.cc \ 39 | *.cpp \ 40 | *.c++ \ 41 | *.h \ 42 | *.hpp \ 43 | *.h++ \ 44 | *.md \ 45 | *.dox \ 46 | *.doc \ 47 | *.txt 48 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/docs/Doxyfile: -------------------------------------------------------------------------------- 1 | # Configuration for Doxygen for use with CMake 2 | # Only options that deviate from the default are included 3 | # To create a new Doxyfile containing all available options, call `doxygen -g` 4 | 5 | #--------------------------------------------------------------------------- 6 | # Project related configuration options 7 | #--------------------------------------------------------------------------- 8 | DOXYFILE_ENCODING = UTF-8 9 | PROJECT_NAME = "C++ Project Template" 10 | PROJECT_NUMBER = 1.0 11 | PROJECT_BRIEF = 12 | PROJECT_LOGO = 13 | OUTPUT_DIRECTORY = ./ 14 | OUTPUT_LANGUAGE = English 15 | MARKDOWN_SUPPORT = YES 16 | 17 | #--------------------------------------------------------------------------- 18 | # Configure Graphs 19 | #--------------------------------------------------------------------------- 20 | HAVE_DOT = YES 21 | INCLUDE_GRAPH = YES 22 | 23 | #--------------------------------------------------------------------------- 24 | # Build related configuration options 25 | #--------------------------------------------------------------------------- 26 | EXTRACT_ALL = YES 27 | RECURSIVE = YES 28 | GENERATE_HTML = YES 29 | GENERATE_LATEX = NO 30 | 31 | #--------------------------------------------------------------------------- 32 | # Configuration options related to the input files 33 | #--------------------------------------------------------------------------- 34 | INPUT = ../src \ 35 | INPUT ../include 36 | INPUT_ENCODING = UTF-8 37 | FILE_PATTERNS = *.c \ 38 | *.cc \ 39 | *.cpp \ 40 | *.c++ \ 41 | *.h \ 42 | *.hpp \ 43 | *.h++ \ 44 | *.md \ 45 | *.dox \ 46 | *.doc \ 47 | *.txt 48 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project( 4 | CppProjectTemplate 5 | VERSION 1.0.0 6 | LANGUAGES C CXX) 7 | 8 | set(CMAKE_CXX_STANDARD 17) 9 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 10 | set(CMAKE_CXX_EXTENSIONS OFF) 11 | 12 | option(ENABLE_TESTING "Enable a Unit Testing Build" ON) 13 | 14 | option(ENABLE_WARNINGS "Enable to add warnings to a target." ON) 15 | option(ENABLE_WARNINGS_AS_ERRORS "Enable to treat warnings as errors." OFF) 16 | 17 | set(LIBRARY_NAME Library) 18 | set(EXECUTABLE_NAME Executable) 19 | 20 | set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") 21 | include(AddGitSubmodule) 22 | include(FetchContent) 23 | include(Docs) 24 | 25 | if(ENABLE_WARNINGS) 26 | include(Warnings) 27 | endif() 28 | 29 | FetchContent_Declare( 30 | nlohmann_json 31 | GIT_REPOSITORY https://github.com/nlohmann/json 32 | GIT_TAG v3.11.3 33 | GIT_SHALLOW TRUE) 34 | FetchContent_MakeAvailable(nlohmann_json) 35 | 36 | FetchContent_Declare( 37 | fmt 38 | GIT_REPOSITORY https://github.com/fmtlib/fmt 39 | GIT_TAG 9.1.0 40 | GIT_SHALLOW TRUE) 41 | FetchContent_MakeAvailable(fmt) 42 | 43 | FetchContent_Declare( 44 | spdlog 45 | GIT_REPOSITORY https://github.com/gabime/spdlog 46 | GIT_TAG v1.13.0 47 | GIT_SHALLOW TRUE) 48 | FetchContent_MakeAvailable(spdlog) 49 | 50 | FetchContent_Declare( 51 | cxxopts 52 | GIT_REPOSITORY https://github.com/jarro2783/cxxopts 53 | GIT_TAG v3.1.1 54 | GIT_SHALLOW TRUE) 55 | FetchContent_MakeAvailable(cxxopts) 56 | 57 | if(ENABLE_TESTING) 58 | FetchContent_Declare( 59 | Catch2 60 | GIT_REPOSITORY https://github.com/catchorg/Catch2 61 | GIT_TAG v3.5.3 62 | GIT_SHALLOW TRUE) 63 | FetchContent_MakeAvailable(Catch2) 64 | list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras) 65 | endif() 66 | 67 | add_subdirectory(configured) 68 | add_subdirectory(external) 69 | add_subdirectory(src) 70 | add_subdirectory(app) 71 | if(ENABLE_TESTING) 72 | include(CTest) 73 | enable_testing() 74 | add_subdirectory(tests) 75 | endif() 76 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "(gdb) Launch", 6 | "type": "cppdbg", 7 | "request": "launch", 8 | "program": "${command:cmake.launchTargetPath}", 9 | "args": [], 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "environment": [ 13 | { 14 | "name": "PATH", 15 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 16 | } 17 | ], 18 | "externalConsole": true, 19 | "MIMode": "gdb", 20 | "setupCommands": [ 21 | { 22 | "description": "Enable pretty-printing for gdb", 23 | "text": "-enable-pretty-printing", 24 | "ignoreFailures": true 25 | } 26 | ] 27 | }, 28 | { 29 | "name": "(lldb) Launch", 30 | "type": "cppdbg", 31 | "request": "launch", 32 | "program": "${command:cmake.launchTargetPath}", 33 | "args": [], 34 | "stopAtEntry": false, 35 | "cwd": "${workspaceFolder}", 36 | "environment": [ 37 | { 38 | "name": "PATH", 39 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 40 | } 41 | ], 42 | "externalConsole": true, 43 | "MIMode": "lldb" 44 | }, 45 | { 46 | "name": "(msvc) Launch", 47 | "type": "cppvsdbg", 48 | "request": "launch", 49 | "program": "${command:cmake.launchTargetPath}", 50 | "args": [], 51 | "stopAtEntry": false, 52 | "cwd": "${workspaceFolder}", 53 | "environment": [ 54 | { 55 | "name": "PATH", 56 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 57 | } 58 | ], 59 | "externalConsole": true 60 | } 61 | ] 62 | } 63 | -------------------------------------------------------------------------------- /2_CMake/14_CPM/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "(gdb) Launch", 6 | "type": "cppdbg", 7 | "request": "launch", 8 | "program": "${command:cmake.launchTargetPath}", 9 | "args": [], 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "environment": [ 13 | { 14 | "name": "PATH", 15 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 16 | } 17 | ], 18 | "externalConsole": true, 19 | "MIMode": "gdb", 20 | "setupCommands": [ 21 | { 22 | "description": "Enable pretty-printing for gdb", 23 | "text": "-enable-pretty-printing", 24 | "ignoreFailures": true 25 | } 26 | ] 27 | }, 28 | { 29 | "name": "(lldb) Launch", 30 | "type": "cppdbg", 31 | "request": "launch", 32 | "program": "${command:cmake.launchTargetPath}", 33 | "args": [], 34 | "stopAtEntry": false, 35 | "cwd": "${workspaceFolder}", 36 | "environment": [ 37 | { 38 | "name": "PATH", 39 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 40 | } 41 | ], 42 | "externalConsole": true, 43 | "MIMode": "lldb" 44 | }, 45 | { 46 | "name": "(msvc) Launch", 47 | "type": "cppvsdbg", 48 | "request": "launch", 49 | "program": "${command:cmake.launchTargetPath}", 50 | "args": [], 51 | "stopAtEntry": false, 52 | "cwd": "${workspaceFolder}", 53 | "environment": [ 54 | { 55 | "name": "PATH", 56 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 57 | } 58 | ], 59 | "externalConsole": true 60 | } 61 | ] 62 | } 63 | -------------------------------------------------------------------------------- /2_CMake/10_UnitTest/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "(gdb) Launch", 6 | "type": "cppdbg", 7 | "request": "launch", 8 | "program": "${command:cmake.launchTargetPath}", 9 | "args": [], 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "environment": [ 13 | { 14 | "name": "PATH", 15 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 16 | } 17 | ], 18 | "externalConsole": true, 19 | "MIMode": "gdb", 20 | "setupCommands": [ 21 | { 22 | "description": "Enable pretty-printing for gdb", 23 | "text": "-enable-pretty-printing", 24 | "ignoreFailures": true 25 | } 26 | ] 27 | }, 28 | { 29 | "name": "(lldb) Launch", 30 | "type": "cppdbg", 31 | "request": "launch", 32 | "program": "${command:cmake.launchTargetPath}", 33 | "args": [], 34 | "stopAtEntry": false, 35 | "cwd": "${workspaceFolder}", 36 | "environment": [ 37 | { 38 | "name": "PATH", 39 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 40 | } 41 | ], 42 | "externalConsole": true, 43 | "MIMode": "lldb" 44 | }, 45 | { 46 | "name": "(msvc) Launch", 47 | "type": "cppvsdbg", 48 | "request": "launch", 49 | "program": "${command:cmake.launchTargetPath}", 50 | "args": [], 51 | "stopAtEntry": false, 52 | "cwd": "${workspaceFolder}", 53 | "environment": [ 54 | { 55 | "name": "PATH", 56 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 57 | } 58 | ], 59 | "externalConsole": true 60 | } 61 | ] 62 | } 63 | -------------------------------------------------------------------------------- /2_CMake/11_Warnings/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "(gdb) Launch", 6 | "type": "cppdbg", 7 | "request": "launch", 8 | "program": "${command:cmake.launchTargetPath}", 9 | "args": [], 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "environment": [ 13 | { 14 | "name": "PATH", 15 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 16 | } 17 | ], 18 | "externalConsole": true, 19 | "MIMode": "gdb", 20 | "setupCommands": [ 21 | { 22 | "description": "Enable pretty-printing for gdb", 23 | "text": "-enable-pretty-printing", 24 | "ignoreFailures": true 25 | } 26 | ] 27 | }, 28 | { 29 | "name": "(lldb) Launch", 30 | "type": "cppdbg", 31 | "request": "launch", 32 | "program": "${command:cmake.launchTargetPath}", 33 | "args": [], 34 | "stopAtEntry": false, 35 | "cwd": "${workspaceFolder}", 36 | "environment": [ 37 | { 38 | "name": "PATH", 39 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 40 | } 41 | ], 42 | "externalConsole": true, 43 | "MIMode": "lldb" 44 | }, 45 | { 46 | "name": "(msvc) Launch", 47 | "type": "cppvsdbg", 48 | "request": "launch", 49 | "program": "${command:cmake.launchTargetPath}", 50 | "args": [], 51 | "stopAtEntry": false, 52 | "cwd": "${workspaceFolder}", 53 | "environment": [ 54 | { 55 | "name": "PATH", 56 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 57 | } 58 | ], 59 | "externalConsole": true 60 | } 61 | ] 62 | } 63 | -------------------------------------------------------------------------------- /2_CMake/15_Conan/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "(gdb) Launch", 6 | "type": "cppdbg", 7 | "request": "launch", 8 | "program": "${command:cmake.launchTargetPath}", 9 | "args": [], 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "environment": [ 13 | { 14 | "name": "PATH", 15 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 16 | } 17 | ], 18 | "externalConsole": true, 19 | "MIMode": "gdb", 20 | "setupCommands": [ 21 | { 22 | "description": "Enable pretty-printing for gdb", 23 | "text": "-enable-pretty-printing", 24 | "ignoreFailures": true 25 | } 26 | ] 27 | }, 28 | { 29 | "name": "(lldb) Launch", 30 | "type": "cppdbg", 31 | "request": "launch", 32 | "program": "${command:cmake.launchTargetPath}", 33 | "args": [], 34 | "stopAtEntry": false, 35 | "cwd": "${workspaceFolder}", 36 | "environment": [ 37 | { 38 | "name": "PATH", 39 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 40 | } 41 | ], 42 | "externalConsole": true, 43 | "MIMode": "lldb" 44 | }, 45 | { 46 | "name": "(msvc) Launch", 47 | "type": "cppvsdbg", 48 | "request": "launch", 49 | "program": "${command:cmake.launchTargetPath}", 50 | "args": [], 51 | "stopAtEntry": false, 52 | "cwd": "${workspaceFolder}", 53 | "environment": [ 54 | { 55 | "name": "PATH", 56 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 57 | } 58 | ], 59 | "externalConsole": true 60 | } 61 | ] 62 | } 63 | -------------------------------------------------------------------------------- /2_CMake/16_VCPKG/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "(gdb) Launch", 6 | "type": "cppdbg", 7 | "request": "launch", 8 | "program": "${command:cmake.launchTargetPath}", 9 | "args": [], 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "environment": [ 13 | { 14 | "name": "PATH", 15 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 16 | } 17 | ], 18 | "externalConsole": true, 19 | "MIMode": "gdb", 20 | "setupCommands": [ 21 | { 22 | "description": "Enable pretty-printing for gdb", 23 | "text": "-enable-pretty-printing", 24 | "ignoreFailures": true 25 | } 26 | ] 27 | }, 28 | { 29 | "name": "(lldb) Launch", 30 | "type": "cppdbg", 31 | "request": "launch", 32 | "program": "${command:cmake.launchTargetPath}", 33 | "args": [], 34 | "stopAtEntry": false, 35 | "cwd": "${workspaceFolder}", 36 | "environment": [ 37 | { 38 | "name": "PATH", 39 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 40 | } 41 | ], 42 | "externalConsole": true, 43 | "MIMode": "lldb" 44 | }, 45 | { 46 | "name": "(msvc) Launch", 47 | "type": "cppvsdbg", 48 | "request": "launch", 49 | "program": "${command:cmake.launchTargetPath}", 50 | "args": [], 51 | "stopAtEntry": false, 52 | "cwd": "${workspaceFolder}", 53 | "environment": [ 54 | { 55 | "name": "PATH", 56 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 57 | } 58 | ], 59 | "externalConsole": true 60 | } 61 | ] 62 | } 63 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "(gdb) Launch", 6 | "type": "cppdbg", 7 | "request": "launch", 8 | "program": "${command:cmake.launchTargetPath}", 9 | "args": [], 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "environment": [ 13 | { 14 | "name": "PATH", 15 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 16 | } 17 | ], 18 | "externalConsole": true, 19 | "MIMode": "gdb", 20 | "setupCommands": [ 21 | { 22 | "description": "Enable pretty-printing for gdb", 23 | "text": "-enable-pretty-printing", 24 | "ignoreFailures": true 25 | } 26 | ] 27 | }, 28 | { 29 | "name": "(lldb) Launch", 30 | "type": "cppdbg", 31 | "request": "launch", 32 | "program": "${command:cmake.launchTargetPath}", 33 | "args": [], 34 | "stopAtEntry": false, 35 | "cwd": "${workspaceFolder}", 36 | "environment": [ 37 | { 38 | "name": "PATH", 39 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 40 | } 41 | ], 42 | "externalConsole": true, 43 | "MIMode": "lldb" 44 | }, 45 | { 46 | "name": "(msvc) Launch", 47 | "type": "cppvsdbg", 48 | "request": "launch", 49 | "program": "${command:cmake.launchTargetPath}", 50 | "args": [], 51 | "stopAtEntry": false, 52 | "cwd": "${workspaceFolder}", 53 | "environment": [ 54 | { 55 | "name": "PATH", 56 | "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" 57 | } 58 | ], 59 | "externalConsole": true 60 | } 61 | ] 62 | } 63 | -------------------------------------------------------------------------------- /2_CMake/12_Sanitizers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project(CppProjectTemplate VERSION 1.0.0 LANGUAGES C CXX) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | set(CMAKE_CXX_EXTENSIONS OFF) 8 | 9 | option(ENABLE_TESTING "Enable a Unit Testing Build" ON) 10 | 11 | option(ENABLE_WARNINGS "Enable compiler warnings for a target" ON) 12 | option(ENABLE_WARNINGS_AS_ERRORS "Enable compiler warnings as errors" OFF) 13 | 14 | option(ENABLE_SANITIZE_ADDR "Enable address sanitizer" ON) 15 | option(ENABLE_SANITIZE_UNDEF "Enable undefined sanitizer" ON) 16 | 17 | set(LIBRARY_NAME Library) 18 | set(EXECUTABLE_NAME Executable) 19 | 20 | set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") 21 | include(AddGitSubmodule) 22 | include(FetchContent) 23 | include(Docs) 24 | 25 | if(ENABLE_WARNINGS) 26 | include(Warnings) 27 | endif() 28 | 29 | if(ENABLE_SANITIZE_ADDR OR ENABLE_SANITIZE_UNDEF) 30 | include(Sanitizer) 31 | add_sanitizer_flags(ENABLE_SANITIZE_ADDR ENABLE_SANITIZE_UNDEF) 32 | endif() 33 | 34 | FetchContent_Declare( 35 | nlohmann_json 36 | GIT_REPOSITORY https://github.com/nlohmann/json 37 | GIT_TAG v3.11.3 38 | GIT_SHALLOW TRUE) 39 | FetchContent_MakeAvailable(nlohmann_json) 40 | 41 | FetchContent_Declare( 42 | fmt 43 | GIT_REPOSITORY https://github.com/fmtlib/fmt 44 | GIT_TAG 9.1.0 45 | GIT_SHALLOW TRUE) 46 | FetchContent_MakeAvailable(fmt) 47 | 48 | FetchContent_Declare( 49 | spdlog 50 | GIT_REPOSITORY https://github.com/gabime/spdlog 51 | GIT_TAG v1.13.0 52 | GIT_SHALLOW TRUE) 53 | FetchContent_MakeAvailable(spdlog) 54 | 55 | FetchContent_Declare( 56 | cxxopts 57 | GIT_REPOSITORY https://github.com/jarro2783/cxxopts 58 | GIT_TAG v3.1.1 59 | GIT_SHALLOW TRUE) 60 | FetchContent_MakeAvailable(cxxopts) 61 | 62 | if(ENABLE_TESTING) 63 | FetchContent_Declare( 64 | Catch2 65 | GIT_REPOSITORY https://github.com/catchorg/Catch2 66 | GIT_TAG v3.5.3 67 | GIT_SHALLOW TRUE) 68 | FetchContent_MakeAvailable(Catch2) 69 | list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras) 70 | endif() 71 | 72 | add_subdirectory(configured) 73 | add_subdirectory(external) 74 | add_subdirectory(src) 75 | add_subdirectory(app) 76 | if(ENABLE_TESTING) 77 | include(CTest) 78 | enable_testing() 79 | add_subdirectory(tests) 80 | endif() 81 | -------------------------------------------------------------------------------- /2_CMake/13_LTO/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | 3 | project( 4 | CppProjectTemplate 5 | VERSION 1.0.0 6 | LANGUAGES C CXX) 7 | 8 | set(CMAKE_CXX_STANDARD 17) 9 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 10 | set(CMAKE_CXX_EXTENSIONS OFF) 11 | 12 | option(ENABLE_TESTING "Enable a Unit Testing Build" ON) 13 | 14 | option(ENABLE_WARNINGS "Enable compiler warnings for a target" ON) 15 | option(ENABLE_WARNINGS_AS_ERRORS "Enable compiler warnings as errors" OFF) 16 | 17 | option(ENABLE_SANITIZE_ADDR "Enable address sanitizer" ON) 18 | option(ENABLE_SANITIZE_UNDEF "Enable undefined sanitizer" ON) 19 | 20 | option(ENABLE_LTO "Enable LTO/IPO" ON) 21 | 22 | set(LIBRARY_NAME Library) 23 | set(EXECUTABLE_NAME Executable) 24 | 25 | set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") 26 | include(AddGitSubmodule) 27 | include(FetchContent) 28 | include(Docs) 29 | 30 | if(ENABLE_WARNINGS) 31 | include(Warnings) 32 | endif() 33 | 34 | if(ENABLE_SANITIZE_ADDR OR ENABLE_SANITIZE_UNDEF) 35 | include(Sanitizer) 36 | add_sanitizer_flags(ENABLE_SANITIZE_ADDR ENABLE_SANITIZE_UNDEF) 37 | endif() 38 | 39 | if(ENABLE_LTO) 40 | include(LTO) 41 | endif() 42 | 43 | FetchContent_Declare( 44 | nlohmann_json 45 | GIT_REPOSITORY https://github.com/nlohmann/json 46 | GIT_TAG v3.11.3 47 | GIT_SHALLOW TRUE) 48 | FetchContent_MakeAvailable(nlohmann_json) 49 | 50 | FetchContent_Declare( 51 | fmt 52 | GIT_REPOSITORY https://github.com/fmtlib/fmt 53 | GIT_TAG 9.1.0 54 | GIT_SHALLOW TRUE) 55 | FetchContent_MakeAvailable(fmt) 56 | 57 | FetchContent_Declare( 58 | spdlog 59 | GIT_REPOSITORY https://github.com/gabime/spdlog 60 | GIT_TAG v1.13.0 61 | GIT_SHALLOW TRUE) 62 | FetchContent_MakeAvailable(spdlog) 63 | 64 | FetchContent_Declare( 65 | cxxopts 66 | GIT_REPOSITORY https://github.com/jarro2783/cxxopts 67 | GIT_TAG v3.1.1 68 | GIT_SHALLOW TRUE) 69 | FetchContent_MakeAvailable(cxxopts) 70 | 71 | if(ENABLE_TESTING) 72 | FetchContent_Declare( 73 | Catch2 74 | GIT_REPOSITORY https://github.com/catchorg/Catch2 75 | GIT_TAG v3.5.3 76 | GIT_SHALLOW TRUE) 77 | FetchContent_MakeAvailable(Catch2) 78 | list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras) 79 | endif() 80 | 81 | add_subdirectory(configured) 82 | add_subdirectory(external) 83 | add_subdirectory(src) 84 | add_subdirectory(app) 85 | if(ENABLE_TESTING) 86 | include(CTest) 87 | enable_testing() 88 | add_subdirectory(tests) 89 | endif() 90 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################################ 2 | ########### FILES ############ 3 | ################################ 4 | *.pptx 5 | CMakeUserPresets.json 6 | .mypy_cache 7 | 8 | ################################ 9 | ########### FOLDERS ############ 10 | ################################ 11 | build/ 12 | html/ 13 | 14 | ################################ 15 | ############ C/C++ ############# 16 | ################################ 17 | # Prerequisites 18 | *.d 19 | # Compiled Object files 20 | *.slo 21 | *.lo 22 | *.o 23 | *.obj 24 | *.ko 25 | *.elf 26 | # Precompiled Headers 27 | *.gch 28 | *.pch 29 | # Compiled Dynamic libraries 30 | *.so 31 | *.dylib 32 | *.dll 33 | # Fortran module files 34 | *.mod 35 | *.smod 36 | # Compiled Static libraries 37 | *.lai 38 | *.la 39 | *.a 40 | *.lib 41 | # Executables 42 | *.i*86 43 | *.x86_64 44 | *.hex 45 | *.app 46 | *.stackdump 47 | *.exe 48 | *.out 49 | # Linker output 50 | *.ilk 51 | *.map 52 | *.exp 53 | # Debug files 54 | *.dSYM/ 55 | *.su 56 | *.idb 57 | *.pdb 58 | 59 | ################################ 60 | ########### VS CODE ############ 61 | ################################ 62 | *.code-workspace 63 | .history 64 | 65 | ################################ 66 | ########### VS ############ 67 | ################################ 68 | 69 | # User-specific files 70 | *.rsuser 71 | *.suo 72 | *.user 73 | *.userosscache 74 | *.sln.docstates 75 | 76 | # User-specific files (MonoDevelop/Xamarin Studio) 77 | *.userprefs 78 | 79 | # Mono auto generated files 80 | mono_crash.* 81 | 82 | # Build results 83 | [Dd]ebug/ 84 | [Dd]ebugPublic/ 85 | [Rr]elease/ 86 | [Rr]eleases/ 87 | x64/ 88 | x86/ 89 | [Ww][Ii][Nn]32/ 90 | [Aa][Rr][Mm]/ 91 | [Aa][Rr][Mm]64/ 92 | bld/ 93 | [Bb]in/ 94 | [Oo]bj/ 95 | [Ll]og/ 96 | [Ll]ogs/ 97 | 98 | # Files built by Visual Studio 99 | *_i.c 100 | *_p.c 101 | *_h.h 102 | *.meta 103 | *.iobj 104 | *.ipdb 105 | *.pgc 106 | *.pgd 107 | *.rsp 108 | *.sbr 109 | *.tlb 110 | *.tli 111 | *.tlh 112 | *.tmp 113 | *.tmp_proj 114 | *_wpftmp.csproj 115 | *.log 116 | *.tlog 117 | *.vspscc 118 | *.vssscc 119 | .builds 120 | *.pidb 121 | *.svclog 122 | *.scc 123 | 124 | # Chutzpah Test files 125 | _Chutzpah* 126 | 127 | # Visual C++ cache files 128 | ipch/ 129 | *.aps 130 | *.ncb 131 | *.opendb 132 | *.opensdf 133 | *.sdf 134 | *.cachefile 135 | *.VC.db 136 | *.VC.VC.opendb 137 | 138 | # Visual Studio profiler 139 | *.psess 140 | *.vsp 141 | *.vspx 142 | *.sap 143 | 144 | # Visual Studio Trace Files 145 | *.e2e 146 | -------------------------------------------------------------------------------- /2_CMake/_Additional/GeneratorExpression/.gitignore: -------------------------------------------------------------------------------- 1 | ################################ 2 | ########### FILES ############ 3 | ################################ 4 | *.pptx 5 | CMakeUserPresets.json 6 | 7 | ################################ 8 | ########### FOLDERS ############ 9 | ################################ 10 | build/ 11 | html/ 12 | 13 | ################################ 14 | ############ C/C++ ############# 15 | ################################ 16 | # Prerequisites 17 | *.d 18 | # Compiled Object files 19 | *.slo 20 | *.lo 21 | *.o 22 | *.obj 23 | *.ko 24 | *.elf 25 | # Precompiled Headers 26 | *.gch 27 | *.pch 28 | # Compiled Dynamic libraries 29 | *.so 30 | *.dylib 31 | *.dll 32 | # Fortran module files 33 | *.mod 34 | *.smod 35 | # Compiled Static libraries 36 | *.lai 37 | *.la 38 | *.a 39 | *.lib 40 | # Executables 41 | *.i*86 42 | *.x86_64 43 | *.hex 44 | *.app 45 | *.stackdump 46 | *.exe 47 | *.out 48 | # Linker output 49 | *.ilk 50 | *.map 51 | *.exp 52 | # Debug files 53 | *.dSYM/ 54 | *.su 55 | *.idb 56 | *.pdb 57 | 58 | ################################ 59 | ########### VS CODE ############ 60 | ################################ 61 | .vscode 62 | *.code-workspace 63 | .history 64 | 65 | ################################ 66 | ########### VS ############ 67 | ################################ 68 | 69 | # User-specific files 70 | *.rsuser 71 | *.suo 72 | *.user 73 | *.userosscache 74 | *.sln.docstates 75 | 76 | # User-specific files (MonoDevelop/Xamarin Studio) 77 | *.userprefs 78 | 79 | # Mono auto generated files 80 | mono_crash.* 81 | 82 | # Build results 83 | [Dd]ebug/ 84 | [Dd]ebugPublic/ 85 | [Rr]elease/ 86 | [Rr]eleases/ 87 | x64/ 88 | x86/ 89 | [Ww][Ii][Nn]32/ 90 | [Aa][Rr][Mm]/ 91 | [Aa][Rr][Mm]64/ 92 | bld/ 93 | [Bb]in/ 94 | [Oo]bj/ 95 | [Ll]og/ 96 | [Ll]ogs/ 97 | 98 | # Files built by Visual Studio 99 | *_i.c 100 | *_p.c 101 | *_h.h 102 | *.meta 103 | *.iobj 104 | *.ipdb 105 | *.pgc 106 | *.pgd 107 | *.rsp 108 | *.sbr 109 | *.tlb 110 | *.tli 111 | *.tlh 112 | *.tmp 113 | *.tmp_proj 114 | *_wpftmp.csproj 115 | *.log 116 | *.tlog 117 | *.vspscc 118 | *.vssscc 119 | .builds 120 | *.pidb 121 | *.svclog 122 | *.scc 123 | 124 | # Chutzpah Test files 125 | _Chutzpah* 126 | 127 | # Visual C++ cache files 128 | ipch/ 129 | *.aps 130 | *.ncb 131 | *.opendb 132 | *.opensdf 133 | *.sdf 134 | *.cachefile 135 | *.VC.db 136 | *.VC.VC.opendb 137 | 138 | # Visual Studio profiler 139 | *.psess 140 | *.vsp 141 | *.vspx 142 | *.sap 143 | 144 | # Visual Studio Trace Files 145 | *.e2e 146 | --------------------------------------------------------------------------------