We shall start out with the C++ example before moving on to the Fortran example:
- In the CMakeLists.txt file, we define the now familiar minimum version, project name, and supported language:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)project(recipe-03 LANGUAGES CXX)
- We then define the executable target and its corresponding source file:
add_executable(hello-world hello-world.cpp)
- Then we let the preprocessor know about the compiler name and vendor by defining the following target compile definitions:
target_compile_definitions(hello-world PUBLIC "COMPILER_NAME=\"${CMAKE_CXX_COMPILER_ID}\"")if(CMAKE_CXX_COMPILER_ID MATCHES Intel) target_compile_definitions(hello-world PUBLIC "IS_INTEL_CXX_COMPILER")endif()if(CMAKE_CXX_COMPILER_ID ...