cmake_minimum_required(VERSION 3.0) project(RMT Fortran) # Global output directories set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") # Create directory to house all compiled module files set(CMAKE_Fortran_MODULE_DIRECTORY "mod") # Set extra compiler warnings if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O2 -ftz -fpe0 -mp1 -mkl -lpthread -limf -debug inline-debug-info -traceback -warn -save-temps" ) elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wall -Wextra") elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Cray") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O3") endif() # Set up OpenMP (if required) option(WITH_OPENMP "Compile with support for OpenMP." ON) if (WITH_OPENMP) find_package(OpenMP) if (${OpenMP_FOUND}) add_definitions(${OpenMP_Fortran_FLAGS}) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}") endif (${OpenMP_FOUND}) endif (WITH_OPENMP) # Set static library links (for cray compiler) if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Cray") set(CMAKE_EXE_LINKER_FLAGS -static) SET(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS -static) endif() ################################################################################ #ARCHER handles library linking automatically, otherwise find the necessary libraries cmake_host_system_information(RESULT machine_name QUERY HOSTNAME) if (NOT ${machine_name} MATCHES "eslogin*") # Set up LAPACK if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") enable_language(C) find_package(LAPACK REQUIRED) endif() # Set up MKL if required if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") set(MKL_USE_STATIC_LIBS ON) set(MKL_MULTI_THREADED ON) list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}") find_package(MKL REQUIRED) set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) endif() endif() ################################################################################# # Setup docs with doxygen # first we can indicate the documentation build as an option and set it to ON by default option(BUILD_DOC "Build documentation" ON) # check if Doxygen is installed if (BUILD_DOC) find_package(Doxygen) if (DOXYGEN_FOUND) # set input and output files set(DOXYGEN_OUT ${CMAKE_CURRENT_LIST_DIR}/../docs/Doxyfile) # note the option ALL which allows to build the docs together with the application add_custom_target( doc_doxygen ALL COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../docs COMMENT "Generating documentation with Doxygen" VERBATIM ) else (DOXYGEN_FOUND) message("Doxygen needs to be installed to generate the doxygen documentation") endif (DOXYGEN_FOUND) endif (BUILD_DOC) ################################################################################# # Recurse into subdirectories add_subdirectory(modules) add_subdirectory(programs)