Skip to content

Commit

Permalink
#633 use a findsuitesparse.cmake file
Browse files Browse the repository at this point in the history
  • Loading branch information
Scottmar93 committed Oct 22, 2019
1 parent afb6588 commit 5a69822
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 36 deletions.
36 changes: 21 additions & 15 deletions CMakeLists.txt
Expand Up @@ -37,21 +37,27 @@ TARGET_LINK_LIBRARIES(klu PRIVATE ${RT})
# )

# set(SUITESPARSE_INCLUDE_DIR "/usr/include/suitesparse")
INCLUDE_DIRECTORIES(${SUITESPARSE_INCLUDE_DIR})

## Link Libraries
find_library(KLU klu)
find_library(AMD amd)
find_library(COLAMD colamd)
find_library(BTF btf)
find_library(SUITESPARSE_CONFIG suitesparseconfig)
TARGET_LINK_LIBRARIES(klu PRIVATE
${KLU}
${AMD}
${COLAMD}
${BTF}
${SUITESPARSE_CONFIG}
)
# find_path(SUITESPARSE_INCLUDE_DIR suitesparse)
# INCLUDE_DIRECTORIES(${SUITESPARSE_INCLUDE_DIR})

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR})
find_package(SuiteSparse)
include_directories(${SuiteSparse_INCLUDE_DIRS})
target_link_libraries(klu PRIVATE ${SuiteSparse_LIBRARIES})

# ## Link Libraries
# find_library(KLU klu)
# find_library(AMD amd)
# find_library(COLAMD colamd)
# find_library(BTF btf)
# find_library(SUITESPARSE_CONFIG suitesparseconfig)
# TARGET_LINK_LIBRARIES(klu PRIVATE
# ${KLU}
# ${AMD}
# ${COLAMD}
# ${BTF}
# ${SUITESPARSE_CONFIG}
# )

# ---------------

31 changes: 10 additions & 21 deletions scripts/replace-cmake/CMakeLists.txt
Expand Up @@ -1002,30 +1002,19 @@ IF(KLU_ENABLE)
# set(SUITESPARSECONFIG_LIBRARY ${SUITESPARSE_DIR}/SuiteSparse_config/libsuitesparseconfig.a)
# set(KLU_LIBRARIES ${KLU_LIBRARY} ${AMD_LIBRARY} ${COLAMD_LIBRARY} ${BTF_LIBRARY} ${SUITESPARSECONFIG_LIBRARY})

find_library(KLU_LIBRARY klu)
find_library(AMD_LIBRARY amd)
find_library(COLAMD_LIBRARY colamd)
find_library(BTF_LIBRARY btf)
find_library(SUITESPARSECONFIG_LIBRARY suitesparseconfig)
set(KLU_LIBRARIES ${KLU_LIBRARY} ${AMD_LIBRARY} ${COLAMD_LIBRARY} ${BTF_LIBRARY} ${SUITESPARSECONFIG_LIBRARY})

# find_library(KLU_LIBRARY klu)
# find_library(AMD_LIBRARY amd)
# find_library(COLAMD_LIBRARY colamd)
# find_library(BTF_LIBRARY btf)
# find_library(SUITESPARSECONFIG_LIBRARY suitesparseconfig)
# set(KLU_LIBRARIES ${KLU_LIBRARY} ${AMD_LIBRARY} ${COLAMD_LIBRARY} ${BTF_LIBRARY} ${SUITESPARSECONFIG_LIBRARY})

set(KLU_FOUND TRUE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/..) # use FindSuiteSparse that is in PyBaMM root
find_package(SuiteSparse)
include_directories(${SuiteSparse_INCLUDE_DIRS})
set(KLU_LIBRARIES ${SuiteSparse_LIBRARIES})

# include is now simply /usr/include
# IF(KLU_FOUND)
# sundials_config.h symbol
# SET(SUNDIALS_KLU TRUE)
# set(KLU_INCLUDE_DIR ${SUITESPARSE_DIR}/KLU/Include)
# set(AMD_INCLUDE_DIR ${SUITESPARSE_DIR}/AMD/Include)
# set(COLAMD_INCLUDE_DIR ${SUITESPARSE_DIR}/COLAMD/Include)
# set(BTF_INCLUDE_DIR ${SUITESPARSE_DIR}/BTF/Include)
# set(SUITESPARSECONFIG_INCLUDE_DIR ${SUITESPARSE_DIR}/SuiteSparse_config)

# INCLUDE_DIRECTORIES(${AMD_INCLUDE_DIR} ${COLAMD_INCLUDE_DIR} ${BTF_INCLUDE_DIR} ${SUITESPARSECONFIG_INCLUDE_DIR} ${KLU_INCLUDE_DIR})
# ENDIF(KLU_FOUND)
# set(SUITESPARSE_INCLUDE_DIR "/usr/include/suitesparse") # leave for user to set
INCLUDE_DIRECTORIES(${SUITESPARSE_INCLUDE_DIR})

IF(KLU_LIBRARIES AND NOT KLU_FOUND)
PRINT_WARNING("KLU not functional - support will not be provided"
Expand Down

0 comments on commit 5a69822

Please sign in to comment.