Commit c51bc45c authored by Praetorius, Simon's avatar Praetorius, Simon

added cmake script target_enables_*

parent 014c737f
......@@ -100,45 +100,9 @@ if (AMDIS_HAS_PARALLEL_DOMAIN)
target_compile_definitions(amdis_base INTERFACE
HAVE_PARALLEL_DOMAIN_AMDIS=1)
find_package(MPI REQUIRED)
target_include_directories(amdis_base INTERFACE ${MPI_CXX_INCLUDE_PATH})
target_compile_options(amdis_base INTERFACE ${MPI_CXX_COMPILE_FLAGS})
string(STRIP " ${MPI_CXX_LINK_FLAGS} " MPI_CXX_LINK_FLAGS_)
target_link_libraries(amdis_base INTERFACE ${MPI_CXX_LINK_FLAGS_} ${MPI_CXX_LIBRARIES})
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})
find_library(BLAS_LIB
NAMES blas fblas openblas
HINTS ${BLAS_DIR}/lib ${PETSC_LIB_DIR} ${PETSC_DIR}/lib /usr/lib/openblas-base /usr/lib/atlas-base)
if (BLAS_LIB)
set(BLAS_LIBRARIES ${BLAS_LIB})
else ()
find_package(BLAS REQUIRED)
endif ()
find_library(LAPACK_LIB
NAMES lapack flapack
HINTS ${LAPACK_DIR}/lib ${PETSC_LIB_DIR} ${PETSC_DIR}/lib)
if (LAPACK_LIB)
set(LAPACK_LIBRARIES ${LAPACK_LIB})
else ()
find_package(LAPACK REQUIRED)
endif ()
target_link_libraries(amdis_base INTERFACE
${PETSC_LIBRARY_SYS}
${PETSC_LIBRARIES}
${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
target_compile_definitions(amdis_base INTERFACE
HAVE_PARALLEL_PETSC=1)
else()
message(FATAL_ERROR "Could not find PETSc!")
endif (PETSc_FOUND)
include(target_enable_petsc)
target_enable_mpi(amdis_base INTERFACE)
target_enable_petsc(amdis_base INTERFACE)
endif (AMDIS_HAS_PARALLEL_DOMAIN)
......@@ -206,12 +170,8 @@ unset(_MUPARSER_LIB CACHE)
# 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)
target_link_libraries(amdis_base INTERFACE ${ZOLTAN_LIB})
else()
message(FATAL_ERROR "Could not find zoltan library!")
endif()
include(target_enable_zoltan)
target_enable_zoltan(amdis_base INTERFACE ON)
endif ()
# Extract some variables from INTERFACE target AMDiS
......
......@@ -29,88 +29,16 @@ if (ENABLE_PARALLEL_DOMAIN)
target_compile_definitions(amdis_parallel INTERFACE
HAVE_PARALLEL_DOMAIN_AMDIS=1)
# MPI is required
find_package(MPI REQUIRED)
target_include_directories(amdis_parallel INTERFACE
${MPI_CXX_INCLUDE_PATH})
target_compile_options(amdis_parallel INTERFACE
${MPI_CXX_COMPILE_FLAGS})
string(STRIP " ${MPI_CXX_LINK_FLAGS} " MPI_CXX_LINK_FLAGS_)
target_link_libraries(amdis_parallel INTERFACE
${MPI_CXX_LINK_FLAGS_} ${MPI_CXX_LIBRARIES})
# PETSc library is required
find_package(petsc QUIET)
if (PETSc_FOUND)
set(PETSC_INCLUDE_DIRS ${PETSC_INCLUDES})
set(PETSC_LIBRARY_DIRS ${PETSC_LIB_DIR})
message(STATUS " Found PETSc, version ${PETSC_VERSION}")
else (PETSc_FOUND)
include(FindPkgConfig)
find_file(PETSC_PKG_CONFIG "PETSc.pc"
HINTS ${PETSC_DIR}/lib/pkgconfig
${PETSC_ROOT}/lib/pkgconfig
/usr/lib/petsc/lib/pkgconfig
/usr/lib/petsc/linux-gnu-cxx-opt/lib/pkgconfig
/usr/lib/petsc/linux-gnu-c-opt/lib/pkgconfig)
if (PETSC_PKG_CONFIG-NOTFOUND)
message(FATAL_ERROR "PETSc PKG-Config file 'PETSc.pc' could not be found. Set variable PETSC_DIR to the directory where this file is located!")
endif (PETSC_PKG_CONFIG-NOTFOUND)
get_filename_component(PETSC_PKG_CONFIG_PATH "${PETSC_PKG_CONFIG}" PATH CACHE)
set(ENV{PKG_CONFIG_PATH} ${PETSC_PKG_CONFIG_PATH})
pkg_check_modules(PETSC REQUIRED PETSc>=3.3)
set(PETSC_DEFINITIONS ${PETSC_CFLAGS} ${PETSC_CFLAGS_OTHER})
endif (PETSc_FOUND)
target_include_directories(amdis_parallel INTERFACE
${PETSC_INCLUDE_DIRS})
# parmetis is required
find_file(PARMETIS_HEADER_FILE "parmetis.h"
HINTS ${PARMETIS_DIR}/include ${PETSC_INCLUDE_DIRS})
if (PARMETIS_HEADER_FILE)
get_filename_component(PARMETIS_INCLUDE_PATH "${PARMETIS_HEADER_FILE}" PATH CACHE)
target_include_directories(amdis_parallel INTERFACE ${PARMETIS_INCLUDE_PATH})
else()
message(FATAL_ERROR "Could not find ParMetis header file 'parmetis.h'!")
endif (PARMETIS_HEADER_FILE)
# blas library is required
find_library(BLAS_LIB
NAMES blas fblas openblas
HINTS ${BLAS_DIR}/lib ${PETSC_LIBRARY_DIRS} /usr/lib/openblas-base /usr/lib/atlas-base)
if (BLAS_LIB)
set(BLAS_LIBRARIES ${BLAS_LIB})
else (BLAS_LIB)
find_package(BLAS REQUIRED)
endif (BLAS_LIB)
# lapack library is required
find_library(LAPACK_LIB
NAMES lapack flapack
HINTS ${LAPACK_DIR}/lib ${PETSC_LIBRARY_DIRS} ${PETSC_DIR}/lib)
if (LAPACK_LIB)
set(LAPACK_LIBRARIES ${LAPACK_LIB})
else (LAPACK_LIB)
find_package(LAPACK REQUIRED)
endif (LAPACK_LIB)
include(target_enable_petsc)
target_enable_mpi(amdis_parallel INTERFACE)
target_enable_petsc(amdis_parallel INTERFACE)
# add support for the zoltan library
if (ENABLE_ZOLTAN)
find_file(ZOLTAN_HEADER_FILE "zoltan_cpp.h" HINTS ${ZOLTAN_DIR}/include ${PETSC_INCLUDE_DIRS})
if (ZOLTAN_HEADER_FILE)
get_filename_component(ZOLTAN_HEADER_DIR "${ZOLTAN_HEADER_FILE}" PATH CACHE)
target_include_directories(amdis_parallel INTERFACE ${ZOLTAN_HEADER_DIR})
else()
message(FATAL_ERROR "Could not find Zoltan include file 'zoltan_cpp.h'!")
endif(ZOLTAN_HEADER_FILE)
target_compile_definitions(amdis_parallel INTERFACE HAVE_ZOLTAN=1)
target_sources(amdis PRIVATE
${SOURCE_DIR}/parallel/ZoltanPartitioner.cc)
include(target_enable_zoltan)
target_enable_zoltan(amdis_parallel INTERFACE)
target_sources(amdis PRIVATE
${SOURCE_DIR}/parallel/ZoltanPartitioner.cc)
endif (ENABLE_ZOLTAN)
if (ENABLE_BDDCML)
......@@ -147,13 +75,7 @@ if (ENABLE_PARALLEL_DOMAIN)
HAVE_PARALLEL_SOLVERS=1)
endif (ENABLE_PARALLEL_SOLVERS)
target_compile_definitions(amdis_parallel INTERFACE
HAVE_PARALLEL_PETSC=1
PETSC_VERSION=${PETSC_VERSION})
target_compile_options(amdis_parallel INTERFACE
${PETSC_DEFINITIONS})
target_link_libraries(amdis amdis_parallel ${PETSC_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
target_link_libraries(amdis amdis_parallel)
# specify how to install this target:
# -----------------------------------
......@@ -166,5 +88,7 @@ if (ENABLE_PARALLEL_DOMAIN)
${BASE_DIR}/cmake3/FindPackageMultipass.cmake
${BASE_DIR}/cmake3/CorrectWindowsPaths.cmake
${BASE_DIR}/cmake3/FindPETSc.cmake
${BASE_DIR}/cmake3/target_enable_petsc.cmake
${BASE_DIR}/cmake3/target_enable_zoltan.cmake
DESTINATION share/amdis/)
endif (ENABLE_PARALLEL_DOMAIN)
macro(target_enable_mpi _TARGET_ _SCOPE_)
find_package(MPI REQUIRED)
target_include_directories(${_TARGET_} ${_SCOPE_}
${MPI_CXX_INCLUDE_PATH})
target_compile_options(${_TARGET_} ${_SCOPE_}
${MPI_CXX_COMPILE_FLAGS})
string(STRIP " ${MPI_CXX_LINK_FLAGS} " MPI_CXX_LINK_FLAGS_)
target_link_libraries(${_TARGET_} ${_SCOPE_}
${MPI_CXX_LINK_FLAGS_} ${MPI_CXX_LIBRARIES})
endmacro(target_enable_mpi)
macro(target_enable_petsc _TARGET_ _SCOPE_)
if (${ARGC} GREATER 2)
set(LINK_EXECUTABLE ON)
else ()
set(LINK_EXECUTABLE OFF)
endif ()
# PETSc library is required
find_package(petsc QUIET)
if (PETSc_FOUND)
set(PETSC_INCLUDE_DIRS ${PETSC_INCLUDES})
set(PETSC_LIBRARY_DIRS ${PETSC_LIB_DIR})
message(STATUS " Found PETSc, version ${PETSC_VERSION}")
else (PETSc_FOUND)
include(FindPkgConfig)
find_file(PETSC_PKG_CONFIG "PETSc.pc"
HINTS ${PETSC_DIR}/lib/pkgconfig
${PETSC_ROOT}/lib/pkgconfig
/usr/lib/petsc/lib/pkgconfig
/usr/lib/petsc/linux-gnu-cxx-opt/lib/pkgconfig
/usr/lib/petsc/linux-gnu-c-opt/lib/pkgconfig)
if (PETSC_PKG_CONFIG-NOTFOUND)
message(FATAL_ERROR "PETSc PKG-Config file 'PETSc.pc' could not be found. Set variable PETSC_DIR to the directory where this file is located!")
endif (PETSC_PKG_CONFIG-NOTFOUND)
get_filename_component(PETSC_PKG_CONFIG_PATH "${PETSC_PKG_CONFIG}" PATH CACHE)
set(ENV{PKG_CONFIG_PATH} ${PETSC_PKG_CONFIG_PATH})
pkg_check_modules(PETSC REQUIRED PETSc>=3.3)
set(PETSC_DEFINITIONS ${PETSC_CFLAGS} ${PETSC_CFLAGS_OTHER})
endif (PETSc_FOUND)
# parmetis is required
find_file(PARMETIS_HEADER_FILE "parmetis.h"
HINTS ${PARMETIS_DIR}/include ${PETSC_INCLUDE_DIRS})
if (PARMETIS_HEADER_FILE)
get_filename_component(PARMETIS_INCLUDE_PATH "${PARMETIS_HEADER_FILE}" PATH CACHE)
target_include_directories(${_TARGET_} ${_SCOPE_} ${PARMETIS_INCLUDE_PATH})
else()
message(FATAL_ERROR "Could not find ParMetis header file 'parmetis.h'!")
endif (PARMETIS_HEADER_FILE)
if (LINK_EXECUTABLE)
find_library(PARMETIS_LIB parmetis
HINTS ${PARMETIS_DIR}/lib ${PETSC_LIBRARY_DIRS})
if (PARMETIS_LIB)
target_link_libraries(${_TARGET_} ${_SCOPE_} ${PARMETIS_LIB})
else (PARMETIS_LIB)
message(FATAL_ERROR "Could not find the ParMetis libraries needed by amdis")
endif (PARMETIS_LIB)
endif (LINK_EXECUTABLE)
# metis is required
find_file(METIS_HEADER_FILE "metis.h"
HINTS ${METIS_DIR}/include ${PARMETIS_DIR}/include ${PETSC_INCLUDE_DIRS})
if (METIS_HEADER_FILE)
get_filename_component(METIS_INCLUDE_PATH "${METIS_HEADER_FILE}" PATH CACHE)
target_include_directories(${_TARGET_} ${_SCOPE_} ${METIS_INCLUDE_PATH})
else()
message(FATAL_ERROR "Could not find Metis header file 'metis.h'!")
endif (METIS_HEADER_FILE)
if (LINK_EXECUTABLE)
find_library(METIS_LIB metis
HINTS ${METIS_DIR}/lib ${PARMETIS_DIR}/lib ${PETSC_LIBRARY_DIRS})
if (METIS_LIB)
target_link_libraries(${_TARGET_} ${_SCOPE_} ${METIS_LIB})
else (METIS_LIB)
message(FATAL_ERROR "Could not find the MEtis libraries needed by amdis")
endif (METIS_LIB)
endif (LINK_EXECUTABLE)
# blas library is required
find_library(BLAS_LIB
NAMES blas fblas openblas
HINTS ${BLAS_DIR}/lib ${PETSC_LIBRARY_DIRS} /usr/lib/openblas-base /usr/lib/atlas-base)
if (BLAS_LIB)
set(BLAS_LIBRARIES ${BLAS_LIB})
else (BLAS_LIB)
find_package(BLAS REQUIRED)
endif (BLAS_LIB)
# lapack library is required
find_library(LAPACK_LIB
NAMES lapack flapack
HINTS ${LAPACK_DIR}/lib ${PETSC_LIBRARY_DIRS} ${PETSC_DIR}/lib)
if (LAPACK_LIB)
set(LAPACK_LIBRARIES ${LAPACK_LIB})
else (LAPACK_LIB)
find_package(LAPACK REQUIRED)
endif (LAPACK_LIB)
target_include_directories(${_TARGET_} ${_SCOPE_} ${PETSC_INCLUDE_DIRS})
target_compile_definitions(${_TARGET_} ${_SCOPE_}
HAVE_PARALLEL_PETSC=1
PETSC_VERSION=${PETSC_VERSION})
target_compile_options(${_TARGET_} ${_SCOPE_} ${PETSC_DEFINITIONS})
target_link_libraries(${_TARGET_} ${_SCOPE_} ${PETSC_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
endmacro(target_enable_petsc)
macro(target_enable_zoltan _TARGET_ _SCOPE_)
if (${ARGC} GREATER 2)
set(LINK_EXECUTABLE ON)
else ()
set(LINK_EXECUTABLE OFF)
endif ()
find_file(ZOLTAN_HEADER_FILE "zoltan_cpp.h" HINTS ${ZOLTAN_DIR}/include ${PETSC_INCLUDE_DIRS})
if (ZOLTAN_HEADER_FILE)
get_filename_component(ZOLTAN_HEADER_DIR "${ZOLTAN_HEADER_FILE}" PATH CACHE)
target_include_directories(${_TARGET_} ${_SCOPE_} ${ZOLTAN_HEADER_DIR})
else()
message(FATAL_ERROR "Could not find Zoltan include file 'zoltan_cpp.h'!")
endif(ZOLTAN_HEADER_FILE)
target_compile_definitions(${_TARGET_} ${_SCOPE_} HAVE_ZOLTAN=1)
if (LINK_EXECUTABLE)
find_library(ZOLTAN_LIB zoltan
HINTS ENV LIBRARY_PATH DOC "Full path to the zoltan library")
if (ZOLTAN_LIB)
target_link_libraries(${_TARGET_} ${_SCOPE_} ${ZOLTAN_LIB})
else()
message(FATAL_ERROR "Could not find zoltan library!")
endif()
endif (LINK_EXECUTABLE)
endmacro(target_enable_zoltan)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment