/** * @file CMakeLists.txt * * @brief * * @copyright * Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne) * SPC (Swiss Plasma Center) * * spclibs is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) * any later version. * * spclibs is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * @authors * (in alphabetical order) * @author Nicolas Richart * @author Trach-Minh Tran */ cmake_minimum_required (VERSION 2.8.8) #cmake_policy(SET CMP0053 NEW) project(bsplines_root Fortran C) #enable_language(Fortran) enable_testing() option(BSPLINES_USE_MUMPS "Activate the mumps interface" ON) if(NOT DEFINED BSPLINES_EXAMPLES) option(BSPLINES_EXAMPLES "Compiles the examples" ON) endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") # Assume we are on CRAY if ftn is the Fortran compiler if (${CMAKE_Fortran_COMPILER} MATCHES "ftn$") set(CRAY TRUE) if(${CMAKE_Fortran_COMPILER_ID} MATCHES "Cray") set(cray_suffix cray) elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI") set(cray_suffix pgi) elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "Intel") set(cray_suffix intel) elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU") set(cray_suffix gnu) endif() else() set(CRAY FALSE) endif() if(POLICY CMP0074) cmake_policy(SET CMP0074 NEW) endif() include(CMakeFlagsHandling) # Compiler flags for debug/optimization if(${CMAKE_Fortran_COMPILER_ID} MATCHES "Cray") elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "Intel") set(CMAKE_AR ${XIAR}) add_flags(LANG Fortran TYPE DEBUG -traceback "-check bounds" "-warn unused") add_flags(LANG Fortran TYPE RELEASE -xHost) elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU") add_flags(LANG Fortran TYPE DEBUG -fbounds-check -fbacktrace) endif() if(NOT MUMPS) set(MUMPS $ENV{MUMPS_ROOT}) endif() # Installation root directory if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(PREFIX $ENV{PREFIX}) if(PREFIX) set(${CMAKE_INSTALL_PREFIX} ${PREFIX}) else() set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "..." FORCE) endif() message(STATUS "CMAKE_INSTALL_PREFIX is " ${CMAKE_INSTALL_PREFIX}) endif() # Search and load the FUTILS configuration file if(NOT TARGET futils) find_package(futils PATHS ${FUTILS}/lib/cmake REQUIRED) endif() if(BSPLINES_USE_MUMPS) find_package(Mumps REQUIRED) set(HAS_MUMPS ${MUMPS_FOUND}) else() set(HAS_MUMPS FALSE) endif() # Find lapack/blas. Skip it if on CRAY! if(CRAY) set(BSPLINES_USE_PARDISO OFF) endif() include(blas) if(NOT BSPLINES_EXPORT_TARGETS) set(BSPLINES_EXPORT_TARGETS bsplines-targets) endif() find_package(MPI COMPONENTS Fortran REQUIRED) include(GNUInstallDirs) add_subdirectory(pppack) add_subdirectory(pputils2) add_subdirectory(fft) add_subdirectory(src) if(HAS_MUMPS AND BSPLINES_EXAMPLES) add_subdirectory(multigrid) endif() if(BSPLINES_EXAMPLES) add_subdirectory(examples) add_subdirectory(wk) endif() export(TARGETS pppack pputils2 bsplines fft FILE "${CMAKE_BINARY_DIR}/bsplinesLibraryDepends.cmake") export(PACKAGE bsplines) # install configuration files if(BSPLINES_EXPORT_TARGETS MATCHES "bsplines-targets") install(EXPORT bsplines-targets DESTINATION lib/cmake ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bsplines-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/bsplines-config.cmake @ONLY ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/bsplines-config.cmake DESTINATION lib/cmake ) endif() # enable packaging with CPack include(CPack)