Commit 47a5a2e8 authored by incardon's avatar incardon

Fixing configure script for numerics only compilation

parent c79b66c6
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(openfpm_numerics LANGUAGES C CXX)
project(openfpm_pdata LANGUAGES C CXX)
enable_testing()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/CMakeFiles/)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake_modules/)
set(BOOST_INCLUDE ${Boost_INCLUDE_DIR} CACHE PATH "Include directory for BOOST")
set(PETSC_ROOT CACHE PATH "If compiling with linear algebra indicate the PETSC root directory")
......@@ -12,6 +13,8 @@ set(LIBHILBERT_ROOT CACHE PATH "LibHilbert root path")
set(HDF5_ROOT CACHE PATH "HDF5 root path")
set(EIGEN3_ROOT CACHE PATH "Eigen3 include path")
set(LIBHILBERT_ROOT CACHE PATH "LibHilbert root path")
set(SUITESPARSE_ROOT CACHE PATH "The suitesparse root path")
set(TINYOBJLOADER_ROOT CACHE PATH "TinyObjLoader library path")
set(SE_CLASS1 CACHE BOOL "Activate compilation with SE_CLASS1")
set(SE_CLASS2 CACHE BOOL "Activate compilation with SE_CLASS2")
set(SE_CLASS3 CACHE BOOL "Activate compilation with SE_CLASS3")
......@@ -21,26 +24,46 @@ set(ENV{HDF5_ROOT} ${HDF5_ROOT})
set(ENV{EIGEN3_ROOT} ${EIGEN3_ROOT})
set(METIS_DIR ${METIS_ROOT})
set(PARMETIS_DIR ${PARMETIS_ROOT})
set(ENV{PATH} "$ENV{PATH}:${HDF5_ROOT}/bin")
set(HDF5_PREFER_PARALLEL TRUE)
set(OPENBLAS_ROOT CACHE PATH "Root path for blas library")
set(SuiteSparse_ROOT ${SUITESPARSE_ROOT})
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CUDA_STANDARD 11)
if (OPENBLAS_ROOT)
set(ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:${OPENBLAS_ROOT}/lib")
set(ENV{DYLD_LIBRARY_PATH} "$ENV{DYLD_LIBRARY_PATH}:${OPENBLAS_ROOT}/lib")
endif()
set(ENV{PATH} "$ENV{PATH}:${HDF5_ROOT}/bin")
set(HDF5_PREFER_PARALLEL TRUE)
if(ENABLE_GPU)
enable_language(CUDA)
find_package(CUDA)
if (CUDA_VERSION_MAJOR EQUAL 9 AND CUDA_VERSION_MINOR EQUAL 2)
message("CUDA is compatible")
else()
message(FATAL_ERROR "CUDA is incompatible, version 9.2 is only supported")
endif()
endif()
find_package(Boost 1.66.0 REQUIRED COMPONENTS unit_test_framework iostreams program_options)
find_package(MPI REQUIRED)
find_package(Boost 1.68.0 COMPONENTS unit_test_framework iostreams program_options)
find_package(MPI)
find_package(PETSc)
find_package(HDF5 REQUIRED)
find_package(HDF5)
find_package(Eigen3)
find_package(LibHilbert REQUIRED)
find_package(Metis REQUIRED)
find_package(ParMetis REQUIRED)
find_package(LibHilbert)
find_package(Metis)
find_package(ParMetis)
find_package(TinyObjLoader )
find_package(BLAS)
find_package(LAPACK)
find_package(Eigen3)
find_package(SuiteSparse OPTIONAL_COMPONENTS UMFPACK)
if(PROFILE_WITH_SCOREP)
set(CMAKE_CXX_COMPILER_LAUNCHER "scorep")
......@@ -51,7 +74,7 @@ endif()
if(CUDA_FOUND)
set(OPENFPM_INIT_FILE "initialize/initialize_wrapper_cuda.cu")
else()
set(OPENFPM_INIT_FILE "initialize/initialize_wrapper_cuda.cpp")
set(OPENFPM_INIT_FILE "initialize/initialize_wrapper_cpu.cpp")
endif()
###### CONFIG.h FILE ######
......@@ -68,6 +91,14 @@ if(SE_CLASS3)
set(DEFINE_SE_CLASS3 "#define SE_CLASS3")
endif()
if(PETSC_FOUND)
set(DEFINE_HAVE_PETSC "#define HAVE_PETSC")
endif()
if(SCAN_COVERTY)
set(DEFINE_SCAN_COVERTY "#define COVERTY_SCAN")
endif()
if(CUDA_FOUND)
set(DEFINE_CUDA_GPU "#define CUDA_GPU")
endif()
......@@ -75,18 +106,21 @@ endif()
if (METIS_FOUND)
set(DEFINE_HAVE_METIS "#define HAVE_METIS 1")
else()
file(WRITE error_code "201")
message( FATAL_ERROR "Metis is required in order to install OpenFPM" )
endif()
if (PARMETIS_FOUND)
set(DEFINE_HAVE_PARMETIS "#define HAVE_PARMETIS 1")
else()
file(WRITE error_code "208")
message( FATAL_ERROR "ParMetis is required in order to install OpenFPM")
endif()
if(MPI_FOUND)
set(DEFINE_HAVE_MPI "#define HAVE_MPI")
else()
file(WRITE error_code "200")
message( FATAL_ERROR "MPI is required in order to install OpenFPM" )
endif()
......@@ -96,6 +130,7 @@ if (Boost_FOUND)
set(DEFINE_HAVE_BOOST_PROGRAM_OPTIONS "#define HAVE_BOOST_PROGRAM_OPTIONS")
set(DEFINE_HAVE_BOOST_UNIT_TEST_FRAMEWORK "#define HAVE_BOOST_UNIT_TEST_FRAMEWORK")
else()
file(WRITE error_code "202")
message( FATAL_ERROR "BOOST is required in order to install OpenFPM" )
endif()
......@@ -103,25 +138,44 @@ if(HDF5_FOUND)
if (HDF5_IS_PARALLEL)
set(DEFINE_HAVE_HDF5 "#define HAVE_HDF5")
else()
message( STATUS "HDF5 found ${HDF5_INCLUDE_DIRS} does not have parallel support, OpenFPM require it" )
file(WRITE error_code "207")
message( FATAL_ERROR "HDF5 found ${HDF5_INCLUDE_DIRS} does not have parallel support, OpenFPM require it" )
endif()
else()
file(WRITE error_code "207")
message( FATAL_ERROR "HDF5 with parallel support is required in order to install OpenFPM" )
endif()
if(EIGEN_FOUND)
if(EIGEN3_FOUND)
set(DEFINE_HAVE_EIGEN "#define HAVE_EIGEN")
endif()
if(LIBHILBERT_FOUND)
set(DEFINE_HAVE_LIBHILBERT "#define HAVE_LIBHILBERT 1")
else()
file(WRITE error_code "210")
message( FATAL_ERROR "LibHilbert is required in order to install OpenFPM")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config/config_cmake.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config/config.h)
if(SUITESPARSE_FOUND AND SuiteSparse_UMFPACK_FOUND)
set(DEFINE_HAVE_SUITESPARSE "#define HAVE_SUITESPARSE")
endif()
include_directories(SYSTEM ${MPI_INCLUDE_PATH})
if(APPLE)
set(DEFINE_HAVE_OSX "#define HAVE_OSX")
endif()
if(TINYOBJLOADER_FOUND)
set(DEFINE_HAVE_TINYOBJLOADER "#define HAVE_TINYOBJLOADER 1")
endif()
file(WRITE error_code "0")
file(WRITE cuda_lib "${CUDA_cudart_static_LIBRARY} ${CUDA_cudadevrt_LIBRARY}")
file(WRITE cuda_include "-I${CUDA_INCLUDE_DIRS}")
file(WRITE mpi_include "-I${MPI_C_INCLUDE_DIRS}")
file(WRITE mpi_libs "${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config/config_cmake.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config/config.h)
add_subdirectory (src)
# 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 Eigen3 lib
#
# This module supports requiring a minimum version, e.g. you can do
# find_package(Eigen3 3.1.2)
# to require version 3.1.2 or newer of Eigen3.
#
# Once done this will define
#
# EIGEN3_FOUND - system has eigen lib with correct version
# EIGEN3_INCLUDE_DIR - the eigen include directory
# EIGEN3_VERSION - eigen version
#
# and the following imported target:
#
# Eigen3::Eigen - The header-only Eigen library
#
# This module reads hints about search locations from
# the following environment variables:
#
# EIGEN3_ROOT
# EIGEN3_ROOT_DIR
# Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
# Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
# Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
# Redistribution and use is allowed according to the terms of the 2-clause BSD license.
if(NOT Eigen3_FIND_VERSION)
if(NOT Eigen3_FIND_VERSION_MAJOR)
set(Eigen3_FIND_VERSION_MAJOR 2)
endif(NOT Eigen3_FIND_VERSION_MAJOR)
if(NOT Eigen3_FIND_VERSION_MINOR)
set(Eigen3_FIND_VERSION_MINOR 91)
endif(NOT Eigen3_FIND_VERSION_MINOR)
if(NOT Eigen3_FIND_VERSION_PATCH)
set(Eigen3_FIND_VERSION_PATCH 0)
endif(NOT Eigen3_FIND_VERSION_PATCH)
set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
endif(NOT Eigen3_FIND_VERSION)
macro(_eigen3_check_version)
file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}")
set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION})
if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
set(EIGEN3_VERSION_OK FALSE)
else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
set(EIGEN3_VERSION_OK TRUE)
endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
if(NOT EIGEN3_VERSION_OK)
message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, "
"but at least version ${Eigen3_FIND_VERSION} is required")
endif(NOT EIGEN3_VERSION_OK)
endmacro(_eigen3_check_version)
if (EIGEN3_INCLUDE_DIR)
# in cache already
_eigen3_check_version()
set(EIGEN3_FOUND ${EIGEN3_VERSION_OK})
set(Eigen3_FOUND ${EIGEN3_VERSION_OK})
else (EIGEN3_INCLUDE_DIR)
# search first if an Eigen3Config.cmake is available in the system,
# if successful this would set EIGEN3_INCLUDE_DIR and the rest of
# the script will work as usual
find_package(Eigen3 ${Eigen3_FIND_VERSION} NO_MODULE QUIET)
if(NOT EIGEN3_INCLUDE_DIR)
find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
HINTS
ENV EIGEN3_ROOT
ENV EIGEN3_ROOT_DIR
PATHS
${CMAKE_INSTALL_PREFIX}/include
${KDE4_INCLUDE_DIR}
PATH_SUFFIXES eigen3 eigen
)
endif(NOT EIGEN3_INCLUDE_DIR)
if(EIGEN3_INCLUDE_DIR)
_eigen3_check_version()
endif(EIGEN3_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK)
mark_as_advanced(EIGEN3_INCLUDE_DIR)
endif(EIGEN3_INCLUDE_DIR)
if(EIGEN3_FOUND AND NOT TARGET Eigen3::Eigen)
add_library(Eigen3::Eigen INTERFACE IMPORTED)
set_target_properties(Eigen3::Eigen PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${EIGEN3_INCLUDE_DIR}")
endif()
# - Try to find LibHilbert
# Once done this will define
#
# LIBHILBERT_FOUND - system has LibHilbert
# LIBHILBERT_INCLUDE_DIRS - include directories for PETSc
# LIBHILBERT_LIBRARY_DIRS - library directories for PETSc
# LIBHILBERT_LIBRARIES - libraries for PETSc
#
#=============================================================================
# Copyright (C) 2010-2016 Pietro Incardona
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
if (LIBHILBERT_FOUND)
return()
endif()
add_library(libhilbert INTERFACE IMPORTED)
# Add libraries (static)
set(_libs "-L${LIBHILBERT_ROOT}/lib -llibhilbert")
set_property(TARGET libhilbert PROPERTY INTERFACE_LINK_LIBRARIES "${_libs}")
# Create LibHilbert test program
set(LIBHILBERT_TEST_LIB_CPP
"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/libhilbert_test_lib.cpp")
file(WRITE ${LIBHILBERT_TEST_LIB_CPP} "
extern \"C\"
{
#include \"hilbertKey.h\"
}
int main()
{
//An integer to handle errors
int err;
//Array to handle output
uint64_t nextCoord[2];
//Get the coordinates of the next cell
getIntCoordFromHKey(nextCoord, 4, 2, 0, &err);
return 0;
}
")
# Try to run test program (static linking)
try_run(
LIBHILBERT_TEST_LIB_EXITCODE
LIBHILBERT_TEST_LIB_COMPILED
${CMAKE_CURRENT_BINARY_DIR}
${LIBHILBERT_TEST_LIB_CPP}
CMAKE_FLAGS
"-DINCLUDE_DIRECTORIES:STRING=${LIBHILBERT_ROOT}/include"
"-DLINK_LIBRARIES:STRING=${LIBHILBERT_ROOT}/lib"
LINK_LIBRARIES libhilbert m
COMPILE_OUTPUT_VARIABLE LIBHILBERT_TEST_LIB_COMPILE_OUTPUT
RUN_OUTPUT_VARIABLE LIBHILBERT_TEST_LIB_OUTPUT)
if (LIBHILBERT_TEST_LIB_COMPILED AND LIBHILBERT_TEST_LIB_EXITCODE EQUAL 0)
message(STATUS "Test LibHilbert_TEST_RUNS static linking - Success")
set(LIBHILBERT_TEST_RUNS TRUE)
set(LIBHILBERT_FOUND TRUE)
set(LIBHILBERT_INCLUDE_DIRS ${LIBHILBERT_ROOT}/include)
set(LIBHILBERT_LIBRARY_DIRS ${LIBHILBERT_ROOT}/lib)
set(LIBHILBERT_LIBRARIES -llibhilbert)
else()
message(STATUS "Test LibHilbert_TEST_RUNS static linking - Failed")
set(LIBHILBERT_TEST_RUNS FALSE)
endif()
# -*- mode: cmake -*-
#
# METIS Find Module for Femus
# Shamelessly stolen from Amanzi open source code https://software.lanl.gov/ascem/trac
#
# Usage:
# Control the search through METIS_DIR or setting environment variable
# METIS_ROOT to the METIS installation prefix.
#
# This module does not search default paths!
#
# Following variables are set:
# METIS_FOUND (BOOL) Flag indicating if METIS was found
# METIS_INCLUDE_DIR (PATH) Path to the METIS include file
# METIS_INCLUDE_DIRS (LIST) List of all required include files
# METIS_LIBRARY_DIR (PATH) Path to the METIS library
# METIS_LIBRARY (FILE) METIS library
# METIS_LIBRARIES (LIST) List of all required METIS libraries
#
# #############################################################################
# Standard CMake modules see CMAKE_ROOT/Modules
include(FindPackageHandleStandardArgs)
# Amanzi CMake functions see <root>/tools/cmake for source
#include(PrintVariable)
if ( METIS_LIBRARIES AND METIS_INCLUDE_DIRS )
# Do nothing. Variables are set. No need to search again
else(METIS_LIBRARIES AND METIS_INCLUDE_DIRS)
# Cache variables
if(METIS_DIR)
set(METIS_DIR "${METIS_DIR}" CACHE PATH "Path to search for METIS include and library files")
endif()
if(METIS_INCLUDE_DIR)
set(METIS_INCLUDE_DIR "${METIS_INCLUDE_DIR}" CACHE PATH "Path to search for METIS include files")
endif()
if(METIS_LIBRARY_DIR)
set(METIS_LIBRARY_DIR "${METIS_LIBRARY_DIR}" CACHE PATH "Path to search for METIS library files")
endif()
# Search for include files
# Search order preference:
# (1) METIS_INCLUDE_DIR - check existence of path AND if the include files exist
# (2) METIS_DIR/<include>
# (3) Default CMake paths See cmake --html-help=out.html file for more information.
#
set(metis_inc_names "metis.h")
if (METIS_INCLUDE_DIR)
if (EXISTS "${METIS_INCLUDE_DIR}")
find_path(metis_test_include_path
NAMES ${metis_inc_names}
HINTS ${METIS_INCLUDE_DIR}
NO_DEFAULT_PATH)
if(NOT metis_test_include_path)
message(SEND_ERROR "Can not locate ${metis_inc_names} in ${METIS_INCLUDE_DIR}")
endif()
set(METIS_INCLUDE_DIR "${metis_test_include_path}")
else()
message(SEND_ERROR "METIS_INCLUDE_DIR=${METIS_INCLUDE_DIR} does not exist")
set(METIS_INCLUDE_DIR "METIS_INCLUDE_DIR-NOTFOUND")
endif()
else()
# Metis sometimes puts the include files in a subdir called Lib
set(metis_inc_suffixes "include" "Lib")
if(METIS_DIR)
if (EXISTS "${METIS_DIR}" )
find_path(METIS_INCLUDE_DIR
NAMES ${metis_inc_names}
HINTS ${METIS_DIR}
PATH_SUFFIXES ${metis_inc_suffixes}
NO_DEFAULT_PATH)
else()
message(SEND_ERROR "METIS_DIR=${METIS_DIR} does not exist")
set(METIS_INCLUDE_DIR "METIS_INCLUDE_DIR-NOTFOUND")
endif()
else()
find_path(METIS_INCLUDE_DIR
NAMES ${metis_inc_names}
PATH_SUFFIXES ${metis_inc_suffixes})
endif()
endif()
# Search for libraries
# Search order preference:
# (1) METIS_LIBRARY_DIR - check existence of path AND if the library file exists
# (2) METIS_DIR/<lib,Lib>
# (3) Default CMake paths See cmake --html-help=out.html file for more information.
#
set(metis_lib_names "metis")
if (METIS_LIBRARY_DIR)
if (EXISTS "${METIS_LIBRARY_DIR}")
find_library(METIS_LIBRARY
NAMES ${metis_lib_names}
HINTS ${METIS_LIBRARY_DIR}
NO_DEFAULT_PATH)
else()
set(METIS_LIBRARY "METIS_LIBRARY-NOTFOUND")
endif()
else()
list(APPEND metis_lib_suffixes "lib" "Lib")
if(METIS_DIR)
if (EXISTS "${METIS_DIR}" )
find_library(METIS_LIBRARY
NAMES ${metis_lib_names}
HINTS ${METIS_DIR}
PATH_SUFFIXES ${metis_lib_suffixes}
NO_DEFAULT_PATH)
else()
set(METISLIBRARY "METIS_LIBRARY-NOTFOUND")
endif()
else()
find_library(METIS_LIBRARY
NAMES ${metis_lib_names}
PATH_SUFFIXES ${metis_lib_suffixes})
endif()
endif()
if ( NOT METIS_LIBRARY )
endif()
# Define prerequisite packages
set(METIS_INCLUDE_DIRS ${METIS_INCLUDE_DIR})
set(METIS_LIBRARIES ${METIS_LIBRARY})
endif(METIS_LIBRARIES AND METIS_INCLUDE_DIRS )
# Send useful message if everything is found
find_package_handle_standard_args(METIS DEFAULT_MSG
METIS_LIBRARIES
METIS_INCLUDE_DIRS)
# find_package_handle_standard_args should set METIS_FOUND but it does not!
if ( METIS_LIBRARIES AND METIS_INCLUDE_DIRS)
set(METIS_FOUND TRUE)
else()
set(METIS_FOUND FALSE)
endif()
# Define the version
mark_as_advanced(
METIS_INCLUDE_DIR
METIS_INCLUDE_DIRS
METIS_LIBRARY
METIS_LIBRARIES
METIS_LIBRARY_DIR
)
This diff is collapsed.
# PackageMultipass - this module defines two macros
#
# FIND_PACKAGE_MULTIPASS (Name CURRENT
# STATES VAR0 VAR1 ...
# DEPENDENTS DEP0 DEP1 ...)
#
# This function creates a cache entry <UPPERCASED-Name>_CURRENT which
# the user can set to "NO" to trigger a reconfiguration of the package.
# The first time this function is called, the values of
# <UPPERCASED-Name>_VAR0, ... are saved. If <UPPERCASED-Name>_CURRENT
# is false or if any STATE has changed since the last time
# FIND_PACKAGE_MULTIPASS() was called, then CURRENT will be set to "NO",
# otherwise CURRENT will be "YES". IF not CURRENT, then
# <UPPERCASED-Name>_DEP0, ... will be FORCED to NOTFOUND.
# Example:
# find_path (FOO_DIR include/foo.h)
# FIND_PACKAGE_MULTIPASS (Foo foo_current
# STATES DIR
# DEPENDENTS INCLUDES LIBRARIES)
# if (NOT foo_current)
# # Make temporary files, run programs, etc, to determine FOO_INCLUDES and FOO_LIBRARIES
# endif (NOT foo_current)
#
# MULTIPASS_SOURCE_RUNS (Name INCLUDES LIBRARIES SOURCE RUNS LANGUAGE)
# Always runs the given test, use this when you need to re-run tests
# because parent variables have made old cache entries stale. The LANGUAGE
# variable is either C or CXX indicating which compiler the test should
# use.
# MULTIPASS_C_SOURCE_RUNS (Name INCLUDES LIBRARIES SOURCE RUNS)
# DEPRECATED! This is only included for backwards compatability. Use
# the more general MULTIPASS_SOURCE_RUNS instead.
# Always runs the given test, use this when you need to re-run tests
# because parent variables have made old cache entries stale.
macro (FIND_PACKAGE_MULTIPASS _name _current)
string (TOUPPER ${_name} _NAME)
set (_args ${ARGV})
list (REMOVE_AT _args 0 1)
set (_states_current "YES")
list (GET _args 0 _cmd)
if (_cmd STREQUAL "STATES")
list (REMOVE_AT _args 0)
list (GET _args 0 _state)
while (_state AND NOT _state STREQUAL "DEPENDENTS")
# The name of the stored value for the given state
set (_stored_var PACKAGE_MULTIPASS_${_NAME}_${_state})
if (NOT "${${_stored_var}}" STREQUAL "${${_NAME}_${_state}}")
set (_states_current "NO")
endif (NOT "${${_stored_var}}" STREQUAL "${${_NAME}_${_state}}")
set (${_stored_var} "${${_NAME}_${_state}}" CACHE INTERNAL "Stored state for ${_name}." FORCE)
list (REMOVE_AT _args 0)
list (GET _args 0 _state)
endwhile (_state AND NOT _state STREQUAL "DEPENDENTS")
endif (_cmd STREQUAL "STATES")
set (_stored ${_NAME}_CURRENT)
if (NOT ${_stored})
set (${_stored} "YES" CACHE BOOL "Is the configuration for ${_name} current? Set to \"NO\" to reconfigure." FORCE)
set (_states_current "NO")
endif (NOT ${_stored})
set (${_current} ${_states_current})
if (NOT ${_current} AND PACKAGE_MULTIPASS_${_name}_CALLED)
message (STATUS "Clearing ${_name} dependent variables")
# Clear all the dependent variables so that the module can reset them
list (GET _args 0 _cmd)
if (_cmd STREQUAL "DEPENDENTS")
list (REMOVE_AT _args 0)
foreach (dep ${_args})
set (${_NAME}_${dep} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE)
endforeach (dep)
endif (_cmd STREQUAL "DEPENDENTS")
set (${_NAME}_FOUND "NOTFOUND" CACHE INTERNAL "Cleared" FORCE)
endif ()
set (PACKAGE_MULTIPASS_${name}_CALLED YES CACHE INTERNAL "Private" FORCE)
endmacro (FIND_PACKAGE_MULTIPASS)
macro (MULTIPASS_SOURCE_RUNS includes libraries source runs language)
include (Check${language}SourceRuns)
# This is a ridiculous hack. CHECK_${language}_SOURCE_* thinks that if the
# *name* of the return variable doesn't change, then the test does
# not need to be re-run. We keep an internal count which we
# increment to guarantee that every test name is unique. If we've
# gotten here, then the configuration has changed enough that the
# test *needs* to be rerun.
if (NOT MULTIPASS_TEST_COUNT)
set (MULTIPASS_TEST_COUNT 00)
endif (NOT MULTIPASS_TEST_COUNT)
math (EXPR _tmp "${MULTIPASS_TEST_COUNT} + 1") # Why can't I add to a cache variable?
set (MULTIPASS_TEST_COUNT ${_tmp} CACHE INTERNAL "Unique test ID")
set (testname MULTIPASS_TEST_${MULTIPASS_TEST_COUNT}_${runs})
set (CMAKE_REQUIRED_INCLUDES ${includes})
set (CMAKE_REQUIRED_LIBRARIES ${libraries})
if(${language} STREQUAL "C")
check_c_source_runs ("${source}" ${testname})
elseif(${language} STREQUAL "CXX")
check_cxx_source_runs ("${source}" ${testname})
endif()
set (${runs} "${${testname}}")
endmacro (MULTIPASS_SOURCE_RUNS)
macro (MULTIPASS_C_SOURCE_RUNS includes libraries source runs)
multipass_source_runs("${includes}" "${libraries}" "${source}" ${runs} "C")
endmacro (MULTIPASS_C_SOURCE_RUNS)
# - Try to find ParMETIS
# Once done this will define
#
# PARMETIS_FOUND - system has ParMETIS
# PARMETIS_INCLUDE_DIRS - include directories for ParMETIS
# PARMETIS_LIBRARIES - libraries for ParMETIS
#
# Variables used by this module. They can change the default behaviour and
# need to be set before calling find_package:
#
# PARMETIS_DIR - Prefix directory of the ParMETIS installation
# PARMETIS_INCLUDE_DIR - Include directory of the ParMETIS installation
# (set only if different from ${PARMETIS_DIR}/include)
# PARMETIS_LIB_DIR - Library directory of the ParMETIS installation
# (set only if different from ${PARMETIS_DIR}/lib)
# PARMETIS_TEST_RUNS - Skip tests building and running a test
# executable linked against ParMETIS libraries
# PARMETIS_LIB_SUFFIX - Also search for non-standard library names with the
# given suffix appended
#=============================================================================
# Copyright (C) 2010-2012 Garth N. Wells, Anders Logg, Johannes Ring
# and Florian Rathgeber. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
if(NOT PARMETIS_INCLUDE_DIR)
find_path(PARMETIS_INCLUDE_DIR parmetis.h