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

LAGraph: Fix some issues with other versions of GraphBLAS #553

Merged
merged 3 commits into from
Nov 30, 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
34 changes: 25 additions & 9 deletions LAGraph/cmake_modules/FindGraphBLAS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,14 @@ find_library ( GRAPHBLAS_LIBRARY
)

if ( MSVC )
set ( STATIC_SUFFIX .lib )
set ( STATIC_NAME graphblas_static )
else ( )
set ( STATIC_SUFFIX .a )
set ( STATIC_NAME graphblas )
endif ( )

# static SuiteSparse:GraphBLAS library
set ( save ${CMAKE_FIND_LIBRARY_SUFFIXES} )
set ( CMAKE_FIND_LIBRARY_SUFFIXES ${STATIC_SUFFIX} ${CMAKE_FIND_LIBRARY_SUFFIXES} )
set ( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX} )
find_library ( GRAPHBLAS_STATIC
NAMES ${STATIC_NAME}
HINTS ${GRAPHBLAS_ROOT}
Expand All @@ -140,6 +138,9 @@ find_library ( GRAPHBLAS_STATIC
PATH_SUFFIXES lib build alternative
)
set ( CMAKE_FIND_LIBRARY_SUFFIXES ${save} )
if ( MINGW AND GRAPHBLAS_STATIC MATCHES ".*\.dll\.a" )
set ( GRAPHBLAS_STATIC "" )
endif ( )

# get version of the library from the dynamic library name
get_filename_component ( GRAPHBLAS_LIBRARY ${GRAPHBLAS_LIBRARY} REALPATH )
Expand All @@ -150,6 +151,21 @@ string (
${GRAPHBLAS_FILENAME}
)

if ( GRAPHBLAS_VERSION )
if ( ${GRAPHBLAS_VERSION} MATCHES "([0-9]+).[0-9]+.[0-9]+" )
set ( GraphBLAS_VERSION_MAJOR ${CMAKE_MATCH_1} )
endif ( )
if ( ${GRAPHBLAS_VERSION} MATCHES "[0-9]+.([0-9]+).[0-9]+" )
set ( GraphBLAS_VERSION_MINOR ${CMAKE_MATCH_1} )
endif ( )
if ( ${GRAPHBLAS_VERSION} MATCHES "[0-9]+.[0-9]+.([0-9]+)" )
set ( GraphBLAS_VERSION_PATCH ${CMAKE_MATCH_1} )
endif ( )
message ( STATUS "major: ${GraphBLAS_VERSION_MAJOR}" )
message ( STATUS "minor: ${GraphBLAS_VERSION_MINOR}" )
message ( STATUS "patch: ${GraphBLAS_VERSION_PATCH}" )
endif ( )

# set ( GRAPHBLAS_VERSION "" )
if ( EXISTS "${GRAPHBLAS_INCLUDE_DIR}" AND NOT GRAPHBLAS_VERSION )
# if the version does not appear in the filename, read the include file
Expand All @@ -162,10 +178,10 @@ if ( EXISTS "${GRAPHBLAS_INCLUDE_DIR}" AND NOT GRAPHBLAS_VERSION )
message ( STATUS "major: ${GRAPHBLAS_MAJOR_STR}" )
message ( STATUS "minor: ${GRAPHBLAS_MINOR_STR}" )
message ( STATUS "patch: ${GRAPHBLAS_PATCH_STR}" )
string ( REGEX MATCH "[0-9]+" GRAPHBLAS_MAJOR ${GRAPHBLAS_MAJOR_STR} )
string ( REGEX MATCH "[0-9]+" GRAPHBLAS_MINOR ${GRAPHBLAS_MINOR_STR} )
string ( REGEX MATCH "[0-9]+" GRAPHBLAS_PATCH ${GRAPHBLAS_PATCH_STR} )
set (GRAPHBLAS_VERSION "${GRAPHBLAS_MAJOR}.${GRAPHBLAS_MINOR}.${GRAPHBLAS_PATCH}")
string ( REGEX MATCH "[0-9]+" GraphBLAS_VERSION_MAJOR ${GRAPHBLAS_MAJOR_STR} )
string ( REGEX MATCH "[0-9]+" GraphBLAS_VERSION_MINOR ${GRAPHBLAS_MINOR_STR} )
string ( REGEX MATCH "[0-9]+" GraphBLAS_VERSION_PATCH ${GRAPHBLAS_PATCH_STR} )
set (GRAPHBLAS_VERSION "${GraphBLAS_VERSION_MAJOR}.${GraphBLAS_VERSION_MINOR}.${GraphBLAS_VERSION_PATCH}")
endif ( )

set ( GRAPHBLAS_LIBRARIES ${GRAPHBLAS_LIBRARY} )
Expand Down Expand Up @@ -199,13 +215,13 @@ else ( )
endif ( )

# Create target from information found
if ( NOT "${GRAPHBLAS_LIBRARY}" STREQUAL "" )
if ( GRAPHBLAS_LIBRARY )
add_library ( GraphBLAS::GraphBLAS UNKNOWN IMPORTED )
set_target_properties ( GraphBLAS::GraphBLAS PROPERTIES
IMPORTED_LOCATION "${GRAPHBLAS_LIBRARY}"
IMPORTED_INCLUDE_DIRECTORIES "${GRAPHBLAS_INCLUDE_DIR}" )
endif ( )
if ( NOT "${GRAPHBLAS_STATIC}" STREQUAL "" )
if ( GRAPHBLAS_STATIC )
add_library ( GraphBLAS::GraphBLAS_static UNKNOWN IMPORTED )
set_target_properties ( GraphBLAS::GraphBLAS_static PROPERTIES
IMPORTED_LOCATION "${GRAPHBLAS_STATIC}"
Expand Down
4 changes: 2 additions & 2 deletions LAGraph/experimental/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ foreach( testsourcefile ${TEST_SOURCES} )
if (WIN32)
if ( BUILD_SHARED_LIBS )
set_tests_properties ( ${ctestname} PROPERTIES
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:SuiteSparse::GraphBLAS>;PATH=path_list_prepend:$<TARGET_FILE_DIR:lagraphxtest>" )
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:GraphBLAS::GraphBLAS>;PATH=path_list_prepend:$<TARGET_FILE_DIR:lagraphxtest>" )
else ( )
set_tests_properties ( ${ctestname} PROPERTIES
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:SuiteSparse::GraphBLAS>" )
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:GraphBLAS::GraphBLAS>" )
endif ( )
endif ( )
endforeach( testsourcefile ${TEST_SOURCES} )
Expand Down
4 changes: 2 additions & 2 deletions LAGraph/src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ foreach( testsourcefile ${TEST_SOURCES} )
if (WIN32)
if ( BUILD_SHARED_LIBS )
set_tests_properties ( ${ctestname} PROPERTIES
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:SuiteSparse::GraphBLAS>;PATH=path_list_prepend:$<TARGET_FILE_DIR:lagraphtest>" )
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:GraphBLAS::GraphBLAS>;PATH=path_list_prepend:$<TARGET_FILE_DIR:lagraphtest>" )
else ( )
set_tests_properties ( ${ctestname} PROPERTIES
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:SuiteSparse::GraphBLAS>>" )
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:GraphBLAS::GraphBLAS>>" )
endif ( )
endif ( )
endforeach( testsourcefile ${TEST_SOURCES} )
Expand Down
Loading