We will construct the CMakeLists.txt step by step and show how to require a certain standard (in this case C++14):
- We state the minimum required CMake version, project name, and language:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)project(recipe-09 LANGUAGES CXX)
- We request all library symbols to be exported on Windows:
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
- We need to add a target for the library. This will compile the sources into a shared library:
add_library(animals SHARED Animal.cpp Animal.hpp Cat.cpp Cat.hpp Dog.cpp Dog.hpp Factory.hpp )
- We now set the CXX_STANDARD, CXX_EXTENSIONS, and CXX_STANDARD_REQUIRED properties for the target. We also set the POSITION_INDEPENDENT_CODE property, to avoid issues when ...