Skip to content

Latest commit

 

History

History

Chapter05

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Software Architecture with C++, Second Edition

Software Architecture with C++, Second Edition, Published by Packt

Chapter 5: Leveraging C++ Language Features

Prerequisites

Install the following software:

  • CMake 3.28
  • Conan 2.11.0
  • GCC 14
  • Ninja 1.12

CMake 3.28: Generator Support

The list of generators which support scanning sources for C++ modules include:

  • Ninja
  • Ninja Multi-Config
  • Visual Studio 17 2022

Assuming you're on Linux or using WSL, configure a local Conan profile and remotes by running:

rm -rf ./build/
conan profile detect --name ./build/conan_profile

Make sure that the profile section [settings] contains:

arch=x86_64
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=14
os=Linux

Building

To build the project, configure the Conan profile as described above, cd to its directory, and then run:

cd build
conan install .. --build=missing -s build_type=Release -pr:a=./conan_profile -of .
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release # build type must match Conan's
cmake --build .

If GCC 14 is not your default compiler, you can tell CMake to use it with the CMAKE_CXX_COMPILER flag:

cd build
conan install .. --build=missing -s build_type=Release -pr:a=./conan_profile -of .
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=`which g++-14` # build type must match Conan's
cmake --build .

To pass the settings directly without a Conan profile, use the command line option --settings:all or -s:a, and the keys arch, build_type, compiler, compiler.cppstd, compiler.libcxx, compiler.version, os:

rm -rf ./build/ && mkdir build && cd build
conan install .. --build=missing -s:a build_type=Release -s:a compiler=gcc -of .
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release # build type must match Conan's
cmake --build .