forked from jrl-umi3218/jrl-cmakemodules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
external: add cmake finder for CHOLMOD
- Loading branch information
Showing
1 changed file
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# This file has been imported from Eigen. See | ||
# https://gitlab.com/libeigen/eigen/-/blob/master/cmake/FindCHOLMOD.cmake It has | ||
# been then adapted by Justin Carpentier <[email protected]> to comply | ||
# with the API of the JRL CMake module. | ||
|
||
# CHOLMOD lib usually requires linking to a blas and lapack library. It is up to | ||
# the user of this module to find a BLAS and link to it. | ||
|
||
if(CHOLMOD_INCLUDES AND CHOLMOD_LIBRARIES) | ||
set(CHOLMOD_FIND_QUIETLY TRUE) | ||
endif() | ||
|
||
find_path( | ||
CHOLMOD_INCLUDES | ||
NAMES cholmod.h | ||
PATHS $ENV{CHOLMODDIR} ${INCLUDE_INSTALL_DIR} | ||
PATH_SUFFIXES suitesparse ufsparse) | ||
|
||
find_library(CHOLMOD_LIBRARIES cholmod PATHS $ENV{CHOLMODDIR} | ||
${LIB_INSTALL_DIR}) | ||
|
||
if(CHOLMOD_LIBRARIES) | ||
|
||
get_filename_component(CHOLMOD_LIBDIR ${CHOLMOD_LIBRARIES} PATH) | ||
|
||
find_library(AMD_LIBRARY amd PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} | ||
${LIB_INSTALL_DIR}) | ||
if(AMD_LIBRARY) | ||
set(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARIES} ${AMD_LIBRARY}) | ||
else() | ||
set(CHOLMOD_LIBRARIES FALSE) | ||
endif() | ||
|
||
endif() | ||
|
||
if(CHOLMOD_LIBRARIES) | ||
|
||
find_library(COLAMD_LIBRARY colamd PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} | ||
${LIB_INSTALL_DIR}) | ||
if(COLAMD_LIBRARY) | ||
set(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARIES} ${COLAMD_LIBRARY}) | ||
else() | ||
set(CHOLMOD_LIBRARIES FALSE) | ||
endif() | ||
|
||
endif() | ||
|
||
if(CHOLMOD_LIBRARIES) | ||
|
||
find_library(CAMD_LIBRARY camd PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} | ||
${LIB_INSTALL_DIR}) | ||
if(CAMD_LIBRARY) | ||
set(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARIES} ${CAMD_LIBRARY}) | ||
else() | ||
set(CHOLMOD_LIBRARIES FALSE) | ||
endif() | ||
|
||
endif() | ||
|
||
if(CHOLMOD_LIBRARIES) | ||
|
||
find_library(CCOLAMD_LIBRARY ccolamd PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} | ||
${LIB_INSTALL_DIR}) | ||
if(CCOLAMD_LIBRARY) | ||
set(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARIES} ${CCOLAMD_LIBRARY}) | ||
else() | ||
set(CHOLMOD_LIBRARIES FALSE) | ||
endif() | ||
|
||
endif() | ||
|
||
if(CHOLMOD_LIBRARIES) | ||
|
||
find_library(CHOLMOD_METIS_LIBRARY metis | ||
PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR}) | ||
if(CHOLMOD_METIS_LIBRARY) | ||
set(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARIES} ${CHOLMOD_METIS_LIBRARY}) | ||
endif() | ||
|
||
endif() | ||
|
||
if(CHOLMOD_LIBRARIES) | ||
|
||
find_library(SUITESPARSE_LIBRARY SuiteSparse | ||
PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR}) | ||
if(SUITESPARSE_LIBRARY) | ||
set(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARIES} ${SUITESPARSE_LIBRARY}) | ||
endif() | ||
|
||
endif() | ||
|
||
if(CHOLMOD_LIBRARIES) | ||
add_library(SuiteSparse::CHOLMOD SHARED IMPORTED) | ||
set_target_properties( | ||
SuiteSparse::CHOLMOD | ||
PROPERTIES IMPORTED_LOCATION ${CHOLMOD_LIBRARIES} | ||
INTERFACE_INCLUDE_DIRECTORIES "${CHOLMOD_INCLUDES}") | ||
endif(CHOLMOD_LIBRARIES) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(CHOLMOD DEFAULT_MSG CHOLMOD_INCLUDES | ||
CHOLMOD_LIBRARIES) | ||
|
||
mark_as_advanced( | ||
CHOLMOD_INCLUDES | ||
CHOLMOD_LIBRARIES | ||
AMD_LIBRARY | ||
COLAMD_LIBRARY | ||
SUITESPARSE_LIBRARY | ||
CAMD_LIBRARY | ||
CCOLAMD_LIBRARY | ||
CHOLMOD_METIS_LIBRARY) |