Creating a simple library
Creating a library works similarly to creating an executable, although there are a few additional things to consider since library targets are usually used by other targets, either in the same project or by other projects. Since libraries usually have an internal part and a publicly visible API, we must take this into account when adding files to the project.
A simple project for a library will look like this:
cmake_minimum_required(VERSION 3.21) project( ch3.hello_lib VERSION 1.0 DESCRIPTION "A simple C++ project to demonstrate creating executables and libraries in CMake" LANGUAGES CXX) add_library(hello) target_sources( hello PRIVATE src/hello.cpp src/internal.cpp) target_compile_features(hello PUBLIC cxx_std_17) target_include_directories( hello PRIVATE src/hello PUBLIC...