# Minimum CMake version. cmake_minimum_required (VERSION 2.8.5) # Adjust CMake's module path. list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules") # ############################################################################ # # Compiler Definition Warnings # ############################################################################ # if ( NOT CMAKE_C_COMPILER ) message(WARNING "C compiler not specified. CMake will guess!") endif() if ( NOT CMAKE_Fortran_COMPILER ) message(WARNING "Fortran compiler not specified. CMake will guess!") endif() # Set compilers. This must be done before enabling languages. message("-- C compiler is ${CMAKE_C_COMPILER}") message("-- Fortran compiler is ${CMAKE_Fortran_COMPILER}") # Tell CMake we want Fortran and C. enable_language(Fortran) enable_language(C) # This gets around a bug in the Intel compiler when limits.h is included. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GCC_LIMITS_H_") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp") if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -fpp -r8 -i4 -debug all -check all -check noarg_temp_created -zero -qopenmp") set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS} -fpp -r8 -i4 -O3 -free -CB -diag-disable 8291 -zero -qopenmp") else () set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEUBG} -cpp -fdefault-real-8 -fdefault-double-8 -fno-align-commons -Wuninitialized -ftrapv -fcheck=bounds -fcheck=do -fcheck=mem -fcheck=pointer -fcheck=recursion -fstack-check -fbacktrace -finit-local-zero -fopenmp") set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS} -cpp -O2 -fdefault-real-8 -fdefault-double-8 -fno-align-commons -finit-local-zero -fopenmp") if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "10") set(CMAKE_Fortran_FLAGS_DEBUG "-fallow-argument-mismatch") set(CMAKE_Fortran_FLAGS_RELEASE "-fallow-argument-mismatch") endif() endif() # Project. This needs to go underneath the MPI stuff to avoid # infinite loops. project (toughlib C CXX Fortran) set(TOUGHLIB_SOURCE_DIR ${PROJECT_SOURCE_DIR}) if (NOT DEFINED TPL_INSTALL_PREFIX) set(TPL_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/tpls) endif () if (NOT DEFINED TPL_BUILD_TYPE) set(TPL_BUILD_TYPE "Release") endif () # Figure out MPI. OPTION(USE_MPI "USE_MPI." FALSE) if (USE_MPI) # CC and CXX should already have been set in Makefile or wherever. add_definitions(-DUSE_MPI) set(MPIEXEC mpirun) set(MPIEXEC_NUMPROC_FLAG -np) endif() # Set up all third-party libraries. OPTION(BUILD_TPLS "BUILD_TPLS." TRUE) if (USE_MPI) else () if (USE_PETSC) set (USE_PETSC FALSE) endif() endif() if (USE_PETSC) add_definitions(-DUSE_PETSC) endif() if (BUILD_TPLS) add_subdirectory(tpls) #else(BUILD_TPLS) if (USE_PETSC) list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/petsc_cmake) message("-- The inputed petsc installation directory is: ${PETSC_DIRi}") message("-- The inputed petsc installation arch is: ${PETSC_ARCHi}") SET(PETSC_DIR ${PETSC_DIRi}) SET(PETSC_ARCH ${PETSC_ARCHi}) # SET(PETSC_DIR "/home/keniz/petsc-3.7.4") # SET(PETSC_ARCH arch-linux2-c-debug) find_package(PETSc) endif (USE_PETSC) endif (BUILD_TPLS) set(TOUGHLIB_TPL_INCLUDE_DIR ${TPL_INSTALL_PREFIX}/include ${TPL_INSTALL_PREFIX}/conf) set(TOUGHLIB_TPL_LIB_DIR ${TPL_INSTALL_PREFIX}/lib) OPTION(IMPLICIT_BLASLAPACK "Don't specify blas and lapack directly" false) if (USE_MPI) if (IMPLICIT_BLASLAPACK) set(TOUGH_TPL_LIB ) else () set(TOUGH_TPL_LIB lapack.a blas.a) endif (IMPLICIT_BLASLAPACK) set(TOUGHLIB_TPL_LIB parmetis.a aztec.a ${TOUGHLIB_TPL_LIB} ) else () endif() # Header files go here. include_directories( ${PROJECT_SOURCE_DIR}/src ${TOUGHLIB_TPL_INCLUDE_DIR} ${PETSC_INCLUDES}) link_directories( ${TOUGHLIB_TPL_LIB_DIR}) # Source subdirectories. add_subdirectory(src) # We use CMake's testing system. # enable_testing() # add_subdirectory(tests)