Template set up with basic infrastructure for C++ projects
Necessary build tools are:
- CMake 3.27 or higher
- Conan 2.26 or higher
- One of supported compilers:
- Clang-22 (libstdc++ or libc++)
- GCC-15
- Visual Studio 2022 (MSVC v194)
- Ninja (if using Clang on Windows)
Supported architecture for cross compilation is Linux AArch64 with one of following compilers:
- GCC-14
- Clang-22 (libstdc++ or libc++)
Note that the compilation flags assume ARM Cortex-A76. Which can be changed in corresponding Conan profiles.
conan install . --profile=conan/clang-22-libstdcxx-amd64-linux --build=missing --settings build_type=Release
- Predefined conan profiles for supported compilers are located in
conanfolder - Conan build types:
Release,RelWithDebInfo,Debug
cmake --preset release
cmake --build --preset release
Disable building of tests by:
- Adding
--conf tools.build:skip_test=Truetoconan installcommand - Adding
-DBUILD_TESTING=OFFduring CMake configure
Building of tests is enabled by default. Execute the tests with the following command:
ctest --preset release
Use the preset matching the build type used when installing dependencies.
When compiling with MSVC or using some other multi configuration generator use
multi-debug, multi-relwithdebinfo or multi-release presets.
Enable running clang-format automatically on all source files during build by
adding -DCST_ENABLE_CLANG_FORMAT=ON during CMake configure. This option is
disabled by default.
Enable toolchain security hardening compiler options, by adding an additional
profile to the conan install command, together with --build=* to recompile
dependencies with hardening enabled. Also enable CMAKE_POSITION_INDEPENDENT_CODE
variable during CMake configure. Toolchain hardening options should only be used
with Release or RelWithDebInfo build types. This option is disabled by default.
conan install . --profile=conan/clang-22-libstdcxx-amd64-linux --profile=conan/opt/clang-amd64-linux-hardening --profile=conan/opt/gnulike-libstdcxx-hardening --build=* --settings build_type=Release
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON --preset release
Predefined toolchain hardening profiles are located in conan/opt:
clang-amd64-linux-hardeninggcc-amd64-linux-hardeningclang-amd64-windows-hardeningmsvc-amd64-windows-hardeninggcc-aarch64-linux-hardeningclang-aarch64-linux-hardening
When compiling with Clang or GCC on Linux also on select the standard library hardening profile:
gnulike-libcxx-hardeninggnulike-libstdcxx-hardening
Use the predefined hardening profile together with the matching compiler profile from conan folder.
Enable link time optimization compiler options, by adding an additional
profile to the conan install command, together with --build=* to recompile
dependencies with link time optimization enabled. Also enable CMAKE_INTERPROCEDURAL_OPTIMIZATION
variable during CMake configure. Link time optimization should only be used
with Release or RelWithDebInfo build types. This option is disabled by default.
conan install . --profile=conan/clang-22-libstdcxx-amd64-linux --profile=conan/opt/gnulike-lto --build=* --settings build_type=Release
cmake -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON --preset release
Predefined link time optimization profiles are located in conan/opt:
gnulike-ltomsvc-amd64-windows-ltoclang-amd64-windows-lto
Enable sanitizers by adding an additional profile to the conan install command,
together with --build=* to recompile dependencies with santizers enabled. Sanitizers
should only be used with Releaseor RelWithDebInfo build types. These options are disabled by default.
conan install . --profile=conan/clang-22-libstdcxx-amd64-linux --profile=conan/opt/gnulike-address-sanitizer --build=* --settings build_type=Release
- Conan profiles for
ClangandGCCsanitizers are:gnulike-address-sanitizer,gnulike-leak-sanitizer,gnulike-thread-sanitizer,gnulike-undefined-sanitizer- Thread sanitizer cannot be used in combination with any other sanitizer
- Conan profile for
MSVCcompiler is:msvc-amd64-windows-address-sanitizer- Run the compiled executables from the developer command prompt, or execute
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64to correctly set up search paths for runtime libraries
- Run the compiled executables from the developer command prompt, or execute
Enable use of non-default linker by adding an additional profile to the conan install conmmand,
together with --build=* to recompile dependencies with the alternative linker.
conan install . --profile=conan/clang-22-libstdcxx-amd64-linux --profile=conan/opt/gnulike-mold --build=* --settings build_type=Release
Predefined alternative linkers are located in conan/opt:
gnulike-moldgnulike-lld
Enable running clang-tidy automatically on all source files during build by
adding -DCST_ENABLE_CLANG_TIDY=ON during CMake configure. This option is
disabled by default.
Enable compiler flags for static analysis during build by adding -DCST_ENABLE_COMPILER_STATIC_ANALYSIS=ON
during CMake configure. This option is disabled by default.
- Compiler static analysis is supported for
GCCandMSVCcompilers
Enable running of include-what-you-use automatically on all source files during
build by adding -DCST_ENABLE_IWYU=ON during CMake configure. This option is
disabled by default.
Enable running of cppcheck automatically on all source files during build by
adding -DCST_ENABLE_CPPCHECK=ON during CMake configure. This option is disabled
by default.