Skip to content
Snippets Groups Projects
Commit 2ee54677 authored by Christoph Grüninger's avatar Christoph Grüninger
Browse files

[CMake] Fix newly introduced bugs in Find(SuiteSparse, UMFPack)

* Fix capitalization of SUITESPARSE_INCLUDE_DIRS
* Drop PATHS when searching SuiteSparse_config.h in default paths
* Add variable dereferencing in string(TOLOWER
* Set SuiteSparse_${_component}_FOUND only TRUE if actually found
* Mark more variables as advanced
parent dddbbb04
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
# :code:`SuiteSparse_FOUND` # :code:`SuiteSparse_FOUND`
# True if SuiteSparse was found. # True if SuiteSparse was found.
# #
# :code:`SUITESPARSE_INCLUDE_DIRS` # :code:`SuiteSparse_INCLUDE_DIRS`
# Path to the SuiteSparse include dirs. # Path to the SuiteSparse include dirs.
# #
# :code:`SuiteSparse_LIBRARIES` # :code:`SuiteSparse_LIBRARIES`
...@@ -77,12 +77,11 @@ find_path(SUITESPARSE_INCLUDE_DIR ...@@ -77,12 +77,11 @@ find_path(SUITESPARSE_INCLUDE_DIR
#now also look for default paths #now also look for default paths
find_path(SUITESPARSE_INCLUDE_DIR find_path(SUITESPARSE_INCLUDE_DIR
NAMES "SuiteSparse_config.h" NAMES "SuiteSparse_config.h"
PATHS ${SuiteSparse_ROOT}
PATH_SUFFIXES "SuiteSparse_config" "SuiteSparse_config/include" "suitesparse" "include" "src" "SuiteSparse_config/Include" PATH_SUFFIXES "SuiteSparse_config" "SuiteSparse_config/include" "suitesparse" "include" "src" "SuiteSparse_config/Include"
) )
foreach(_component ${SUITESPARSE_COMPONENTS}) foreach(_component ${SUITESPARSE_COMPONENTS})
string(TOLOWER _component _componentLower) string(TOLOWER ${_component} _componentLower)
#look for library at positions given by the user #look for library at positions given by the user
find_library(${_component}_LIBRARY find_library(${_component}_LIBRARY
...@@ -151,8 +150,8 @@ endif() ...@@ -151,8 +150,8 @@ endif()
# check wether everything was found # check wether everything was found
foreach(_component ${SUITESPARSE_COMPONENTS}) foreach(_component ${SUITESPARSE_COMPONENTS})
# variable used for component handling # variable used for component handling
set(SuiteSparse_${_component}_FOUND TRUE)
if(${_component}_LIBRARY AND ${_component}_INCLUDE_DIR) if(${_component}_LIBRARY AND ${_component}_INCLUDE_DIR)
set(SuiteSparse_${_component}_FOUND TRUE)
list(APPEND SUITESPARSE_INCLUDE_DIR "${${_component}_INCLUDE_DIR}") list(APPEND SUITESPARSE_INCLUDE_DIR "${${_component}_INCLUDE_DIR}")
list(APPEND SUITESPARSE_LIBRARY "${${_component}_LIBRARY}") list(APPEND SUITESPARSE_LIBRARY "${${_component}_LIBRARY}")
endif() endif()
...@@ -191,7 +190,9 @@ find_package_handle_standard_args( ...@@ -191,7 +190,9 @@ find_package_handle_standard_args(
mark_as_advanced( mark_as_advanced(
SUITESPARSE_INCLUDE_DIR SUITESPARSE_INCLUDE_DIR
SUITESPARSE_LIBRARY SUITESPARSE_LIBRARY
SUITESPARSE_CONFIG_LIB) SUITESPARSE_CONFIG_LIB
WILL_USE_CHOLMOD
WILL_USE_UMFPACK)
# if both headers and library are found, store results # if both headers and library are found, store results
if(SuiteSparse_FOUND) if(SuiteSparse_FOUND)
...@@ -200,10 +201,10 @@ if(SuiteSparse_FOUND) ...@@ -200,10 +201,10 @@ if(SuiteSparse_FOUND)
# log result # log result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining location of SuiteSparse succeded:\n" "Determining location of SuiteSparse succeded:\n"
"Include directory: ${SUITESPARSE_INCLUDE_DIRS}\n" "Include directory: ${SuiteSparse_INCLUDE_DIRS}\n"
"Library directory: ${SuiteSparse_LIBRARIES}\n\n") "Library directory: ${SuiteSparse_LIBRARIES}\n\n")
set(SuiteSparse_COMPILER_FLAGS) set(SuiteSparse_COMPILER_FLAGS)
foreach(dir ${SUITESPARSE_INCLUDE_DIRS}) foreach(dir ${SuiteSparse_INCLUDE_DIRS})
set(SuiteSparse_COMPILER_FLAGS "${SuiteSparse_COMPILER_FLAGS} -I${dir}/") set(SuiteSparse_COMPILER_FLAGS "${SuiteSparse_COMPILER_FLAGS} -I${dir}/")
endforeach() endforeach()
set(SuiteSparse_DUNE_COMPILE_FLAGS ${SuiteSparse_COMPILER_FLAGS} set(SuiteSparse_DUNE_COMPILE_FLAGS ${SuiteSparse_COMPILER_FLAGS}
...@@ -214,7 +215,7 @@ else() ...@@ -214,7 +215,7 @@ else()
# log errornous result # log errornous result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKES_FILES_DIRECTORY}/CMakeError.log file(APPEND ${CMAKE_BINARY_DIR}${CMAKES_FILES_DIRECTORY}/CMakeError.log
"Determing location of SuiteSparse failed:\n" "Determing location of SuiteSparse failed:\n"
"Include directory: ${SUITESPARSE_INCLUDE_DIRS}\n" "Include directory: ${SuiteSparse_INCLUDE_DIRS}\n"
"Library directory: ${SuiteSparse_LIBRARIES}\n\n") "Library directory: ${SuiteSparse_LIBRARIES}\n\n")
endif() endif()
...@@ -226,5 +227,5 @@ if(SuiteSparse_FOUND) ...@@ -226,5 +227,5 @@ if(SuiteSparse_FOUND)
dune_register_package_flags( dune_register_package_flags(
COMPILE_DEFINITIONS "ENABLE_SUITESPARSE=1" COMPILE_DEFINITIONS "ENABLE_SUITESPARSE=1"
LIBRARIES "${SuiteSparse_LIBRARIES}" LIBRARIES "${SuiteSparse_LIBRARIES}"
INCLUDE_DIRS "${SUITESPARSE_INCLUDE_DIRS}") INCLUDE_DIRS "${SuiteSparse_INCLUDE_DIRS}")
endif() endif()
...@@ -26,31 +26,28 @@ ...@@ -26,31 +26,28 @@
# system paths. # system paths.
# #
include( FindSuiteSparse )
find_package(SuiteSparse COMPONENTS UMFPACK) find_package(SuiteSparse COMPONENTS UMFPACK)
if(SuiteSparse_UMFPACK_FOUND) set(UMFPACK_INCLUDE_DIRS ${SuiteSparse_INCLUDE_DIRS})
set( UMFPACK_INCLUDE_DIR ${SUITESPARSE_INCLUDE_DIR} ) set(UMFPACK_LIBRARIES ${SuiteSparse_LIBRARIES})
set( UMFPACK_LIBRARY ${SUITESPARSE_LIBRARY} )
endif()
# behave like a CMake module is supposed to behave # behave like a CMake module is supposed to behave
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args( find_package_handle_standard_args(
"UMFPack" "UMFPack"
DEFAULT_MSG DEFAULT_MSG
UMFPACK_INCLUDE_DIR UMFPACK_INCLUDE_DIRS
UMFPACK_LIBRARY UMFPACK_LIBRARIES
) )
mark_as_advanced(UMFPACK_INCLUDE_DIR UMFPACK_LIBRARY) mark_as_advanced(UMFPACK_INCLUDE_DIRS UMFPACK_LIBRARIES)
# if both headers and library are found, store results # if both headers and library are found, store results
if(UMFPACK_FOUND) if(UMFPACK_FOUND)
foreach( dir ${UMFPACK_INCLUDE_DIR} ) foreach( dir ${UMFPACK_INCLUDE_DIR} )
list( APPEND UMFPACK_INCLUDE_FLAGS "-I${dir}/ " ) list( APPEND UMFPACK_INCLUDE_FLAGS "-I${dir}/ " )
endforeach() endforeach()
set(UMFPACK_LIBRARIES ${UMFPACK_LIBRARY}) set(UMFPACK_LIBRARIES ${UMFPACK_LIBRARIES})
# log result # log result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining location of UMFPack succeded:\n" "Determining location of UMFPack succeded:\n"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment