Now that we have the sources in place, our goal will be to configure the project and experiment with compiler flags:
- We set the minimum required version of CMake:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
- We declare the name of the project and the language:
project(recipe-08 LANGUAGES CXX)
- Then, we print the current set of compiler flags. CMake will use these for all C++ targets:
message("C++ compiler flags: ${CMAKE_CXX_FLAGS}")
- We prepare a list of flags for our targets. Some of these will not be available on Windows and we make sure to account for that case:
list(APPEND flags "-fPIC" "-Wall")if(NOT WIN32) list(APPEND flags "-Wextra" "-Wpedantic")endif()
- We add a new target, the geometry library and list its source ...