diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b861b6109a25b1441cf99085a1c6645384a54dc..ddeaf56b888c357ebf63de2ca8308fd1decbd080 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,7 @@ set(ENV{EIGEN3_ROOT} ${EIGEN3_ROOT}) set(METIS_DIR ${METIS_ROOT}) set(PARMETIS_DIR ${PARMETIS_ROOT}) set(OPENBLAS_ROOT CACHE PATH "Root path for blas library") -set(SUITESPARSE_CHECK_INCLUDE_DIRS ${SUITESPARSE_ROOT}/include) -set(SUITESPARSE_CHECK_LIBRARY_DIRS ${SUITESPARSE_ROOT}/lib) +set(SuiteSparse_ROOT ${SUITESPARSE_ROOT}) set (CMAKE_CXX_STANDARD 11) set (CMAKE_CUDA_STANDARD 11) @@ -44,8 +43,6 @@ if(ENABLE_GPU) find_package(CUDA) endif() -message("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB ${OPENBLAS_ROOT}") -message("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA $ENV{LD_LIBRARY_PATH}") find_package(Boost 1.68.0 COMPONENTS unit_test_framework iostreams program_options) find_package(MPI) @@ -59,7 +56,7 @@ find_package(TinyObjLoader ) find_package(BLAS) find_package(LAPACK) find_package(Eigen3) -find_package(SuiteSparse) +find_package(SuiteSparse OPTIONAL_COMPONENTS UMFPACK) if(PROFILE_WITH_SCOREP) set(CMAKE_CXX_COMPILER_LAUNCHER "scorep") diff --git a/build.sh b/build.sh index b53946b42be7839c972a17e97553b998f318011e..eb2689af86117de22c08a50d4657aeda6fd6204d 100755 --- a/build.sh +++ b/build.sh @@ -14,7 +14,6 @@ echo "make target: $target" echo "compilation type: $comp_type" echo "Branch name: $branch" -rm -rf $HOME/openfpm_dependencies/openfpm_pdata/$branch/EIGEN if [ x"$hostname" == x"cifarm-centos-node.mpi-cbg.de" ]; then #we retest PETSC installation diff --git a/cmake_modules/FindSuiteSparse.cmake b/cmake_modules/FindSuiteSparse.cmake index cc090c7154e272445906da620a9ee758075a08c0..f5a2649a26cf9acd2f49136932b3ee57d8b8dd72 100644 --- a/cmake_modules/FindSuiteSparse.cmake +++ b/cmake_modules/FindSuiteSparse.cmake @@ -1,510 +1,272 @@ -# Ceres Solver - A fast non-linear least squares minimizer -# Copyright 2015 Google Inc. All rights reserved. -# http://ceres-solver.org/ +# .. cmake_module:: # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: +# Find the SuiteSparse libraries like UMFPACK or SPQR. # -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * 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. -# * Neither the name of Google Inc. nor the names of its contributors may be -# used to endorse or promote products derived from this software without -# specific prior written permission. +# Example which tries to find Suite Sparse's UMFPack component: # -# 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 OWNER 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. +# :code:`find_package(SuiteSparse OPTIONAL_COMPONENTS UMFPACK)` # -# Author: alexs.mac@gmail.com (Alex Stewart) +# `OPTIONAL_COMPONENTS` +# A list of components. Components are: +# AMD, BTF, CAMD, CCOLAMD, CHOLMOD, COLAMD, CXSPARSE, +# KLU, LDL, RBIO, SPQR, UMFPACK # - -# FindSuiteSparse.cmake - Find SuiteSparse libraries & dependencies. -# -# This module defines the following variables: -# -# SUITESPARSE_FOUND: TRUE iff SuiteSparse and all dependencies have been found. -# SUITESPARSE_INCLUDE_DIRS: Include directories for all SuiteSparse components. -# SUITESPARSE_LIBRARIES: Libraries for all SuiteSparse component libraries and -# dependencies. -# SUITESPARSE_VERSION: Extracted from UFconfig.h (<= v3) or -# SuiteSparse_config.h (>= v4). -# SUITESPARSE_MAIN_VERSION: Equal to 4 if SUITESPARSE_VERSION = 4.2.1 -# SUITESPARSE_SUB_VERSION: Equal to 2 if SUITESPARSE_VERSION = 4.2.1 -# SUITESPARSE_SUBSUB_VERSION: Equal to 1 if SUITESPARSE_VERSION = 4.2.1 -# -# SUITESPARSE_IS_BROKEN_SHARED_LINKING_UBUNTU_SYSTEM_VERSION: TRUE iff running -# on Ubuntu, SUITESPARSE_VERSION is 3.4.0 and found SuiteSparse is a system -# install, in which case found version of SuiteSparse cannot be used to link -# a shared library due to a bug (static linking is unaffected). -# -# The following variables control the behaviour of this module: -# -# SUITESPARSE_INCLUDE_DIR_HINTS: List of additional directories in which to -# search for SuiteSparse includes, -# e.g: /timbuktu/include. -# SUITESPARSE_LIBRARY_DIR_HINTS: List of additional directories in which to -# search for SuiteSparse libraries, -# e.g: /timbuktu/lib. -# -# The following variables define the presence / includes & libraries for the -# SuiteSparse components searched for, the SUITESPARSE_XX variables are the -# union of the variables for all components. +# :ref:`SuiteSparse_ROOT` +# Path list to search for SuiteSparse # -# == Symmetric Approximate Minimum Degree (AMD) -# AMD_FOUND -# AMD_INCLUDE_DIR -# AMD_LIBRARY +# Sets the following variables: # -# == Constrained Approximate Minimum Degree (CAMD) -# CAMD_FOUND -# CAMD_INCLUDE_DIR -# CAMD_LIBRARY +# :code:`SuiteSparse_FOUND` +# True if SuiteSparse was found. # -# == Column Approximate Minimum Degree (COLAMD) -# COLAMD_FOUND -# COLAMD_INCLUDE_DIR -# COLAMD_LIBRARY +# :code:`SuiteSparse_INCLUDE_DIRS` +# Path to the SuiteSparse include dirs. # -# Constrained Column Approximate Minimum Degree (CCOLAMD) -# CCOLAMD_FOUND -# CCOLAMD_INCLUDE_DIR -# CCOLAMD_LIBRARY +# :code:`SuiteSparse_LIBRARIES` +# Name of the SuiteSparse libraries. # -# == Sparse Supernodal Cholesky Factorization and Update/Downdate (CHOLMOD) -# CHOLMOD_FOUND -# CHOLMOD_INCLUDE_DIR -# CHOLMOD_LIBRARY +# :code:`SuiteSparse_<COMPONENT>_FOUND` +# Whether <COMPONENT> was found as part of SuiteSparse. # -# == Multifrontal Sparse QR (SuiteSparseQR) -# SUITESPARSEQR_FOUND -# SUITESPARSEQR_INCLUDE_DIR -# SUITESPARSEQR_LIBRARY +# .. cmake_variable:: SuiteSparse_ROOT # -# == Common configuration for all but CSparse (SuiteSparse version >= 4). -# SUITESPARSE_CONFIG_FOUND -# SUITESPARSE_CONFIG_INCLUDE_DIR -# SUITESPARSE_CONFIG_LIBRARY +# You may set this variable to have :ref:`FindSuiteSparse` look +# for SuiteSparse in the given path before inspecting +# system paths. # -# == Common configuration for all but CSparse (SuiteSparse version < 4). -# UFCONFIG_FOUND -# UFCONFIG_INCLUDE_DIR -# -# Optional SuiteSparse Dependencies: -# -# == Serial Graph Partitioning and Fill-reducing Matrix Ordering (METIS) -# METIS_FOUND -# METIS_LIBRARY - -# Reset CALLERS_CMAKE_FIND_LIBRARY_PREFIXES to its value when -# FindSuiteSparse was invoked. -macro(SUITESPARSE_RESET_FIND_LIBRARY_PREFIX) - if (MSVC) - set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}") - endif (MSVC) -endmacro(SUITESPARSE_RESET_FIND_LIBRARY_PREFIX) - -# Called if we failed to find SuiteSparse or any of it's required dependencies, -# unsets all public (designed to be used externally) variables and reports -# error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument. -macro(SUITESPARSE_REPORT_NOT_FOUND REASON_MSG) - unset(SUITESPARSE_FOUND) - unset(SUITESPARSE_INCLUDE_DIRS) - unset(SUITESPARSE_LIBRARIES) - unset(SUITESPARSE_VERSION) - unset(SUITESPARSE_MAIN_VERSION) - unset(SUITESPARSE_SUB_VERSION) - unset(SUITESPARSE_SUBSUB_VERSION) - # Do NOT unset SUITESPARSE_FOUND_REQUIRED_VARS here, as it is used by - # FindPackageHandleStandardArgs() to generate the automatic error message on - # failure which highlights which components are missing. - - suitesparse_reset_find_library_prefix() - - # Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by FindPackage() - # use the camelcase library name, not uppercase. - if (SuiteSparse_FIND_QUIETLY) - message(STATUS "Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN}) - elseif (SuiteSparse_FIND_REQUIRED) - message(FATAL_ERROR "Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN}) - else() - # Neither QUIETLY nor REQUIRED, use no priority which emits a message - # but continues configuration and allows generation. - message("-- Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN}) - endif (SuiteSparse_FIND_QUIETLY) - - # Do not call return(), s/t we keep processing if not called with REQUIRED - # and report all missing components, rather than bailing after failing to find - # the first. -endmacro(SUITESPARSE_REPORT_NOT_FOUND) -# Protect against any alternative find_package scripts for this library having -# been called previously (in a client project) which set SUITESPARSE_FOUND, but -# not the other variables we require / set here which could cause the search -# logic here to fail. -unset(SUITESPARSE_FOUND) +find_package(BLAS QUIET) -# Handle possible presence of lib prefix for libraries on MSVC, see -# also SUITESPARSE_RESET_FIND_LIBRARY_PREFIX(). -if (MSVC) - # Preserve the caller's original values for CMAKE_FIND_LIBRARY_PREFIXES - # s/t we can set it back before returning. - set(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") - # The empty string in this list is important, it represents the case when - # the libraries have no prefix (shared libraries / DLLs). - set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}") -endif (MSVC) +# look for desired componenents +set(SUITESPARSE_COMPONENTS ${SuiteSparse_FIND_COMPONENTS}) -# Specify search directories for include files and libraries (this is the union -# of the search directories for all OSs). Search user-specified hint -# directories first if supplied, and search user-installed locations first -# so that we prefer user installs to system installs where both exist. -list(APPEND SUITESPARSE_CHECK_INCLUDE_DIRS - /opt/local/include - /opt/local/include/ufsparse # Mac OS X - /usr/local/homebrew/include # Mac OS X - /usr/local/include - /usr/include) -list(APPEND SUITESPARSE_CHECK_LIBRARY_DIRS - /opt/local/lib - /opt/local/lib/ufsparse # Mac OS X - /usr/local/homebrew/lib # Mac OS X - /usr/local/lib - /usr/lib) -# Additional suffixes to try appending to each search path. -list(APPEND SUITESPARSE_CHECK_PATH_SUFFIXES - suitesparse) # Windows/Ubuntu +# resolve inter-component dependencies +list(FIND SUITESPARSE_COMPONENTS "UMFPACK" WILL_USE_UMFPACK) +if(NOT WILL_USE_UMFPACK EQUAL -1) + list(APPEND SUITESPARSE_COMPONENTS AMD CHOLMOD) +endif() +list(FIND SUITESPARSE_COMPONENTS "CHOLMOD" WILL_USE_CHOLMOD) +if(NOT WILL_USE_CHOLMOD EQUAL -1) + list(APPEND SUITESPARSE_COMPONENTS AMD CAMD COLAMD CCOLAMD) +endif() -# Wrappers to find_path/library that pass the SuiteSparse search hints/paths. -# -# suitesparse_find_component(<component> [FILES name1 [name2 ...]] -# [LIBRARIES name1 [name2 ...]] -# [REQUIRED]) -macro(suitesparse_find_component COMPONENT) - include(CMakeParseArguments) - set(OPTIONS REQUIRED) - set(MULTI_VALUE_ARGS FILES LIBRARIES) - cmake_parse_arguments(SUITESPARSE_FIND_${COMPONENT} - "${OPTIONS}" "" "${MULTI_VALUE_ARGS}" ${ARGN}) +if(SUITESPARSE_COMPONENTS) + list(REMOVE_DUPLICATES SUITESPARSE_COMPONENTS) +endif() - if (SUITESPARSE_FIND_${COMPONENT}_REQUIRED) - list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS ${COMPONENT}_FOUND) +# find SuiteSparse config: +# look for library at positions given by the user +find_library(SUITESPARSE_CONFIG_LIB + NAMES "suitesparseconfig" + PATHS ${SuiteSparse_ROOT} + PATH_SUFFIXES "lib" "lib32" "lib64" "Lib" + NO_DEFAULT_PATH +) +# now also include the default paths +find_library(SUITESPARSE_CONFIG_LIB + NAMES "suitesparseconfig" + PATH_SUFFIXES "lib" "lib32" "lib64" "Lib" +) + +#look for header files at positions given by the user +find_path(SUITESPARSE_INCLUDE_DIR + NAMES "SuiteSparse_config.h" + PATHS ${SuiteSparse_ROOT} + PATH_SUFFIXES "SuiteSparse_config" "SuiteSparse_config/include" "suitesparse" "include" "src" "SuiteSparse_config/Include" + NO_DEFAULT_PATH +) +#now also look for default paths +find_path(SUITESPARSE_INCLUDE_DIR + NAMES "SuiteSparse_config.h" + PATH_SUFFIXES "SuiteSparse_config" "SuiteSparse_config/include" "suitesparse" "include" "src" "SuiteSparse_config/Include" +) + +foreach(_component ${SUITESPARSE_COMPONENTS}) + string(TOLOWER ${_component} _componentLower) + + #look for library at positions given by the user + find_library(${_component}_LIBRARY + NAMES "${_componentLower}" + PATHS ${SuiteSparse_ROOT} + PATH_SUFFIXES "lib" "lib32" "lib64" "${_component}" "${_component}/Lib" + NO_DEFAULT_PATH + ) + #now also include the default paths + find_library(${_component}_LIBRARY + NAMES "${_componentLower}" + PATH_SUFFIXES "lib" "lib32" "lib64" "${_component}" "${_component}/Lib" + ) + + #look for header files at positions given by the user + find_path(${_component}_INCLUDE_DIR + NAMES "${_componentLower}.h" + PATHS ${SuiteSparse_ROOT} + PATH_SUFFIXES "${_componentLower}" "include/${_componentLower}" "suitesparse" "include" "src" "${_component}" "${_component}/Include" + NO_DEFAULT_PATH + ) + #now also look for default paths + find_path(${_component}_INCLUDE_DIR + NAMES "${_componentLower}.h" + PATH_SUFFIXES "${_componentLower}" "include/${_componentLower}" "suitesparse" "include" "${_component}" "${_component}/Include" + ) +endforeach() + +# SPQR has different header file name SuiteSparseQR.hpp +#look for header files at positions given by the user +find_path(SPQR_INCLUDE_DIR + NAMES "SuiteSparseQR.hpp" + PATHS ${SuiteSparse_ROOT} + PATH_SUFFIXES "spqr" "include/spqr" "suitesparse" "include" "src" "SPQR" "SPQR/Include" + NO_DEFAULT_PATH +) +#now also look for default paths +find_path(SPQR_INCLUDE_DIR + NAMES "SuiteSparseQR.hpp" + PATH_SUFFIXES "spqr" "include/spqr" "suitesparse" "include" "SPQR" "SPQR/Include" +) + +# resolve inter-modular dependencies + +# CHOLMOD requires AMD, COLAMD; CAMD and CCOLAMD are optional +if(CHOLMOD_LIBRARY) + if(NOT (AMD_LIBRARY AND COLAMD_LIBRARY)) + message(WARNING "CHOLMOD requires AMD and COLAMD which were not found, skipping the test.") + set(SuiteSparse_CHOLMOD_FOUND "CHOLMOD requires AMD and COLAMD-NOTFOUND") endif() - set(${COMPONENT}_FOUND TRUE) - if (SUITESPARSE_FIND_${COMPONENT}_FILES) - find_path(${COMPONENT}_INCLUDE_DIR - NAMES ${SUITESPARSE_FIND_${COMPONENT}_FILES} - HINTS ${SUITESPARSE_INCLUDE_DIR_HINTS} - PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS} - PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES}) - if (${COMPONENT}_INCLUDE_DIR) - message(STATUS "Found ${COMPONENT} headers in: " - "${${COMPONENT}_INCLUDE_DIR}") - mark_as_advanced(${COMPONENT}_INCLUDE_DIR) - else() - # Specified headers not found. - set(${COMPONENT}_FOUND FALSE) - if (SUITESPARSE_FIND_${COMPONENT}_REQUIRED) - suitesparse_report_not_found( - "Did not find ${COMPONENT} header (required SuiteSparse component).") - else() - message(STATUS "Did not find ${COMPONENT} header (optional " - "SuiteSparse component).") - # Hide optional vars from CMake GUI even if not found. - mark_as_advanced(${COMPONENT}_INCLUDE_DIR) - endif() - endif() + list(APPEND CHOLMOD_LIBRARY ${AMD_LIBRARY} ${COLAMD_LIBRARY}) + if(CAMD_LIBRARY) + list(APPEND CHOLMOD_LIBRARY ${CAMD_LIBRARY}) endif() - - if (SUITESPARSE_FIND_${COMPONENT}_LIBRARIES) - find_library(${COMPONENT}_LIBRARY - NAMES ${SUITESPARSE_FIND_${COMPONENT}_LIBRARIES} - HINTS ${SUITESPARSE_LIBRARY_DIR_HINTS} - PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS} - PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES}) - if (${COMPONENT}_LIBRARY) - message(STATUS "Found ${COMPONENT} library: ${${COMPONENT}_LIBRARY}") - mark_as_advanced(${COMPONENT}_LIBRARY) - else () - # Specified libraries not found. - set(${COMPONENT}_FOUND FALSE) - if (SUITESPARSE_FIND_${COMPONENT}_REQUIRED) - suitesparse_report_not_found( - "Did not find ${COMPONENT} library (required SuiteSparse component).") - else() - message(STATUS "Did not find ${COMPONENT} library (optional SuiteSparse " - "dependency)") - # Hide optional vars from CMake GUI even if not found. - mark_as_advanced(${COMPONENT}_LIBRARY) - endif() - endif() + if(CCOLAMD_LIBRARY) + list(APPEND CHOLMOD_LIBRARY ${CCOLAMD_LIBRARY}) endif() -endmacro() - -# Given the number of components of SuiteSparse, and to ensure that the -# automatic failure message generated by FindPackageHandleStandardArgs() -# when not all required components are found is helpful, we maintain a list -# of all variables that must be defined for SuiteSparse to be considered found. -unset(SUITESPARSE_FOUND_REQUIRED_VARS) - -# BLAS. -find_package(BLAS QUIET) -if (NOT BLAS_FOUND) - suitesparse_report_not_found( - "Did not find BLAS library (required for SuiteSparse).") -endif (NOT BLAS_FOUND) -list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS BLAS_FOUND) - -# LAPACK. -find_package(LAPACK QUIET) -if (NOT LAPACK_FOUND) - suitesparse_report_not_found( - "Did not find LAPACK library (required for SuiteSparse).") -endif (NOT LAPACK_FOUND) -list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS LAPACK_FOUND) + list(REVERSE CHOLMOD_LIBRARY) + # remove duplicates + list(REMOVE_DUPLICATES CHOLMOD_LIBRARY) + list(REVERSE CHOLMOD_LIBRARY) +endif() -suitesparse_find_component(AMD REQUIRED FILES amd.h LIBRARIES amd) -suitesparse_find_component(CAMD REQUIRED FILES camd.h LIBRARIES camd) -suitesparse_find_component(COLAMD REQUIRED FILES colamd.h LIBRARIES colamd) -suitesparse_find_component(CCOLAMD REQUIRED FILES ccolamd.h LIBRARIES ccolamd) -suitesparse_find_component(CHOLMOD REQUIRED FILES cholmod.h LIBRARIES cholmod) -suitesparse_find_component( - SUITESPARSEQR REQUIRED FILES SuiteSparseQR.hpp LIBRARIES spqr) -if (SUITESPARSEQR_FOUND) - # SuiteSparseQR may be compiled with Intel Threading Building Blocks, - # we assume that if TBB is installed, SuiteSparseQR was compiled with - # support for it, this will do no harm if it wasn't. - find_package(TBB QUIET) - if (TBB_FOUND) - message(STATUS "Found Intel Thread Building Blocks (TBB) library " - "(${TBB_VERSION}) assuming SuiteSparseQR was compiled " - "with TBB.") - # Add the TBB libraries to the SuiteSparseQR libraries (the only - # libraries to optionally depend on TBB). - list(APPEND SUITESPARSEQR_LIBRARY ${TBB_LIBRARIES}) +# UMFPack requires AMD, can depend on CHOLMOD +if(UMFPACK_LIBRARY) + # check wether cholmod was found + if(CHOLMOD_LIBRARY) + list(APPEND UMFPACK_LIBRARY ${CHOLMOD_LIBRARY}) else() - message(STATUS "Did not find Intel TBB library, assuming SuiteSparseQR was " - "not compiled with TBB.") + list(APPEND UMFPACK_LIBRARY ${AMD_LIBRARY}) endif() -endif(SUITESPARSEQR_FOUND) - -# UFconfig / SuiteSparse_config. -# -# If SuiteSparse version is >= 4 then SuiteSparse_config is required. -# For SuiteSparse 3, UFconfig.h is required. -suitesparse_find_component( - SUITESPARSE_CONFIG FILES SuiteSparse_config.h LIBRARIES suitesparseconfig) - -if (SUITESPARSE_CONFIG_FOUND) - # SuiteSparse_config (SuiteSparse version >= 4) requires librt library for - # timing by default when compiled on Linux or Unix, but not on OSX (which - # does not have librt). - if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR UNIX AND NOT APPLE) - suitesparse_find_component(LIBRT LIBRARIES rt) - if (LIBRT_FOUND) - message(STATUS "Adding librt: ${LIBRT_LIBRARY} to " - "SuiteSparse_config libraries (required on Linux & Unix [not OSX] if " - "SuiteSparse is compiled with timing).") - list(APPEND SUITESPARSE_CONFIG_LIBRARY ${LIBRT_LIBRARY}) - else() - message(STATUS "Could not find librt, but found SuiteSparse_config, " - "assuming that SuiteSparse was compiled without timing.") - endif () - endif (CMAKE_SYSTEM_NAME MATCHES "Linux" OR UNIX AND NOT APPLE) -else() - # Failed to find SuiteSparse_config (>= v4 installs), instead look for - # UFconfig header which should be present in < v4 installs. - suitesparse_find_component(UFCONFIG FILES UFconfig.h) -endif () - -if (NOT SUITESPARSE_CONFIG_FOUND AND - NOT UFCONFIG_FOUND) - suitesparse_report_not_found( - "Failed to find either: SuiteSparse_config header & library (should be " - "present in all SuiteSparse >= v4 installs), or UFconfig header (should " - "be present in all SuiteSparse < v4 installs).") + list(REVERSE UMFPACK_LIBRARY) + # remove duplicates + list(REMOVE_DUPLICATES UMFPACK_LIBRARY) + list(REVERSE UMFPACK_LIBRARY) endif() -# Extract the SuiteSparse version from the appropriate header (UFconfig.h for -# <= v3, SuiteSparse_config.h for >= v4). -list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS SUITESPARSE_VERSION) - -if (UFCONFIG_FOUND) - # SuiteSparse version <= 3. - set(SUITESPARSE_VERSION_FILE ${UFCONFIG_INCLUDE_DIR}/UFconfig.h) - if (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) - suitesparse_report_not_found( - "Could not find file: ${SUITESPARSE_VERSION_FILE} containing version " - "information for <= v3 SuiteSparse installs, but UFconfig was found " - "(only present in <= v3 installs).") - else (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) - file(READ ${SUITESPARSE_VERSION_FILE} UFCONFIG_CONTENTS) - - string(REGEX MATCH "#define SUITESPARSE_MAIN_VERSION [0-9]+" - SUITESPARSE_MAIN_VERSION "${UFCONFIG_CONTENTS}") - string(REGEX REPLACE "#define SUITESPARSE_MAIN_VERSION ([0-9]+)" "\\1" - SUITESPARSE_MAIN_VERSION "${SUITESPARSE_MAIN_VERSION}") - - string(REGEX MATCH "#define SUITESPARSE_SUB_VERSION [0-9]+" - SUITESPARSE_SUB_VERSION "${UFCONFIG_CONTENTS}") - string(REGEX REPLACE "#define SUITESPARSE_SUB_VERSION ([0-9]+)" "\\1" - SUITESPARSE_SUB_VERSION "${SUITESPARSE_SUB_VERSION}") - - string(REGEX MATCH "#define SUITESPARSE_SUBSUB_VERSION [0-9]+" - SUITESPARSE_SUBSUB_VERSION "${UFCONFIG_CONTENTS}") - string(REGEX REPLACE "#define SUITESPARSE_SUBSUB_VERSION ([0-9]+)" "\\1" - SUITESPARSE_SUBSUB_VERSION "${SUITESPARSE_SUBSUB_VERSION}") - - # This is on a single line s/t CMake does not interpret it as a list of - # elements and insert ';' separators which would result in 4.;2.;1 nonsense. - set(SUITESPARSE_VERSION - "${SUITESPARSE_MAIN_VERSION}.${SUITESPARSE_SUB_VERSION}.${SUITESPARSE_SUBSUB_VERSION}") - endif (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) -endif (UFCONFIG_FOUND) - -if (SUITESPARSE_CONFIG_FOUND) - # SuiteSparse version >= 4. - set(SUITESPARSE_VERSION_FILE - ${SUITESPARSE_CONFIG_INCLUDE_DIR}/SuiteSparse_config.h) - if (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) - suitesparse_report_not_found( - "Could not find file: ${SUITESPARSE_VERSION_FILE} containing version " - "information for >= v4 SuiteSparse installs, but SuiteSparse_config was " - "found (only present in >= v4 installs).") - else (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) - file(READ ${SUITESPARSE_VERSION_FILE} SUITESPARSE_CONFIG_CONTENTS) - - string(REGEX MATCH "#define SUITESPARSE_MAIN_VERSION [0-9]+" - SUITESPARSE_MAIN_VERSION "${SUITESPARSE_CONFIG_CONTENTS}") - string(REGEX REPLACE "#define SUITESPARSE_MAIN_VERSION ([0-9]+)" "\\1" - SUITESPARSE_MAIN_VERSION "${SUITESPARSE_MAIN_VERSION}") - - string(REGEX MATCH "#define SUITESPARSE_SUB_VERSION [0-9]+" - SUITESPARSE_SUB_VERSION "${SUITESPARSE_CONFIG_CONTENTS}") - string(REGEX REPLACE "#define SUITESPARSE_SUB_VERSION ([0-9]+)" "\\1" - SUITESPARSE_SUB_VERSION "${SUITESPARSE_SUB_VERSION}") - - string(REGEX MATCH "#define SUITESPARSE_SUBSUB_VERSION [0-9]+" - SUITESPARSE_SUBSUB_VERSION "${SUITESPARSE_CONFIG_CONTENTS}") - string(REGEX REPLACE "#define SUITESPARSE_SUBSUB_VERSION ([0-9]+)" "\\1" - SUITESPARSE_SUBSUB_VERSION "${SUITESPARSE_SUBSUB_VERSION}") - - # This is on a single line s/t CMake does not interpret it as a list of - # elements and insert ';' separators which would result in 4.;2.;1 nonsense. - set(SUITESPARSE_VERSION - "${SUITESPARSE_MAIN_VERSION}.${SUITESPARSE_SUB_VERSION}.${SUITESPARSE_SUBSUB_VERSION}") - endif (NOT EXISTS ${SUITESPARSE_VERSION_FILE}) -endif (SUITESPARSE_CONFIG_FOUND) - -# METIS (Optional dependency). -suitesparse_find_component(METIS LIBRARIES metis) +# check wether everything was found +foreach(_component ${SUITESPARSE_COMPONENTS}) + # variable used for component handling + if(${_component}_LIBRARY AND ${_component}_INCLUDE_DIR) + set(SuiteSparse_${_component}_FOUND TRUE) + else() + set(SuiteSparse_${_component}_FOUND FALSE) + endif() + set(HAVE_SUITESPARSE_${_component} ${SuiteSparse_${_component}_FOUND}) + if(SuiteSparse_${_component}_FOUND) + list(APPEND SUITESPARSE_INCLUDE_DIR "${${_component}_INCLUDE_DIR}") + list(APPEND SUITESPARSE_LIBRARY "${${_component}_LIBRARY}") + endif() -# Only mark SuiteSparse as found if all required components and dependencies -# have been found. -set(SUITESPARSE_FOUND TRUE) -foreach(REQUIRED_VAR ${SUITESPARSE_FOUND_REQUIRED_VARS}) - if (NOT ${REQUIRED_VAR}) - set(SUITESPARSE_FOUND FALSE) - endif (NOT ${REQUIRED_VAR}) -endforeach(REQUIRED_VAR ${SUITESPARSE_FOUND_REQUIRED_VARS}) + mark_as_advanced( + HAVE_SUITESPARSE_${_component} + SuiteSparse_${_component}_FOUND + ${_component}_INCLUDE_DIR + ${_component}_LIBRARY) +endforeach() + +# check version, for SPQR we need at least SuiteSparse 4.3 +if(SuiteSparse_SPQR_FOUND) + include(CheckCSourceCompiles) + include(CMakePushCheckState) + cmake_push_check_state() + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${SUITESPARSE_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${SUITESPARSE_LIBRARY}) + # check whether version is at least 4.3 + check_c_source_compiles(" + #include <SuiteSparse_config.h> + int main(void) + { + #ifndef SUITESPARSE_HAS_VERSION_FUNCTION + #error SuiteSparse <= 4.2.0 too old, required version 4.3 or newer for SPQR. + #endif + #if SUITESPARSE_VERSION <= 4003 + #error SuiteSparse too old, required version 4.3 or newer for SPQR. + #endif + return 0; + }" + SUITESPARSE_MIN_VERSION_4_3) + + if(NOT SUITESPARSE_MIN_VERSION_4_3) + set(SuiteSparse_SPQR_FOUND FALSE) + set(HAVE_SUITESPARSE_SPQR FALSE) + endif() + cmake_pop_check_state() +endif() -if (SUITESPARSE_FOUND) - list(APPEND SUITESPARSE_INCLUDE_DIRS - ${AMD_INCLUDE_DIR} - ${CAMD_INCLUDE_DIR} - ${COLAMD_INCLUDE_DIR} - ${CCOLAMD_INCLUDE_DIR} - ${CHOLMOD_INCLUDE_DIR} - ${SUITESPARSEQR_INCLUDE_DIR}) - # Handle config separately, as otherwise at least one of them will be set - # to NOTFOUND which would cause any check on SUITESPARSE_INCLUDE_DIRS to fail. - if (SUITESPARSE_CONFIG_FOUND) - list(APPEND SUITESPARSE_INCLUDE_DIRS - ${SUITESPARSE_CONFIG_INCLUDE_DIR}) - endif (SUITESPARSE_CONFIG_FOUND) - if (UFCONFIG_FOUND) - list(APPEND SUITESPARSE_INCLUDE_DIRS - ${UFCONFIG_INCLUDE_DIR}) - endif (UFCONFIG_FOUND) - # As SuiteSparse includes are often all in the same directory, remove any - # repetitions. - list(REMOVE_DUPLICATES SUITESPARSE_INCLUDE_DIRS) +list(APPEND SUITESPARSE_LIBRARY ${SUITESPARSE_CONFIG_LIB}) - # Important: The ordering of these libraries is *NOT* arbitrary, as these - # could potentially be static libraries their link ordering is important. - list(APPEND SUITESPARSE_LIBRARIES - ${SUITESPARSEQR_LIBRARY} - ${CHOLMOD_LIBRARY} - ${CCOLAMD_LIBRARY} - ${CAMD_LIBRARY} - ${COLAMD_LIBRARY} - ${AMD_LIBRARY} - ${LAPACK_LIBRARIES} - ${BLAS_LIBRARIES}) - if (SUITESPARSE_CONFIG_FOUND) - list(APPEND SUITESPARSE_LIBRARIES - ${SUITESPARSE_CONFIG_LIBRARY}) - endif (SUITESPARSE_CONFIG_FOUND) - if (METIS_FOUND) - list(APPEND SUITESPARSE_LIBRARIES - ${METIS_LIBRARY}) - endif (METIS_FOUND) +# make them unique +if(SUITESPARSE_INCLUDE_DIR) + list(REMOVE_DUPLICATES SUITESPARSE_INCLUDE_DIR) +endif() +if(SUITESPARSE_LIBRARY) + list(REVERSE SUITESPARSE_LIBRARY) + list(REMOVE_DUPLICATES SUITESPARSE_LIBRARY) + list(REVERSE SUITESPARSE_LIBRARY) endif() -# Determine if we are running on Ubuntu with the package install of SuiteSparse -# which is broken and does not support linking a shared library. -set(SUITESPARSE_IS_BROKEN_SHARED_LINKING_UBUNTU_SYSTEM_VERSION FALSE) -if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND - SUITESPARSE_VERSION VERSION_EQUAL 3.4.0) - find_program(LSB_RELEASE_EXECUTABLE lsb_release) - if (LSB_RELEASE_EXECUTABLE) - # Any even moderately recent Ubuntu release (likely to be affected by - # this bug) should have lsb_release, if it isn't present we are likely - # on a different Linux distribution (should be fine). - execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -si - OUTPUT_VARIABLE LSB_DISTRIBUTOR_ID - OUTPUT_STRIP_TRAILING_WHITESPACE) +# behave like a CMake module is supposed to behave +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + "SuiteSparse" + FOUND_VAR SuiteSparse_FOUND + REQUIRED_VARS + BLAS_FOUND + SUITESPARSE_INCLUDE_DIR + SUITESPARSE_LIBRARY + HANDLE_COMPONENTS +) + +mark_as_advanced( + SUITESPARSE_INCLUDE_DIR + SUITESPARSE_LIBRARY + SUITESPARSE_CONFIG_LIB + SUITESPARSE_MIN_VERSION_4_3 + WILL_USE_CHOLMOD + WILL_USE_UMFPACK) + +# if both headers and library are found, store results +if(SuiteSparse_FOUND) + set(SuiteSparse_LIBRARIES ${SUITESPARSE_LIBRARY}) + set(SuiteSparse_INCLUDE_DIRS ${SUITESPARSE_INCLUDE_DIR}) + # log result + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining location of SuiteSparse succeeded:\n" + "Include directory: ${SuiteSparse_INCLUDE_DIRS}\n" + "Library directory: ${SuiteSparse_LIBRARIES}\n\n") + set(SuiteSparse_COMPILER_FLAGS) + foreach(dir ${SuiteSparse_INCLUDE_DIRS}) + set(SuiteSparse_COMPILER_FLAGS "${SuiteSparse_COMPILER_FLAGS} -I${dir}/") + endforeach() +else() + # log errornous result + file(APPEND ${CMAKE_BINARY_DIR}${CMAKES_FILES_DIRECTORY}/CMakeError.log + "Determing location of SuiteSparse failed:\n" + "Include directory: ${SuiteSparse_INCLUDE_DIRS}\n" + "Library directory: ${SuiteSparse_LIBRARIES}\n\n") +endif() - if (LSB_DISTRIBUTOR_ID MATCHES "Ubuntu" AND - SUITESPARSE_LIBRARIES MATCHES "/usr/lib/libamd") - # We are on Ubuntu, and the SuiteSparse version matches the broken - # system install version and is a system install. - set(SUITESPARSE_IS_BROKEN_SHARED_LINKING_UBUNTU_SYSTEM_VERSION TRUE) - message(STATUS "Found system install of SuiteSparse " - "${SUITESPARSE_VERSION} running on Ubuntu, which has a known bug " - "preventing linking of shared libraries (static linking unaffected).") - endif (LSB_DISTRIBUTOR_ID MATCHES "Ubuntu" AND - SUITESPARSE_LIBRARIES MATCHES "/usr/lib/libamd") - endif (LSB_RELEASE_EXECUTABLE) -endif (CMAKE_SYSTEM_NAME MATCHES "Linux" AND - SUITESPARSE_VERSION VERSION_EQUAL 3.4.0) +#set HAVE_SUITESPARSE for config.h +set(HAVE_SUITESPARSE ${SuiteSparse_FOUND}) +set(HAVE_UMFPACK ${SuiteSparse_UMFPACK_FOUND}) -suitesparse_reset_find_library_prefix() -# Handle REQUIRED and QUIET arguments to FIND_PACKAGE -include(FindPackageHandleStandardArgs) -if (SUITESPARSE_FOUND) - find_package_handle_standard_args(SuiteSparse - REQUIRED_VARS ${SUITESPARSE_FOUND_REQUIRED_VARS} - VERSION_VAR SUITESPARSE_VERSION - FAIL_MESSAGE "Failed to find some/all required components of SuiteSparse.") -else (SUITESPARSE_FOUND) - # Do not pass VERSION_VAR to FindPackageHandleStandardArgs() if we failed to - # find SuiteSparse to avoid a confusing autogenerated failure message - # that states 'not found (missing: FOO) (found version: x.y.z)'. - find_package_handle_standard_args(SuiteSparse - REQUIRED_VARS ${SUITESPARSE_FOUND_REQUIRED_VARS} - FAIL_MESSAGE "Failed to find some/all required components of SuiteSparse.") -endif (SUITESPARSE_FOUND) diff --git a/openfpm_numerics b/openfpm_numerics index 8998b7a730e8beaeca1b5f06793fe25d10f8ef16..362f517377e313a26904e6bfcaf4bf0613bd6906 160000 --- a/openfpm_numerics +++ b/openfpm_numerics @@ -1 +1 @@ -Subproject commit 8998b7a730e8beaeca1b5f06793fe25d10f8ef16 +Subproject commit 362f517377e313a26904e6bfcaf4bf0613bd6906