Liebe Gitlab-Nutzer, lieber Gitlab-Nutzer, es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Ein Anmelden über dieses erzeugt ein neues Konto. Das alte Konto ist über den Reiter "Standard" erreichbar. Die Administratoren

Dear Gitlab user, it is now possible to log in to our service using the ZIH login/LDAP. Logging in via this will create a new account. The old account can be accessed via the "Standard" tab. The administrators

Commit 49fb3404 authored by Simon praetorius's avatar Simon praetorius
Browse files

cmake 2.8 configuration adopted to cmake3

parent b80bc058
This diff is collapsed.
#This configuration file is shipped with the great FEM-Toolbox AMDiS.
#It simplifies the configure of different amdis-version and sets some variables.
#We set the following variables:
# AMDIS_INCLUDE_DIR the amdis-directory only
# AMDIS_INCLUDE_DIRS all include directories (mtl, umfpack, parmetis, metis, ...)
# AMDIS_LIBRARIES the needed libraries
# AMDIS_LIBRARY_DIRS the link directories
# AMDiS_COMPILEFLAGS some compile flags for amdis
#
#
# For a fast start, you use this package in the following way
# simply look for it, possibly set the AMDiS directory
# find_package(AMDiS )
# include(${AMDIS_USE_FILE})
# add_executable(yourTarget <yourSources>)
# target_link_libraries(yourTarget ${AMDIS_LIBRARIES})
#
#
#The AMDIS_USE_FILE adds the include and link-directories for amdis to cmake.
#
#If you use the parallel amdis-version, the AMDIS_USE_FILE also trys to detect
#the mpi and petsc configuration. If those versions don't fit your needs,
#you can change the corresponding directories, or simply do this work at your own
#and omit the AMDIS_USE_FILE. Then you also have to set the flags, include
#and library directories.
################## ONLY WORKAROUND AND WARNING ###################
#if(NOT "$ENV{LIBRARY_PATH}" STREQUAL "")
# message(WARNING "the environment variable LIBRARY_PATH is set. this can lead to problems during linking. \n You can unset it in your CMakeLists.txt with the command unset(ENV{LIBRARY_PATH}).\n")
#endif()
##################################################################
# try to detect the AMDiS include directory
# -------------------------------------------
find_file(_AMDIS_H AMDiS.h PATHS ${AMDIS_INCLUDE_DIR} ${AMDIS_DIR}/../../include/amdis/ /usr/include/amdis/)
if(_AMDIS_H)
get_filename_component(AMDIS_INCLUDE_DIR ${_AMDIS_H} PATH CACHE)
set(AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR})
else()
message(ERROR "could not detect the AMDiS include directory. Please set the variable AMDIS_INCLUDE_DIR to the directory containing the AMDiS headers.")
endif()
unset(_AMDIS_H CACHE)
# set(MTL_DIR @MTL_INCLUDE_DIR@ CACHE PATH "the mtl directory")
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/mtl4)
# AMDiS base libraries
# --------------------
find_library(_AMDIS_LIB amdis PATHS ${AMDIS_LIBRARY_DIR} ${AMDIS_DIR}/../../lib/amdis/ /usr/include/amdis)
if(_AMDIS_LIB)
get_filename_component(AMDIS_LIBRARY_DIR ${_AMDIS_LIB} PATH CACHE)
set(AMDIS_LIBRARY_DIRS ${AMDIS_LIBRARY_DIR})
set(AMDIS_LIBRARIES "${_AMDIS_LIB}" CACHE STRING "amdis libraries")
else()
message(ERROR "could not detect the AMDiS library directory. Please set the variable AMDIS_LIBRARY_DIR to the directory containg the AMDiS library")
endif()
unset(_AMDIS_LIB CACHE)
# Boost libraries
# ---------------
set(AMDIS_HAS_PARALLEL_DOMAIN @ENABLE_PARALLEL_DOMAIN@)
set(AMDIS_NEED_COMPRESSION @ENABLE_COMPRESSION@)
set(BOOST_LIBS_REQUIRED system iostreams filesystem program_options date_time)
if(WIN32)
list(APPEND BOOST_LIBS_REQUIRED zlib)
if (AMDIS_NEED_COMPRESSION)
list(APPEND BOOST_LIBS_REQUIRED bzip2)
endif ()
endif()
set(BOOST_VERSION "1.42")
if(AMDIS_HAS_PARALLEL_DOMAIN)
set(BOOST_VERSION "1.48")
endif(AMDIS_HAS_PARALLEL_DOMAIN)
if(WIN32)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost ${BOOST_VERSION} REQUIRED ${BOOST_LIBS_REQUIRED})
else()
set(Boost_USE_STATIC_LIBS OFF)
find_package(Boost ${BOOST_VERSION} REQUIRED ${BOOST_LIBS_REQUIRED})
endif()
if(Boost_FOUND)
list(APPEND AMDIS_LIBRARIES ${Boost_LIBRARIES})
list(APPEND AMDIS_LIBRARY_DIRS ${Boost_LIBRARY_DIRS})
list(APPEND AMDIS_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
else()
message(ERROR "Boost libraries not found")
endif(Boost_FOUND)
# more libraries and include-directories added by default
# -------------------------------------------------------
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/reinit)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/compositeFEM)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/muparser)
# ------------------------------------------------------------------
set(AMDIS_NEED_ZOLTAN @ENABLE_ZOLTAN@)
set(AMDIS_OPENMP @ENABLE_OPENMP@)
set(AMDIS_NEED_CXX11 @ENABLE_CXX11@)
set(AMDIS_NEED_UMFPACK @ENABLE_UMFPACK@)
set(AMDIS_NEED_HYPRE @ENABLE_HYPRE@)
set(AMDIS_NEED_SEQ_PETSC @ENABLE_SEQ_PETSC@)
set(AMDIS_NEED_PNG @ENABLE_PNG@)
set(AMDIS_NEED_BDDCML @ENABLE_BDDCML@)
set(AMDIS_NEED_MKL @ENABLE_MKL@)
set(AMDIS_NEED_EXTENSIONS @ENABLE_EXTENSIONS@)
set(AMDIS_NEED_BASE_PROBLEMS @ENABLE_BASE_PROBLEMS@)
set(AMDIS_USE_FILE ${AMDIS_DIR}/AMDISUse.cmake)
set(AMDIS_COMPILEFLAGS "@COMPILEFLAGS@")
set(AMDIS_VERSION @CurrentRevision@)
set(AMDIS_MAJOR_VERSION @AMDIS_MAJOR@)
set(AMDIS_MINOR_VERSION @AMDIS_MINOR@)
set(AMDIS_SUB_MINOR_VERSION @AMDIS_SUB_MINOR@)
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release")
endif()
include(cmake/enable_petsc.cmake)
if (AMDIS_HAS_PARALLEL_DOMAIN OR AMDIS_NEED_SEQ_PETSC)
enable_mpi(AMDIS_COMPILEFLAGS AMDIS_INCLUDE_DIRS AMDIS_LIBRARIES ON)
enable_petsc(AMDIS_COMPILEFLAGS AMDIS_INCLUDE_DIRS AMDIS_LIBRARIES ON)
endif()
if(AMDIS_NEED_HYPRE)
find_package(HYPRE REQUIRED HINTS ${AMDIS_DIR})
if(HAVE_HYPRE)
enable_mpi(AMDIS_COMPILEFLAGS AMDIS_INCLUDE_DIRS AMDIS_LIBRARIES ON)
list(APPEND AMDIS_INCLUDE_DIRS ${HYPRE_INCLUDE_DIRECTORIES})
list(APPEND AMDIS_COMPILEFLAGS "-DMTL_HAS_HYPRE")
list(APPEND AMDIS_LIBRARIES ${HYPRE_LIBRARIES} )
endif()
endif(AMDIS_NEED_HYPRE)
if(AMDIS_OPENMP)
if(CMAKE_CXX_COMPILER MATCHES ".*icpc")
list(APPEND AMDIS_COMPILEFLAGS "-openmp")
list(APPEND AMDIS_LIBRARIES "-openmp")
else()
list(APPEND AMDIS_COMPILEFLAGS "-fopenmp")
list(APPEND AMDIS_LIBRARIES "-fopenmp")
endif()
endif(AMDIS_OPENMP)
# AMDiS-Extensions library
# ------------------------
if(AMDIS_NEED_EXTENSIONS)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/extensions)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/extensions/time)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/extensions/nanoflann)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/extensions/pugixml)
find_library(_EXTENSIONS_LIB extensions PATHS ${AMDIS_LIBRARY_DIR} ${AMDIS_DIR}/../../lib/amdis/)
if(_EXTENSIONS_LIB)
list(APPEND AMDIS_LIBRARIES ${_EXTENSIONS_LIB})
endif()
unset(_EXTENSIONS_LIB CACHE)
endif(AMDIS_NEED_EXTENSIONS)
# AMDiS BaseProblems libraries
# ----------------------------
if(AMDIS_NEED_BASE_PROBLEMS)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/base_problems)
find_library(_BASE_PROBLEMS_LIB base_problems PATHS ${AMDIS_LIBRARY_DIR} ${AMDIS_DIR}/../../lib/amdis/)
if(_BASE_PROBLEMS_LIB)
list(APPEND AMDIS_LIBRARIES ${_BASE_PROBLEMS_LIB})
endif()
unset(_BASE_PROBLEMS_LIB CACHE)
endif(AMDIS_NEED_BASE_PROBLEMS)
# ----------------------------
find_library(_REINIT_LIB reinit PATHS ${AMDIS_LIBRARY_DIR} ${AMDIS_DIR}/../../lib/amdis/)
find_library(_COMPOSITE_FEM_LIB compositeFEM PATHS ${AMDIS_LIBRARY_DIR} ${AMDIS_DIR}/../../lib/amdis/)
find_library(_MUPARSER_LIB muparser PATHS ${AMDIS_LIBRARY_DIR} ${AMDIS_DIR}/../../lib/amdis/)
if(_REINIT_LIB)
list(APPEND AMDIS_LIBRARIES ${_REINIT_LIB})
else()
message(ERROR "Reinit library not found")
endif()
unset(_REINIT_LIB CACHE)
if(_COMPOSITE_FEM_LIB)
list(APPEND AMDIS_LIBRARIES ${_COMPOSITE_FEM_LIB})
else()
message(ERROR "CompositeFEM library not found")
endif()
unset(_COMPOSITE_FEM_LIB CACHE)
if(_MUPARSER_LIB)
list(APPEND AMDIS_LIBRARIES ${_MUPARSER_LIB})
else()
message(ERROR "MuParser library not found")
endif()
unset(_MUPARSER_LIB CACHE)
# ----------------------------
if(AMDIS_NEED_UMFPACK)
if (WIN32)
set(SuiteSparse_USE_LAPACK_BLAS ON)
endif (WIN32)
find_package(SuiteSparse QUIET)
if (SuiteSparse_FOUND)
include(${USE_SuiteSparse})
list(APPEND AMDIS_LIBRARIES ${SuiteSparse_LIBRARIES})
list(APPEND AMDIS_INCLUDE_DIRS ${SuiteSparse_INCLUDE_DIR} ${SuiteSparse_METIS_INCLUDE_DIR})
message("AMDIS_INCLUDE_DIRS = ${AMDIS_INCLUDE_DIRS}")
else (SuiteSparse_FOUND)
set(AMDIS_UMFPACK_PATH @UMFPACK_PATH@)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_UMFPACK_PATH})
find_library(UMFPACK_LIB umfpack
HINTS ENV LIBRARY_PATH
DOC "The UMFPACK library")
if(UMFPACK_LIB)
list(APPEND AMDIS_LIBRARIES ${UMFPACK_LIB})
else()
message(FATAL_ERROR "Could not find the UMFPACK library")
endif()
if("$ENV{BLA_VENDOR}" STREQUAL "ACML")
find_library(ACML_LIBRARY acml HINTS ENV ACML_LIB)
if(ACML_LIBRARY)
list(APPEND AMDIS_LIBRARIES ${ACML_LIBRARY}) #fortran ffio m rt) #needed for open64
else()
message(FATAL_ERROR "could not find the acml libraries, required by acml blas")
endif(ACML_LIBRARY)
else()
find_library(BLAS_LIBRARY NAMES "blas" "goto" "mkl"
HINTS ENV MKL_LIB
DOC "The BLAS library")
if(BLAS_LIBRARY)
list(APPEND AMDIS_LIBRARIES ${BLAS_LIBRARY})
list(APPEND AMDIS_LIBRARY_DIRS ${BLAS_LIBRARY_DIR})
else()
find_package(BLAS)
if(BLAS_FOUND)
list(APPEND AMDIS_LIBRARIES ${BLAS_LIBRARIES})
else()
message(STATUS "Could not find the BLAS library. Please set the variable BLAS_LIBRARY to the blas library with full path")
endif()
endif()
endif("$ENV{BLA_VENDOR}" STREQUAL "ACML")
find_library(AMD_LIB amd
HINTS ENV LIBRARY_PATH
DOC "The AMD library")
if(AMD_LIB)
list(APPEND AMDIS_LIBRARIES ${AMD_LIB})
else()
message(FATAL_ERROR "Could not find the AMD library.")
endif()
#check for if we need cholmod
set(_CHOLMOD_TEST_DIR ${CMAKE_BINARY_DIR}/CMakeFiles/cholmodTest/)
file(WRITE ${_CHOLMOD_TEST_DIR}/CMakeLists.txt "project(cholmodTest)
cmake_minimum_required(VERSION 2.8)
include_directories(${AMDIS_INCLUDE_DIRS})
add_executable(cholmodTest cholmodTest.cpp)
target_link_libraries(cholmodTest ${AMDIS_LIBRARIES})")
file(WRITE ${_CHOLMOD_TEST_DIR}/cholmodTest.cpp "#include <stdio.h>
#include \"umfpack.h\"
int n = 5 ;
int Ap [ ] = {0, 2, 5, 9, 10, 12} ;
int Ai [ ] = { 0, 1, 0, 2, 4, 1, 2, 3, 4, 2, 1, 4} ;
double Ax [ ] = {2., 3., 3., -1., 4., 4., -3., 1., 2., 2., 6., 1.} ;
double b [ ] = {8., 45., -3., 3., 19.} ;
double x [5] ;
int main (void)
{
double *null = (double *) NULL ;
int i ;
void *Symbolic, *Numeric ;
double stats [2];
umfpack_tic (stats);
(void) umfpack_di_symbolic (n, n, Ap, Ai, Ax, &Symbolic, null, null) ;
(void) umfpack_di_numeric (Ap, Ai, Ax, Symbolic, &Numeric, null, null) ;
umfpack_di_free_symbolic (&Symbolic) ;
(void) umfpack_di_solve (UMFPACK_A, Ap, Ai, Ax, x, b, Numeric, null, null) ;
umfpack_di_free_numeric (&Numeric) ;
umfpack_toc (stats);
return (0) ;
}")
# "#include <umfpack.h>
# int main(int , char* argv[]) { double c[UMFPACK_CONTROL]; umfpack_dl_defaults(c); return 0;}")
try_compile(CHOLMOD_TEST ${_CHOLMOD_TEST_DIR}/build ${_CHOLMOD_TEST_DIR} cholmodTest
OUTPUT_VARIABLE CHOLMOD_OUT)
if(NOT CHOLMOD_TEST)
file(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "cholmodTest-output: \n ${CHOLMOD_OUT}")
find_library(CHOLMOD_LIB cholmod)
find_library(COLAMD_LIB colamd)
if(CHOLMOD_LIB)
list(APPEND AMDIS_LIBRARIES ${CHOLMOD_LIB})
else()
message(FATAL_ERROR "your umfpack seems to need cholmod, but cmake could not find it")
endif()
if(COLAMD_LIB)
list(APPEND AMDIS_LIBRARIES ${COLAMD_LIB})
else()
message(FATAL_ERROR "your umfpack seems to need colamd, but cmake could not find it")
endif()
#test with cholmod and colamd..
file(WRITE ${_CHOLMOD_TEST_DIR}/CMakeLists.txt "project(cholmodTest)
cmake_minimum_required(VERSION 2.8)
include_directories(${AMDIS_INCLUDE_DIRS})
add_executable(cholmodTest cholmodTest.cpp)
target_link_libraries(cholmodTest ${AMDIS_LIBRARIES})")
try_compile(CHOLMOD_TEST2 ${_CHOLMOD_TEST_DIR}/build ${_CHOLMOD_TEST_DIR} cholmodTest
OUTPUT_VARIABLE CHOLMOD_OUT)
if(NOT CHOLMOD_TEST2)
file(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "cholmodTest2-output: \n ${CHOLMOD_OUT}")
find_library(SUITESPARSECONFIG_LIB suitesparseconfig)
if(SUITESPARSECONFIG_LIB)
list(APPEND AMDIS_LIBRARIES ${SUITESPARSECONFIG_LIB})
else()
message(STATUS "your umfpack seems to need suitesparseconfig, but cmake could not find it")
endif()
endif()
endif()
endif ()
endif(AMDIS_NEED_UMFPACK)
# PNG library
# -----------
if(AMDIS_NEED_PNG)
set(AMDIS_PNG_PATH @PNG_PATH@)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_PNG_PATH})
find_library(PNG_LIB png
HINTS ENV LIBRARY_PATH
DOC "The PNG library")
if(PNG_LIB)
list(APPEND AMDIS_LIBRARIES ${PNG_LIB})
else()
message(FATAL_ERROR "Could not find the PNG library")
endif()
endif(AMDIS_NEED_PNG)
# BDDCML-library
# --------------
if(AMDIS_NEED_BDDCML)
set(AMDIS_BDDCML_PATH @BDDCML_PATH@)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_BDDCML_PATH})
set(AMDIS_BDDCML_LIB @BDDCML_LIB@)
list(APPEND AMDIS_LIBRARIES ${AMDIS_BDDCML_LIB})
set(AMDIS_BDDCML_LINK_LIST @BDDCML_LINK_LIST@)
list(APPEND AMDIS_LIBRARIES ${AMDIS_BDDCML_LINK_LIST})
endif(AMDIS_NEED_BDDCML)
# Zoltan library
# --------------
if(AMDIS_NEED_ZOLTAN)
find_library(ZOLTAN_LIB zoltan
HINTS ENV LIBRARY_PATH
DOC "full path to the zoltan library")
if(ZOLTAN_LIB)
list(APPEND AMDIS_LIBRARIES ${ZOLTAN_LIB})
else()
message(FATAL_ERROR "Could not find zoltan library!")
endif()
endif()
if(${AMDIS_FIND_COMPONENTS} MATCHES umfpack )
if(NOT AMDIS_NEED_UMFPACK)
set(AMDIS_umfpack_FOUND FALSE)
message(SEND_ERROR "The selected amdis was not compiled with umfpack")
endif()
endif()
# globally add compile options and include directories
# globally add compile options and include directories
add_definitions(${AMDIS_COMPILEFLAGS})
include_directories(${AMDIS_INCLUDE_DIRS})
This diff is collapsed.
This diff is collapsed.
# CorrectWindowsPaths - this module defines one macro
#
# CONVERT_CYGWIN_PATH( PATH )
# This uses the command cygpath (provided by cygwin) to convert
# unix-style paths into paths useable by cmake on windows
macro (CONVERT_CYGWIN_PATH _path)
if (WIN32)
EXECUTE_PROCESS(COMMAND cygpath.exe -m ${${_path}}
OUTPUT_VARIABLE ${_path})
string (STRIP ${${_path}} ${_path})
endif (WIN32)
endmacro (CONVERT_CYGWIN_PATH)
# - Try to find PETSc
# Once done this will define
# source: https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake
#
# PETSC_FOUND - system has PETSc
# PETSC_INCLUDES - the PETSc include directories
......@@ -10,8 +9,10 @@
# PETSC_MPIEXEC - Executable for running MPI programs
# PETSC_VERSION - Version string (MAJOR.MINOR.SUBMINOR)
#
# Hack: PETSC_VERSION currently decides on the version based on the
# layout. Otherwise we need to run C code to determine the version.
# Usage:
# find_package(PETSc COMPONENTS CXX) - required if build --with-clanguage=C++ --with-c-support=0
# find_package(PETSc COMPONENTS C) - standard behavior of checking build using a C compiler
# find_package(PETSc) - same as above
#
# Setting these changes the behavior of the search
# PETSC_DIR - directory in which PETSc resides
......@@ -21,6 +22,31 @@
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
set(PETSC_VALID_COMPONENTS
C
CXX)
if(NOT PETSc_FIND_COMPONENTS)
set(PETSC_LANGUAGE_BINDINGS "C")
else()
# Right now, this is designed for compatability with the --with-clanguage option, so
# only allow one item in the components list.
list(LENGTH ${PETSc_FIND_COMPONENTS} components_length)
if(${components_length} GREATER 1)
message(FATAL_ERROR "Only one component for PETSc is allowed to be specified")
endif()
# This is a stub for allowing multiple components should that time ever come. Perhaps
# to also test Fortran bindings?
foreach(component ${PETSc_FIND_COMPONENTS})
list(FIND PETSC_VALID_COMPONENTS ${component} component_location)
if(${component_location} EQUAL -1)
message(FATAL_ERROR "\"${component}\" is not a valid PETSc component.")
else()
list(APPEND PETSC_LANGUAGE_BINDINGS ${component})
endif()
endforeach()
endif()
function (petsc_get_version)
if (EXISTS "${PETSC_DIR}/include/petscversion.h")
file (STRINGS "${PETSC_DIR}/include/petscversion.h" vstrings REGEX "#define PETSC_VERSION_(RELEASE|MAJOR|MINOR|SUBMINOR|PATCH) ")
......@@ -43,12 +69,20 @@ function (petsc_get_version)
endfunction ()
find_path (PETSC_DIR include/petsc.h
HINTS ENV PETSC_DIR
HINTS /usr/lib/petsc ENV PETSC_DIR
PATHS
/usr/lib/petscdir/3.1 /usr/lib/petscdir/3.0.0 /usr/lib/petscdir/2.3.3 /usr/lib/petscdir/2.3.2 # Debian
# Debian paths
/usr/lib/petscdir/3.5.1 /usr/lib/petscdir/3.5
/usr/lib/petscdir/3.4.2 /usr/lib/petscdir/3.4
/usr/lib/petscdir/3.3 /usr/lib/petscdir/3.2 /usr/lib/petscdir/3.1
/usr/lib/petscdir/3.0.0 /usr/lib/petscdir/2.3.3 /usr/lib/petscdir/2.3.2
# MacPorts path
/opt/local/lib/petsc
$ENV{HOME}/petsc
DOC "PETSc Directory")
find_program (MAKE_EXECUTABLE NAMES make gmake)
if (PETSC_DIR AND NOT PETSC_ARCH)
set (_petsc_arches
$ENV{PETSC_ARCH} # If set, use environment variable first
......@@ -58,11 +92,11 @@ if (PETSC_DIR AND NOT PETSC_ARCH)
foreach (arch ${_petsc_arches})
if (NOT PETSC_ARCH)
find_path (petscconf petscconf.h
HINTS ${PETSC_DIR}
PATH_SUFFIXES ${arch}/include bmake/${arch}
NO_DEFAULT_PATH)
HINTS ${PETSC_DIR}
PATH_SUFFIXES ${arch}/include bmake/${arch}
NO_DEFAULT_PATH)
if (petscconf)
set (PETSC_ARCH "${arch}" CACHE STRING "PETSc build architecture")
set (PETSC_ARCH "${arch}" CACHE STRING "PETSc build architecture")
endif (petscconf)
endif (NOT PETSC_ARCH)
endforeach (arch)
......@@ -78,7 +112,10 @@ find_package_multipass (PETSc petsc_config_current
# Determine whether the PETSc layout is old-style (through 2.3.3) or
# new-style (>= 3.0.0)
if (EXISTS "${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h") # > 2.3.3
if (EXISTS "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/petscvariables") # > 3.5
set (petsc_conf_rules "${PETSC_DIR}/lib/petsc/conf/rules")
set (petsc_conf_variables "${PETSC_DIR}/lib/petsc/conf/variables")
elseif (EXISTS "${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h") # > 2.3.3
set (petsc_conf_rules "${PETSC_DIR}/conf/rules")
set (petsc_conf_variables "${PETSC_DIR}/conf/variables")
elseif (EXISTS "${PETSC_DIR}/bmake/${PETSC_ARCH}/petscconf.h") # <= 2.3.3
......@@ -87,9 +124,10 @@ elseif (EXISTS "${PETSC_DIR}/bmake/${PETSC_ARCH}/petscconf.h") # <= 2.3.3
elseif (PETSC_DIR)
message (SEND_ERROR "The pair PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} do not specify a valid PETSc installation")
endif ()
petsc_get_version()
if (petsc_conf_rules AND petsc_conf_variables AND NOT petsc_config_current)
petsc_get_version()
# Put variables into environment since they are needed to get
# configuration (petscvariables) in the PETSc makefile
set (ENV{PETSC_DIR} "${PETSC_DIR}")
......@@ -104,12 +142,12 @@ if (petsc_conf_rules AND petsc_conf_variables AND NOT petsc_config_current)
include ${petsc_conf_rules}
include ${petsc_conf_variables}
show :
-@echo -n \${\${VARIABLE}}
\t-@echo -n \${\${VARIABLE}}
")
macro (PETSC_GET_VARIABLE name var)
set (${var} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE)
execute_process (COMMAND ${CMAKE_MAKE_PROGRAM} --no-print-directory -f ${petsc_config_makefile} show VARIABLE=${name}
execute_process (COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} show VARIABLE=${name}
OUTPUT_VARIABLE ${var}
RESULT_VARIABLE petsc_return)
endmacro (PETSC_GET_VARIABLE)
......@@ -118,6 +156,7 @@ show :
petsc_get_variable (PETSC_CCPPFLAGS petsc_cpp_line)
petsc_get_variable (PETSC_INCLUDE petsc_include)
petsc_get_variable (PCC petsc_cc)
petsc_get_variable (PCC_FLAGS petsc_cc_flags)
petsc_get_variable (MPIEXEC petsc_mpiexec)
# We are done with the temporary Makefile, calling PETSC_GET_VARIABLE after this point is invalid!
file (REMOVE ${petsc_config_makefile})
......@@ -126,11 +165,39 @@ show :
# Extract include paths and libraries from compile command line
resolve_includes (petsc_includes_all "${petsc_cpp_line}")
#on windows we need to make sure we're linking against the right
#runtime library
if (WIN32)
if (petsc_cc_flags MATCHES "-MT")
set(using_md False)
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
set(using_md True)
endif(${flag_var} MATCHES "/MD")
endforeach(flag_var)
if(${using_md} MATCHES "True")
message(WARNING "PETSc was built with /MT, but /MD is currently set.
See http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F")
endif(${using_md} MATCHES "True")
endif (petsc_cc_flags MATCHES "-MT")
endif (WIN32)
include (CorrectWindowsPaths)
convert_cygwin_path(petsc_lib_dir)
message (STATUS "petsc_lib_dir ${petsc_lib_dir}")
macro (PETSC_FIND_LIBRARY suffix name)
set (PETSC_LIBRARY_${suffix} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # Clear any stale value, if we got here, we need to find it again
find_library (PETSC_LIBRARY_${suffix} NAMES ${name} HINTS ${petsc_lib_dir} NO_DEFAULT_PATH)
if (WIN32)
set (libname lib${name}) #windows expects "libfoo", linux expects "foo"
else (WIN32)
set (libname ${name})
endif (WIN32)
find_library (PETSC_LIBRARY_${suffix} NAMES ${libname} HINTS ${petsc_lib_dir} NO_DEFAULT_PATH)
set (PETSC_LIBRARIES_${suffix} "${PETSC_LIBRARY_${suffix}}")
mark_as_advanced (PETSC_LIBRARY_${suffix})
endmacro (PETSC_FIND_LIBRARY suffix name)
......@@ -167,29 +234,42 @@ show :
message (STATUS "Recognized PETSc install with single library for all packages")
endif ()
include (CheckCSourceRuns)
include(Check${PETSC_LANGUAGE_BINDINGS}SourceRuns)
macro (PETSC_TEST_RUNS includes libraries runs)
multipass_c_source_runs ("${includes}" "${libraries}" "
if(${PETSC_LANGUAGE_BINDINGS} STREQUAL "C")
set(_PETSC_ERR_FUNC "CHKERRQ(ierr)")
elseif(${PETSC_LANGUAGE_BINDINGS} STREQUAL "CXX")
set(_PETSC_ERR_FUNC "CHKERRXX(ierr)")
endif()
if (PETSC_VERSION VERSION_GREATER 3.1)
set (_PETSC_TSDestroy "TSDestroy(&ts)")
else ()
set (_PETSC_TSDestroy "TSDestroy(ts)")
endif ()
set(_PETSC_TEST_SOURCE "
static const char help[] = \"PETSc test program.\";
#include \"petscts.h\"
#include <petscts.h>
int main(int argc,char *argv[]) {
PetscErrorCode ierr;
TS ts;