Merge pull request #346 from andlaus/fix_superlu_and_quadmath

Fix superlu and quadmath
This commit is contained in:
Bård Skaflestad 2013-08-26 06:07:22 -07:00
commit 8b98840a72
2 changed files with 76 additions and 89 deletions

View File

@ -6,6 +6,7 @@
# QUADMATH_LIBRARIES # QUADMATH_LIBRARIES
# #
# perform tests # perform tests
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles) include(CheckCXXSourceCompiles)
include(CMakePushCheckState) include(CMakePushCheckState)

View File

@ -15,75 +15,80 @@
# SUPERLU_LIBRARIES Name to the SuperLU library. # SUPERLU_LIBRARIES Name to the SuperLU library.
# #
# adds SuperLU flags to the targets include(CheckIncludeFiles)
function(add_dune_superlu_flags _targets) include(CMakePushCheckState)
if(SUPERLU_FOUND) include(CheckCSourceCompiles)
foreach(_target ${_targets})
target_link_libraries(${_target} ${SUPERLU_DUNE_LIBRARIES})
get_target_property(_props ${_target} COMPILE_FLAGS)
string(REPLACE "_props-NOTFOUND" "" _props "${_props}")
set_target_properties(${_target} PROPERTIES COMPILE_FLAGS
"${_props} ${SUPERLU_DUNE_COMPILE_FLAGS} -DENABLE_SUPERLU=1")
endforeach(_target ${_targets})
endif(SUPERLU_FOUND)
endfunction(add_dune_superlu_flags)
# look for BLAS cmake_push_check_state()
find_package(BLAS QUIET REQUIRED)
if(NOT BLAS_FOUND)
message(WARNING "SuperLU requires BLAS which was not found, skipping the test.")
return()
endif(NOT BLAS_FOUND)
# look for files only at the positions given by the user if # find out the size of a pointer. this is required to only search for
# an explicit path is specified # libraries in the directories relevant for the architecture
if (SUPERLU_PREFIX OR SUPERLU_ROOT)
set (_no_default_path "NO_DEFAULT_PATH")
else (SUPERLU_PREFIX OR SUPERLU_ROOT)
set (_no_default_path "")
endif (SUPERLU_PREFIX OR SUPERLU_ROOT)
# look for header files
find_path(SUPERLU_INCLUDE_DIR
NAMES supermatrix.h
PATHS ${SUPERLU_PREFIX} ${SUPERLU_ROOT}
PATH_SUFFIXES "superlu" "include/superlu" "include" "SRC"
${_no_default_path}
)
# only search in architecture-relevant directory
if (CMAKE_SIZEOF_VOID_P) if (CMAKE_SIZEOF_VOID_P)
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}") math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
endif (CMAKE_SIZEOF_VOID_P) endif (CMAKE_SIZEOF_VOID_P)
# look for library # look for files only at the positions given by the user if
find_library(SUPERLU_LIBRARY # an explicit path is specified
NAMES "superlu_4.3" "superlu_4.2" "superlu_4.1" "superlu_4.0" "superlu_3.1" "superlu_3.0" "superlu" if(SUPERLU_ROOT)
PATHS ${SUPERLU_PREFIX} ${SUPERLU_ROOT} set (_no_default_path "NO_DEFAULT_PATH")
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" else()
${_no_default_path} set (_no_default_path "")
) endif()
# check version specific macros # look for a system-wide BLAS library
include(CheckCSourceCompiles) find_package(BLAS QUIET)
include(CMakePushCheckState)
cmake_push_check_state() # look for the internal SuperLU blas library (but only if no
# system-wide library was found and a path to the superLU library was
# specified)
set(SUPERLU_BLAS_LIBRARY "")
if (BLAS_FOUND)
list(APPEND SUPERLU_BLAS_LIBRARY "${BLAS_LIBRARIES}")
elseif(SUPERLU_ROOT)
find_library(SUPERLU_BLAS_LIBRARY
NAMES "blas"
PATHS ${SUPERLU_ROOT}
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
NO_DEFAULT_PATH)
endif()
# print message if there was still no blas found!
if(NOT BLAS_FOUND AND NOT SUPERLU_BLAS_LIBRARY)
message("BLAS not found but required for SuperLU")
return()
endif()
list(APPEND CMAKE_REQUIRED_LIBRARIES "${SUPERLU_BLAS_LIBRARY}")
# find the directory containing the SuperLU include files
if (NOT SUPERLU_INCLUDE_DIR)
find_path(SUPERLU_INCLUDE_DIR
NAMES "supermatrix.h"
PATHS ${SUPERLU_ROOT}
PATH_SUFFIXES "superlu" "include/superlu" "include" "SRC"
${_no_default_path}
)
endif()
if(NOT SUPERLU_INCLUDE_DIR)
message("Directory with the SuperLU include files not found")
return()
endif()
list(APPEND CMAKE_REQUIRED_INCLUDES "${SUPERLU_INCLUDE_DIR}")
# look for actual SuperLU library
if (NOT SUPERLU_LIBRARY)
find_library(SUPERLU_LIBRARY
NAMES "superlu_4.3" "superlu_4.2" "superlu_4.1" "superlu_4.0" "superlu_3.1" "superlu_3.0" "superlu"
PATHS ${SUPERLU_ROOT}
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
${_no_default_path}
)
endif()
if(NOT SUPERLU_LIBRARY)
message("Directory with the SuperLU library not found")
return()
endif()
list(APPEND CMAKE_REQUIRED_LIBRARIES "${SUPERLU_LIBRARY}")
# we need if clauses here because variable is set variable-NOTFOUND
# if the searches above were not successful
# Without them CMake print errors like:
# "CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
# Please set them or make sure they are set and tested correctly in the CMake files:"
#
if(SUPERLU_INCLUDE_DIR)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${SUPERLU_INCLUDE_DIR})
endif(SUPERLU_INCLUDE_DIR)
if(SUPERLU_LIBRARY)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${SUPERLU_LIBRARY})
endif(SUPERLU_LIBRARY)
if(BLAS_LIBRARIES)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${BLAS_LIBRARIES})
endif(BLAS_LIBRARIES)
# check whether "mem_usage_t.expansions" was found in "slu_ddefs.h" # check whether "mem_usage_t.expansions" was found in "slu_ddefs.h"
CHECK_C_SOURCE_COMPILES(" CHECK_C_SOURCE_COMPILES("
#include <slu_ddefs.h> #include <slu_ddefs.h>
@ -94,7 +99,6 @@ int main(void)
}" }"
HAVE_MEM_USAGE_T_EXPANSIONS) HAVE_MEM_USAGE_T_EXPANSIONS)
# check whether version is at least 4.3
CHECK_C_SOURCE_COMPILES(" CHECK_C_SOURCE_COMPILES("
#include <slu_ddefs.h> #include <slu_ddefs.h>
int main(void) int main(void)
@ -120,7 +124,7 @@ if(SUPERLU_MIN_VERSION_4_3)
else() else()
set(SUPERLU_WITH_VERSION "SuperLU <= 4.2, post 2005" CACHE STRING set(SUPERLU_WITH_VERSION "SuperLU <= 4.2, post 2005" CACHE STRING
"Human readable string containing SuperLU version information.") "Human readable string containing SuperLU version information.")
endif(SUPERLU_MIN_VERSION_4_3) endif()
# behave like a CMake module is supposed to behave # behave like a CMake module is supposed to behave
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
@ -128,36 +132,18 @@ find_package_handle_standard_args(
"SuperLU" "SuperLU"
DEFAULT_MSG DEFAULT_MSG
SUPERLU_INCLUDE_DIR SUPERLU_INCLUDE_DIR
SUPERLU_LIBRARY SUPERLU_LIBRARY)
)
mark_as_advanced(SUPERLU_INCLUDE_DIR SUPERLU_LIBRARY) mark_as_advanced(SUPERLU_INCLUDE_DIR SUPERLU_LIBRARY)
# if both headers and library are found, store results # if both headers and library are found, store results
if(SUPERLU_FOUND) if(SUPERLU_FOUND)
set(SUPERLU_INCLUDE_DIRS ${SUPERLU_INCLUDE_DIR}) set(SUPERLU_INCLUDE_DIRS ${SUPERLU_INCLUDE_DIR})
set(SUPERLU_LIBRARIES ${SUPERLU_LIBRARY} ${BLAS_LIBRARIES}) set(SUPERLU_LIBRARIES ${SUPERLU_LIBRARY})
set(SUPERLU_DEFINITIONS "-DENABLE_SUPERLU=1")
# log result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determing location of ${SUPERLU_WITH_VERSION} succeded:\n"
"Include directory: ${SUPERLU_INCLUDE_DIRS}\n"
"Library directory: ${SUPERLU_LIBRARIES}\n\n")
set(SUPERLU_DUNE_COMPILE_FLAGS "-I${SUPERLU_INCLUDE_DIRS}"
CACHE STRING "Compile flags used by DUNE when compiling SuperLU programs")
set(SUPERLU_DUNE_LIBRARIES ${SUPERLU_LIBRARIES} ${BLAS_LIBRARIES}
CACHE STRING "Libraries used by DUNE when linking SuperLU programs")
else(SUPERLU_FOUND)
# log errornous result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determing location of SuperLU failed:\n"
"Include directory: ${SUPERLU_INCLUDE_DIRS}\n"
"Library directory: ${SUPERLU_LIBRARIES}\n\n")
endif(SUPERLU_FOUND)
# set HAVE_SUPERLU for config.h if (SUPERLU_BLAS_LIBRARY)
if(SUPERLU_FOUND) list(APPEND SUPERLU_LIBRARIES ${SUPERLU_BLAS_LIBRARY})
set(HAVE_SUPERLU 1) endif()
else(SUPERLU_FOUND) endif()
set(HAVE_SUPERLU "")
endif(SUPERLU_FOUND) cmake_pop_check_state()