Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPEX: Automatically check for dependencies when importing target #413

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ endif ( )

# look for all external libaries:
find_package ( OpenMP REQUIRED )
find_package ( GMP 6.1.2 REQUIRED )
find_package ( MPFR 4.0.2 REQUIRED )

include ( SuiteSparseBLAS )

#-------------------------------------------------------------------------------
Expand Down
63 changes: 63 additions & 0 deletions SPEX/Config/SPEXConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,69 @@ set ( SPEX_VERSION_MINOR @SPEX_VERSION_MINOR@ )
set ( SPEX_VERSION_PATCH @SPEX_VERSION_SUB@ )
set ( SPEX_VERSION "@SPEX_VERSION_MAJOR@.@SPEX_VERSION_MINOR@.@SPEX_VERSION_SUB@" )

# Check for dependent targets
include ( CMakeFindDependencyMacro )

# Look for SuiteSparse_config, AMD and COLAMD targets
if ( @SUITESPARSE_IN_BUILD_TREE@ )
if ( NOT TARGET SuiteSparse::SuiteSparseConfig )
# First check in a common build tree
find_dependency ( SuiteSparse_config @SUITESPARSE_CONFIG_VERSION_MAJOR@.@SUITESPARSE_CONFIG_VERSION_MINOR@
PATHS ${CMAKE_SOURCE_DIR}/../SuiteSparse_config/build NO_DEFAULT_PATH )
# Then, check in the currently active CMAKE_MODULE_PATH
if ( NOT SuiteSparse_config_FOUND )
find_dependency ( SuiteSparse_config @SUITESPARSE_CONFIG_VERSION_MAJOR@.@SUITESPARSE_CONFIG_VERSION_MINOR@ )
endif ( )
endif ( )

if ( NOT TARGET SuiteSparse::AMD )
# First check in a common build tree
find_dependency ( AMD @AMD_VERSION_MAJOR@.@AMD_VERSION_MINOR@
PATHS ${CMAKE_SOURCE_DIR}/../AMD/build NO_DEFAULT_PATH )
# Then, check in the currently active CMAKE_MODULE_PATH
if ( NOT AMD_FOUND )
find_dependency ( AMD @AMD_VERSION_MAJOR@.@AMD_VERSION_MINOR@ )
endif ( )
endif ( )

if ( NOT TARGET SuiteSparse::COLAMD )
# First check in a common build tree
find_dependency ( COLAMD @COLAMD_VERSION_MAJOR@.@COLAMD_VERSION_MINOR@
PATHS ${CMAKE_SOURCE_DIR}/../COLAMD/build NO_DEFAULT_PATH )
# Then, check in the currently active CMAKE_MODULE_PATH
if ( NOT COLAMD_FOUND )
find_dependency ( COLAMD @COLAMD_VERSION_MAJOR@.@COLAMD_VERSION_MINOR@ )
endif ( )
endif ( )

else ( )
if ( NOT TARGET SuiteSparse::SuiteSparseConfig )
find_dependency ( SuiteSparse_config @SUITESPARSE_CONFIG_VERSION_MAJOR@.@SUITESPARSE_CONFIG_VERSION_MINOR@ )
endif ( )
if ( NOT TARGET SuiteSparse::AMD )
find_dependency ( AMD @AMD_VERSION_MAJOR@.@AMD_VERSION_MINOR@ )
endif ( )
if ( NOT TARGET SuiteSparse::COLAMD )
find_dependency ( COLAMD @COLAMD_VERSION_MAJOR@.@COLAMD_VERSION_MINOR@ )
endif ( )
endif ( )

# Look for GMP and MPFR modules
if ( NOT GMP_FOUND )
find_dependency ( GMP 6.1.2 )
endif ( )
if ( NOT MPFR_FOUND )
find_dependency ( MPFR 4.0.2 )
endif ( )

if ( NOT SuiteSparse_config_FOUND OR NOT AMD_FOUND OR NOT COLAMD_FOUND
OR NOT GMP_FOUND OR NOT MPFR_FOUND)
set ( SPEX_FOUND OFF )
return ( )
endif ( )


# Import target
include ( ${CMAKE_CURRENT_LIST_DIR}/SPEXTargets.cmake )

# The following is only for backward compatibility with FindSPEX.
Expand Down