Our CMakeLists.txt for the C++ and Fortran examples will follow a template that is largely similar between the two languages:
- Both define a minimum CMake version, project name, and language (CXX or Fortran; we will show the C++ version):
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)project(recipe-05 LANGUAGES CXX)
- For the C++ example, we require the C++11 standard:
set(CMAKE_CXX_STANDARD 11)set(CMAKE_CXX_EXTENSIONS OFF)set(CMAKE_CXX_STANDARD_REQUIRED ON)
- Both call find_package to search for OpenMP:
find_package(OpenMP REQUIRED)
- Finally, we define the executable target and link to the imported target provided by the FindOpenMP module (in the Fortran case, we link against OpenMP::OpenMP_Fortran):
add_executable(example ...