We have four CMakeLists.txt instances to look at: one root and tree leaves. Let us start with the root CMakeLists.txt:
- We declare a mixed-language Fortran and C project:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)project(recipe-01 LANGUAGES Fortran C)
- We direct CMake to save static and shared libraries under the lib subdirectory of the build directory. Executables will be saved under bin, while Fortran compiled module files will be saved under modules:
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/modules) ...