Commit 866968b0 authored by Praetorius, Simon's avatar Praetorius, Simon

Merge branch 'issue/cmake_configuration' into 'master'

Issue/cmake configuration

rewritten several cmake files to be more compatible with several linux distributions

See merge request !8
parents d272ab51 379e8d5c
Pipeline #580 canceled with stage
in 0 seconds
...@@ -2,12 +2,9 @@ set(CMAKE_LEGACY_CYGWIN_WIN32 0) ...@@ -2,12 +2,9 @@ set(CMAKE_LEGACY_CYGWIN_WIN32 0)
cmake_minimum_required(VERSION 2.8 FATAL_ERROR) cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(AMDiS) project(AMDiS)
if (USE_NEW_CMAKE AND ${CMAKE_VERSION} VERSION_GREATER "3.2") if (${CMAKE_VERSION} VERSION_GREATER "3.2")
# Experimental implementation of new CMakeLists.txt include(${AMDiS_SOURCE_DIR}/cmake3/CMakeLists.txt)
# Can be selected by calling cmake -DUSE_NEW_CMAKE=ON .
# Use only if you know what you are doing :-)
include(${AMDiS_SOURCE_DIR}/cmake3/CMakeLists.txt)
else () else ()
# By defualt the classical CMakeLists file ist used # Fallback to classical CMakeLists file
include(${AMDiS_SOURCE_DIR}/cmake/CMakeLists.txt) include(${AMDiS_SOURCE_DIR}/cmake/CMakeLists.txt)
endif () endif ()
...@@ -157,11 +157,23 @@ endif (AMDIS_NEED_CXX11) ...@@ -157,11 +157,23 @@ endif (AMDIS_NEED_CXX11)
#load mpi-compiler for use with parmetis and parallel_domain #load mpi-compiler for use with parmetis and parallel_domain
if(AMDIS_HAS_PARALLEL_DOMAIN) if(AMDIS_HAS_PARALLEL_DOMAIN)
find_package(MPI REQUIRED) find_package(MPI REQUIRED)
if(MPI_FOUND) list(APPEND AMDIS_LIBRARIES ${MPI_LIBRARIES})
list(APPEND AMDIS_LIBRARIES ${MPI_LIBRARIES}) list(APPEND AMDIS_COMPILEFLAGS ${MPI_COMPILE_FLAGS})
list(APPEND AMDIS_COMPILEFLAGS ${MPI_COMPILE_FLAGS}) list(APPEND AMDIS_INCLUDE_DIRS ${MPI_INCLUDE_PATH})
list(APPEND AMDIS_INCLUDE_DIRS ${MPI_INCLUDE_PATH})
endif(MPI_FOUND) find_library(PARMETIS_LIB parmetis)
if(PARMETIS_LIB)
list(APPEND AMDIS_LIBRARIES ${PARMETIS_LIB})
else(PARMETIS_LIB)
message(FATAL_ERROR "could not find the parmetis libraries needed by amdis")
endif(PARMETIS_LIB)
find_library(METIS_LIB metis)
if(METIS_LIB)
list(APPEND AMDIS_LIBRARIES ${METIS_LIB})
else(METIS_LIB)
message(FATAL_ERROR "could not find the metis libraries needed by amdis")
endif(METIS_LIB)
if(AMDIS_HAS_PARALLEL_DOMAIN STREQUAL "PETSC") if(AMDIS_HAS_PARALLEL_DOMAIN STREQUAL "PETSC")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${AMDIS_DIR}) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${AMDIS_DIR})
set(PETSC_EXECUTABLE_RUNS ON) set(PETSC_EXECUTABLE_RUNS ON)
...@@ -175,18 +187,6 @@ if(AMDIS_HAS_PARALLEL_DOMAIN) ...@@ -175,18 +187,6 @@ if(AMDIS_HAS_PARALLEL_DOMAIN)
elseif(AMDIS_HAS_PARALLEL_DOMAIN STREQUAL "PMTL") elseif(AMDIS_HAS_PARALLEL_DOMAIN STREQUAL "PMTL")
find_package(MTL REQUIRED) find_package(MTL REQUIRED)
list(APPEND AMDIS_LIBRARIES ${MTL_LIBRARIES}) list(APPEND AMDIS_LIBRARIES ${MTL_LIBRARIES})
find_library(PARMETIS_LIB parmetis)
if(PARMETIS_LIB)
list(APPEND AMDIS_LIBRARIES ${PARMETIS_LIB})
else(PARMETIS_LIB)
message(FATAL_ERROR "could not find the parmetis libraries needed by amdis")
endif(PARMETIS_LIB)
find_library(METIS_LIB metis)
if(METIS_LIB)
list(APPEND AMDIS_LIBRARIES ${METIS_LIB})
else(METIS_LIB)
message(FATAL_ERROR "could not find the metis libraries needed by amdis")
endif(METIS_LIB)
endif() endif()
elseif(AMDIS_NEED_SEQ_PETSC) elseif(AMDIS_NEED_SEQ_PETSC)
......
#thats bad because it affects each target # globally add compile options and include directories
add_definitions(${AMDIS_COMPILEFLAGS}) add_definitions(${AMDIS_COMPILEFLAGS})
include_directories(${AMDIS_INCLUDE_DIRS}) include_directories(${AMDIS_INCLUDE_DIRS})
...@@ -25,12 +25,12 @@ SET(MTL_INCLUDE_DIR ${LIB_DIR}/mtl4/ CACHE PATH "mtl4 directory") ...@@ -25,12 +25,12 @@ SET(MTL_INCLUDE_DIR ${LIB_DIR}/mtl4/ CACHE PATH "mtl4 directory")
# #message("svn-rev: ${svn_info_WC_REVISION}") # #message("svn-rev: ${svn_info_WC_REVISION}")
# set(AMDIS_SUB_MINOR "${svn_info_WC_REVISION}") # set(AMDIS_SUB_MINOR "${svn_info_WC_REVISION}")
# endif() # endif()
set(CurrentRevision "0.9") set(CurrentRevision "1.1")
if(NOT AMDIS_MAJOR) if(NOT AMDIS_MAJOR)
set(AMDIS_MAJOR "0") set(AMDIS_MAJOR "1")
endif() endif()
if(NOT AMDIS_MINOR) if(NOT AMDIS_MINOR)
set(AMDIS_MINOR "9") set(AMDIS_MINOR "1")
endif() endif()
list(APPEND COMPILEFLAGS "-DAMDIS_VERSION=${CurrentRevision}") list(APPEND COMPILEFLAGS "-DAMDIS_VERSION=${CurrentRevision}")
......
# enable the c++11 features. From cmake version 3.0 this is simply done by setting include(CheckCXXCompilerFlag)
# the cxx_standard variables. For older cmake version the compile-flags must be added manually. include(CheckCXXSourceCompiles)
include(CheckIncludeFileCXX)
if (ENABLE_CXX11) if (ENABLE_CXX11)
list(APPEND COMPILEFLAGS "-DHAS_CXX11=1") check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11_FLAG)
if (${CMAKE_VERSION} VERSION_GREATER "3.0")
set(CMAKE_CXX_STANDARD 11) set(CXX11_CODE "
set(CMAKE_CXX_STANDARD_REQUIRED ON) #include <array>
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") # cmake can not detect intel compile features #include <tuple>
set(REQUIRED_CXX_FEATURES "cxx_alias_templates" "cxx_auto_type" "cxx_lambdas" "cxx_override" "cxx_range_for" "cxx_static_assert" "cxx_variadic_templates") template <class... T> using A = std::tuple<T...>;
int main(){
decltype(1) vec[]={1,2,3};
for(auto&& x:vec);
}")
if (COMPILER_SUPPORTS_CXX11_FLAG)
set(CMAKE_REQUIRED_FLAGS "-std=c++11")
check_cxx_source_compiles("${CXX11_CODE}" CXX11_COMPILES_WITH_CXX11_FLAG)
set(CMAKE_REQUIRED_FLAGS "")
endif ()
if (COMPILER_SUPPORTS_CXX11_FLAG AND CXX11_COMPILES_WITH_CXX11_FLAG)
add_definitions("-std=c++11")
else ()
check_cxx_source_compiles("${CXX11_CODE}" CXX11_COMPILES)
if (NOT CXX11_COMPILES)
message (FATAL_ERROR "Compiler does not support C++11.")
endif ()
endif ()
add_library(test_compiler_features cmake/dummy.cc) list(APPEND COMPILEFLAGS "-DHAS_CXX11=1")
foreach(feature ${REQUIRED_CXX_FEATURES})
target_compile_features(test_compiler_features PUBLIC ${feature})
endforeach(feature)
endif ()
else()
if (CMAKE_COMPILER_IS_GNUCXX)
set(GXX_MIN_VER "4.8")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS GXX_MIN_VER)
message (FATAL_ERROR "For C++11-Features the G++ Compiler must be at least version $GXX_MIN_VER")
endif ()
list(APPEND COMPILEFLAGS "-std=gnu++11")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CLANG_MIN_VER "3.0")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS CLANG_MIN_VER)
message (FATAL_ERROR "For C++11-Features the Clang Compiler must be at least version $CLANG_MIN_VER")
endif ()
list(APPEND COMPILEFLAGS "-std=c++11")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(INTEL_MIN_VER "12.1")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS INTEL_MIN_VER)
message (FATAL_ERROR "For C++11-Features the Intel C++ Compiler must be at least version $INTEL_MIN_VER")
endif ()
list(APPEND COMPILEFLAGS "-std=c++11")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(MSVC_MIN_VER "12.0")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS MSVC_MIN_VER)
message (FATAL_ERROR "For C++11-Features the MSVC C++ Compiler must be at least version $MSVC_MIN_VER")
endif ()
endif ()
endif()
else () else ()
list(APPEND COMPILEFLAGS "-DHAS_CXX11=0") list(APPEND COMPILEFLAGS "-DHAS_CXX11=0")
endif (ENABLE_CXX11) endif (ENABLE_CXX11)
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
# target_link_libraries(yourTarget AMDiS) # target_link_libraries(yourTarget AMDiS)
# #
if (${CMAKE_VERSION} VERSION_LESS "3.0") if (${CMAKE_VERSION} VERSION_LESS "3.2")
message(FATAL_ERROR "The Configuration file was created for CMake version >= 3.0") message(FATAL_ERROR "The Configuration file was created for CMake version >= 3.2")
endif () endif ()
list(APPEND CMAKE_MODULE_PATH ${AMDIS_DIR}) list(APPEND CMAKE_MODULE_PATH ${AMDIS_DIR})
...@@ -36,14 +36,16 @@ set(AMDIS_NEED_COMPOSITE_FEM @ENABLE_COMPOSITE_FEM@) ...@@ -36,14 +36,16 @@ set(AMDIS_NEED_COMPOSITE_FEM @ENABLE_COMPOSITE_FEM@)
set(BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@) set(BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
set(CMAKE_BUILD_TYPE @CMAKE_BUILD_TYPE@) set(CMAKE_BUILD_TYPE @CMAKE_BUILD_TYPE@)
include(FindPkgConfig)
add_library(amdis_base INTERFACE) add_library(amdis_base INTERFACE)
add_library(AMDiS ALIAS amdis_base) add_library(AMDiS ALIAS amdis_base)
target_compile_definitions(amdis_base INTERFACE) target_compile_definitions(amdis_base INTERFACE)
if (AMDIS_NEED_CXX11) if (AMDIS_NEED_CXX11)
set(CMAKE_CXX_STANDARD 11) include(test_compile_features)
set(CMAKE_CXX_STANDARD_REQUIRED ON) target_enable_cxx11(AMDIS_NEED_CXX11 amdis_base INTERFACE)
target_compile_definitions(amdis_base INTERFACE HAS_CXX11=1) target_compile_definitions(amdis_base INTERFACE HAS_CXX11=1)
else () else ()
target_compile_definitions(amdis_base INTERFACE HAS_CXX11=0) target_compile_definitions(amdis_base INTERFACE HAS_CXX11=0)
...@@ -82,7 +84,8 @@ endif (NOT BOOST_ROOT) ...@@ -82,7 +84,8 @@ endif (NOT BOOST_ROOT)
if (NOT BOOST_LIBRARYDIR) if (NOT BOOST_LIBRARYDIR)
set(BOOST_LIBRARYDIR @BOOST_LIBRARYDIR@) set(BOOST_LIBRARYDIR @BOOST_LIBRARYDIR@)
endif (NOT BOOST_LIBRARYDIR) endif (NOT BOOST_LIBRARYDIR)
include(find_boost) include(target_enable_boost)
target_enable_boost(amdis_base INTERFACE ON)
# umfpack library # umfpack library
# -------------------- # --------------------
...@@ -90,7 +93,8 @@ if (AMDIS_NEED_UMFPACK) ...@@ -90,7 +93,8 @@ if (AMDIS_NEED_UMFPACK)
set(AMDIS_SuiteSparse_DIR @SuiteSparse_DIR@) set(AMDIS_SuiteSparse_DIR @SuiteSparse_DIR@)
set(AMDIS_UMFPACK_INCLUDE_DIR @UMFPACK_INCLUDE_DIRS@) set(AMDIS_UMFPACK_INCLUDE_DIR @UMFPACK_INCLUDE_DIRS@)
set(AMDIS_UMFPACK_LIB_DIR ${AMDIS_UMFPACK_INCLUDE_DIR}/../include) set(AMDIS_UMFPACK_LIB_DIR ${AMDIS_UMFPACK_INCLUDE_DIR}/../include)
include(find_umfpack) include(target_enable_umfpack)
target_enable_umfpack(amdis_base INTERFACE ON)
endif (AMDIS_NEED_UMFPACK) endif (AMDIS_NEED_UMFPACK)
...@@ -100,27 +104,9 @@ if (AMDIS_HAS_PARALLEL_DOMAIN) ...@@ -100,27 +104,9 @@ if (AMDIS_HAS_PARALLEL_DOMAIN)
target_compile_definitions(amdis_base INTERFACE target_compile_definitions(amdis_base INTERFACE
HAVE_PARALLEL_DOMAIN_AMDIS=1) HAVE_PARALLEL_DOMAIN_AMDIS=1)
find_package(MPI REQUIRED) include(target_enable_petsc)
if (MPI_FOUND) target_enable_mpi(amdis_base INTERFACE ON)
target_include_directories(amdis_base INTERFACE ${MPI_INCLUDE_PATH}) target_enable_petsc(amdis_base INTERFACE ON)
target_compile_options(amdis_base INTERFACE ${MPI_COMPILE_FLAGS})
target_link_libraries(amdis_base INTERFACE ${MPI_LIBRARIES})
endif (MPI_FOUND)
set(PETSC_EXECUTABLE_RUNS ON)
set(AMDIS_PETSC_DIR @PETSC_DIR@)
include(find_petsc)
if (PETSc_FOUND)
target_include_directories(amdis_base INTERFACE ${PETSC_INCLUDES})
target_link_libraries(amdis_base INTERFACE
${PETSC_LIBRARY_SYS}
${PETSC_LIBRARIES}
blas lapack)
target_compile_definitions(amdis_base INTERFACE
HAVE_PARALLEL_PETSC=1)
else()
message(FATAL_ERROR "Could not find PETSc!")
endif (PETSc_FOUND)
endif (AMDIS_HAS_PARALLEL_DOMAIN) endif (AMDIS_HAS_PARALLEL_DOMAIN)
...@@ -188,12 +174,19 @@ unset(_MUPARSER_LIB CACHE) ...@@ -188,12 +174,19 @@ unset(_MUPARSER_LIB CACHE)
# Zoltan library # Zoltan library
# -------------- # --------------
if (AMDIS_NEED_ZOLTAN) if (AMDIS_NEED_ZOLTAN)
find_library(ZOLTAN_LIB zoltan HINTS ENV LIBRARY_PATH DOC "Full path to the zoltan library") include(target_enable_zoltan)
if (ZOLTAN_LIB) target_enable_zoltan(amdis_base INTERFACE ON)
target_link_libraries(amdis_base INTERFACE ${ZOLTAN_LIB})
else()
message(FATAL_ERROR "Could not find zoltan library!")
endif()
endif () endif ()
set(AMDIS_LIBRARIES AMDiS) # Extract some variables from INTERFACE target AMDiS
get_target_property(AMDIS_INCLUDE_DIRS AMDiS INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(AMDIS_LIBRARIES AMDiS INTERFACE_LINK_LIBRARIES)
get_target_property(AMDIS_COMPILEFLAGS AMDiS INTERFACE_COMPILE_OPTIONS)
if (NOT AMDIS_COMPILEFLAGS)
set(AMDIS_COMPILEFLAGS "")
endif()
get_target_property(_DEFINITIONS AMDiS INTERFACE_COMPILE_DEFINITIONS)
foreach(defn ${_DEFINITIONS})
list(APPEND AMDIS_COMPILEFLAGS "-D${defn}")
endforeach(defn)
message(STATUS "To compile your program with AMDiS simply add the target 'AMDiS' to the target_link_libraries(...) command") # globally add compile options and include directories
\ No newline at end of file add_definitions(${AMDIS_COMPILEFLAGS})
include_directories(${AMDIS_INCLUDE_DIRS})
cmake_minimum_required(VERSION 3.2 FATAL_ERROR) cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(AMDiS VERSION 0.9 LANGUAGES CXX) project(AMDiS VERSION 1.1 LANGUAGES CXX)
message(WARNING "This is an experimental CMakeLists.txt file.")
set(BASE_DIR ${AMDiS_SOURCE_DIR}) set(BASE_DIR ${AMDiS_SOURCE_DIR})
set(SOURCE_DIR ${BASE_DIR}/src) set(SOURCE_DIR ${BASE_DIR}/src)
...@@ -11,6 +9,7 @@ if (NOT CMAKE_BUILD_TYPE) ...@@ -11,6 +9,7 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "") set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
endif () endif ()
include(FindPkgConfig)
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
#some options to control the build process #some options to control the build process
...@@ -32,14 +31,9 @@ option(BUILD_SHARED_LIBS "Build all libraries as shared or static, default: shar ...@@ -32,14 +31,9 @@ option(BUILD_SHARED_LIBS "Build all libraries as shared or static, default: shar
mark_as_advanced(BUILD_SHARED_LIBS) mark_as_advanced(BUILD_SHARED_LIBS)
if (MSVC) if (MSVC)
# if (${CMAKE_VERSION} VERSION_LESS "3.4") set(BUILD_SHARED_LIBS false)
set(BUILD_SHARED_LIBS false) mark_as_advanced(BUILD_SHARED_LIBS)
mark_as_advanced(BUILD_SHARED_LIBS) message(WARNING "Currently we can only build static libraries with Visual Studio")
message(WARNING "Currently we can only build static libraries with Visual Studio")
# elseif (BUILD_SHARED_LIBS)
# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS true)
# set(MSVC_SHARED_LIBS true)
# endif ()
endif (MSVC) endif (MSVC)
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
...@@ -49,22 +43,12 @@ add_library(amdis_base INTERFACE) ...@@ -49,22 +43,12 @@ add_library(amdis_base INTERFACE)
add_library(AMDiS::base ALIAS amdis_base) add_library(AMDiS::base ALIAS amdis_base)
target_include_directories(amdis_base INTERFACE ${SOURCE_DIR}) target_include_directories(amdis_base INTERFACE ${SOURCE_DIR})
target_compile_definitions(amdis_base INTERFACE target_compile_definitions(amdis_base INTERFACE)
$<$<CONFIG:Release>:DEBUG=0>
$<$<NOT:$<CONFIG:Release>>:DEBUG=1>)
include(test_compile_features) include(test_compile_features)
test_compile_features(ENABLE_CXX11 amdis_base INTERFACE target_enable_cxx11(ENABLE_CXX11 amdis_base INTERFACE)
cxx_alias_templates
cxx_auto_type
cxx_lambdas
cxx_override
cxx_range_for
cxx_static_assert
cxx_variadic_templates)
if (ENABLE_CXX11) if (ENABLE_CXX11)
# set(CMAKE_CXX_STANDARD 11)
# set(CMAKE_CXX_STANDARD_REQUIRED ON)
target_compile_definitions(amdis_base INTERFACE HAS_CXX11=1) target_compile_definitions(amdis_base INTERFACE HAS_CXX11=1)
else () else ()
target_compile_definitions(amdis_base INTERFACE HAS_CXX11=0) target_compile_definitions(amdis_base INTERFACE HAS_CXX11=0)
...@@ -75,10 +59,15 @@ endif (ENABLE_CXX11) ...@@ -75,10 +59,15 @@ endif (ENABLE_CXX11)
include(find_mtl4) # -> target mtl4 include(find_mtl4) # -> target mtl4
install(FILES ${BASE_DIR}/cmake3/find_mtl4.cmake DESTINATION share/amdis/) install(FILES ${BASE_DIR}/cmake3/find_mtl4.cmake DESTINATION share/amdis/)
include(find_umfpack) if (ENABLE_UMFPACK)
include(target_enable_umfpack) # -> target boost
target_enable_umfpack(amdis_base INTERFACE)
install(FILES ${BASE_DIR}/cmake3/target_enable_umfpack.cmake DESTINATION share/amdis/)
endif (ENABLE_UMFPACK)
include(find_boost) # -> target boost include(target_enable_boost) # -> target boost
install(FILES ${BASE_DIR}/cmake3/find_boost.cmake DESTINATION share/amdis/) target_enable_boost(amdis_base INTERFACE)
install(FILES ${BASE_DIR}/cmake3/target_enable_boost.cmake DESTINATION share/amdis/)
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
...@@ -236,9 +225,9 @@ endif (ENABLE_COMPOSITE_FEM) ...@@ -236,9 +225,9 @@ endif (ENABLE_COMPOSITE_FEM)
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
if (MSVC) if (MSVC)
target_compile_definitions(amdis PRIVATE target_compile_definitions(amdis PRIVATE
_SCL_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS
_CRT_SECURE_NO_WARNINGS) _CRT_SECURE_NO_WARNINGS)
endif (MSVC) endif (MSVC)
target_link_libraries(amdis AMDiS::base muparser) target_link_libraries(amdis AMDiS::base muparser)
...@@ -266,5 +255,4 @@ configure_file(${BASE_DIR}/cmake3/AMDISConfig.cmake.in ...@@ -266,5 +255,4 @@ configure_file(${BASE_DIR}/cmake3/AMDISConfig.cmake.in
install(FILES ${AMDiS_BINARY_DIR}/AMDISConfig.cmake DESTINATION share/amdis/) install(FILES ${AMDiS_BINARY_DIR}/AMDISConfig.cmake DESTINATION share/amdis/)
install(FILES ${BASE_DIR}/cmake3/AMDISUse.cmake DESTINATION share/amdis/) install(FILES ${BASE_DIR}/cmake3/AMDISUse.cmake DESTINATION share/amdis/)
install(FILES ${BASE_DIR}/cmake3/test_compile_features.cmake DESTINATION share/amdis/) install(FILES ${BASE_DIR}/cmake3/test_compile_features.cmake DESTINATION share/amdis/)
install(FILES ${BASE_DIR}/cmake3/dummy.cc DESTINATION share/amdis/) \ No newline at end of file
# 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)
# source: https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake
# - Try to find PETSc # - Try to find PETSc
# Once done this will define # Once done this will define
# #
...@@ -10,8 +9,10 @@ ...@@ -10,8 +9,10 @@
# PETSC_MPIEXEC - Executable for running MPI programs # PETSC_MPIEXEC - Executable for running MPI programs
# PETSC_VERSION - Version string (MAJOR.MINOR.SUBMINOR) # PETSC_VERSION - Version string (MAJOR.MINOR.SUBMINOR)
# #
# Hack: PETSC_VERSION currently decides on the version based on the # Usage:
# layout. Otherwise we need to run C code to determine the version. # 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 # Setting these changes the behavior of the search
# PETSC_DIR - directory in which PETSc resides # PETSC_DIR - directory in which PETSc resides
...@@ -21,6 +22,31 @@ ...@@ -21,6 +22,31 @@
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. # 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) function (petsc_get_version)
if (EXISTS "${PETSC_DIR}/include/petscversion.h") if (EXISTS "${PETSC_DIR}/include/petscversion.h")
file (STRINGS "${PETSC_DIR}/include/petscversion.h" vstrings REGEX "#define PETSC_VERSION_(RELEASE|MAJOR|MINOR|SUBMINOR|PATCH) ") file (STRINGS "${PETSC_DIR}/include/petscversion.h" vstrings REGEX "#define PETSC_VERSION_(RELEASE|MAJOR|MINOR|SUBMINOR|PATCH) ")
...@@ -42,14 +68,21 @@ function (petsc_get_version) ...@@ -42,14 +68,21 @@ function (petsc_get_version)
endif () endif ()
endfunction () endfunction ()
if (PETSC_DIR)
file(TO_CMAKE_PATH ${PETSC_DIR} PETSC_DIR)
endif (PETSC_DIR)
find_path (PETSC_DIR include/petsc.h find_path (PETSC_DIR include/petsc.h
HINTS ${AMDIS_PETSC_DIR} $ENV{HOME}/petsc ENV PETSC_DIR HINTS /usr/lib/petsc ENV PETSC_DIR
PATHS
# 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") DOC "PETSc Directory")
find_program (MAKE_EXECUTABLE NAMES make gmake)
if (PETSC_DIR AND NOT PETSC_ARCH) if (PETSC_DIR AND NOT PETSC_ARCH)
set (_petsc_arches set (_petsc_arches
$ENV{PETSC_ARCH} # If set, use environment variable first $ENV{PETSC_ARCH} # If set, use environment variable first
...@@ -59,11 +92,11 @@ if (PETSC_DIR AND NOT PETSC_ARCH) ...@@ -59,11 +92,11 @@ if (PETSC_DIR AND NOT PETSC_ARCH)
foreach (arch ${_petsc_arches}) foreach (arch ${_petsc_arches})
if (NOT PETSC_ARCH) if (NOT PETSC_ARCH)
find_path (petscconf petscconf.h find_path (petscconf petscconf.h
HINTS ${PETSC_DIR} HINTS ${PETSC_DIR}
PATH_SUFFIXES ${arch}/include bmake/${arch} PATH_SUFFIXES ${arch}/include bmake/${arch}
NO_DEFAULT_PATH) NO_DEFAULT_PATH)
if (petscconf) if (petscconf)
set (PETSC_ARCH "${arch}" CACHE STRING "PETSc build architecture") set (PETSC_ARCH "${arch}" CACHE STRING "PETSc build architecture")
endif (petscconf) endif (petscconf)
endif (NOT PETSC_ARCH) endif (NOT PETSC_ARCH)
endforeach (arch) endforeach (arch)
...@@ -79,25 +112,22 @@ find_package_multipass (PETSc petsc_config_current ...@@ -79,25 +112,22 @@ find_package_multipass (PETSc petsc_config_current
# Determine whether the PETSc layout is old-style (through 2.3.3) or # Determine whether the PETSc layout is old-style (through 2.3.3) or
# new-style (>= 3.0.0) # 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
if (EXISTS "${PETSC_DIR}/conf/rules") set (petsc_conf_rules "${PETSC_DIR}/lib/petsc/conf/rules")
set (petsc_conf_rules "${PETSC_DIR}/conf/rules") set (petsc_conf_variables "${PETSC_DIR}/lib/petsc/conf/variables")
set (petsc_conf_variables "${PETSC_DIR}/conf/variables") elseif (EXISTS "${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h") # > 2.3.3
else () set (petsc_conf_rules "${PETSC_DIR}/conf/rules")
set (petsc_conf_rules "${PETSC_DIR}/lib/petsc/conf/rules") set (petsc_conf_variables "${PETSC_DIR}/conf/variables")
set (petsc_conf_variables "${PETSC_DIR}/lib/petsc/conf/variables")
endif ()
elseif (EXISTS "${PETSC_DIR}/bmake/${PETSC_ARCH}/petscconf.h") # <= 2.3.3 elseif (EXISTS "${PETSC_DIR}/bmake/${PETSC_ARCH}/petscconf.h") # <= 2.3.3
set (petsc_conf_rules "${PETSC_DIR}/bmake/common/rules") set (petsc_conf_rules "${PETSC_DIR}/bmake/common/rules")
set (petsc_conf_variables "${PETSC_DIR}/bmake/common/variables") set (petsc_conf_variables "${PETSC_DIR}/bmake/common/variables")
elseif (PETSC_DIR) elseif (PETSC_DIR)
message (SEND_ERROR "The pair PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} do not specify a valid PETSc installation") message (SEND_ERROR "The pair PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} do not specify a valid PETSc installation")
else ()
message (FATAL_ERROR "PETSc could not be found. Be sure to set PETSC_DIR and PETSC_ARCH.")
endif () endif ()
petsc_get_version()
if (petsc_conf_rules AND petsc_conf_variables AND NOT petsc_config_current) if (petsc_conf_rules AND petsc_conf_variables AND NOT petsc_config_current)
petsc_get_version()