Skip to content

Commit

Permalink
updates to build system
Browse files Browse the repository at this point in the history
  • Loading branch information
DrTimothyAldenDavis committed Dec 9, 2023
1 parent 17ef14c commit 55ad380
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 7 deletions.
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ if ( NOT MSVC )
if ( NOT WIN32 )
list ( APPEND LAGRAPH_STATIC_LIBS "m" )
endif ( )
list ( APPEND LAGRAPH_STATIC_LIBS ${GRAPHBLAS_LIBRARY} )
endif ( )
# This might be something like:
# /usr/lib/libgomp.so;/usr/lib/libpthread.a;m
Expand Down Expand Up @@ -369,6 +368,9 @@ if ( NOT MSVC )
endif ( )
endforeach ( )
endforeach ( )
if ( BUILD_STATIC_LIBS )
set ( LAGRAPH_STATIC_LIBS "-l$<TARGET_FILE_BASE_NAME:GraphBLAS::GraphBLAS> ${LAGRAPH_STATIC_LIBS}" )
endif ( )

set ( prefix "${CMAKE_INSTALL_PREFIX}" )
set ( exec_prefix "\${prefix}" )
Expand All @@ -384,11 +386,20 @@ if ( NOT MSVC )
else ( )
set ( includedir "\${prefix}/${SUITESPARSE_INCLUDEDIR}")
endif ( )
if ( BUILD_SHARED_LIBS )
set ( SUITESPARSE_LIB_BASE_NAME $<TARGET_FILE_BASE_NAME:LAGraph> )
else ( )
set ( SUITESPARSE_LIB_BASE_NAME $<TARGET_FILE_BASE_NAME:LAGraph_static> )
endif ( )
configure_file (
config/LAGraph.pc.in
LAGraph.pc
LAGraph.pc.out
@ONLY
NEWLINE_STYLE LF )
file ( GENERATE
OUTPUT LAGraph.pc
INPUT ${CMAKE_CURRENT_BINARY_DIR}/LAGraph.pc.out
NEWLINE_STYLE LF )
install ( FILES
${CMAKE_CURRENT_BINARY_DIR}/LAGraph.pc
DESTINATION ${SUITESPARSE_PKGFILEDIR}/pkgconfig )
Expand Down
57 changes: 55 additions & 2 deletions cmake_modules/FindGraphBLAS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,68 @@ endif ( )

if ( GRAPHBLAS_LIBRARY )
message ( STATUS "Create target GraphBLAS::GraphBLAS" )
# Get library name from filename of library
# This might be something like:
# /usr/lib/libgraphblas.so or /usr/lib/libgraphblas.a or graphblas64
# convert to library name that can be used with -l flags for pkg-config
set ( GRAPHBLAS_LIBRARY_TMP ${GRAPHBLAS_LIBRARY} )
string ( FIND ${GRAPHBLAS_LIBRARY} "." _pos REVERSE )
if ( ${_pos} EQUAL "-1" )
set ( _graphblas_library_name ${GRAPHBLAS_LIBRARY} )
else ( )
set ( _kinds "SHARED" "STATIC" )
if ( WIN32 )
list ( PREPEND _kinds "IMPORT" )
endif ( )
foreach ( _kind IN LISTS _kinds )
set ( _regex ".*\\/(lib)?([^\\.]*)(${CMAKE_${_kind}_LIBRARY_SUFFIX})" )
if ( ${GRAPHBLAS_LIBRARY} MATCHES ${_regex} )
string ( REGEX REPLACE ${_regex} "\\2" _libname ${GRAPHBLAS_LIBRARY} )
if ( NOT "${_libname}" STREQUAL "" )
set ( _graphblas_library_name ${_libname} )
break ()
endif ( )
endif ( )
endforeach ( )
endif ( )

add_library ( GraphBLAS::GraphBLAS UNKNOWN IMPORTED )
set_target_properties ( GraphBLAS::GraphBLAS PROPERTIES
IMPORTED_LOCATION "${GRAPHBLAS_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${GRAPHBLAS_INCLUDE_DIR}" )
INTERFACE_INCLUDE_DIRECTORIES "${GRAPHBLAS_INCLUDE_DIR}"
OUTPUT_NAME ${_graphblas_library_name} )
endif ( )

if ( GRAPHBLAS_STATIC )
message ( STATUS "Create target GraphBLAS::GraphBLAS_static" )
# Get library name from filename of library
# This might be something like:
# /usr/lib/libgraphblas.so or /usr/lib/libgraphblas.a or graphblas64
# convert to library name that can be used with -l flags for pkg-config
set ( GRAPHBLAS_LIBRARY_TMP ${GRAPHBLAS_STATIC} )
string ( FIND ${GRAPHBLAS_STATIC} "." _pos REVERSE )
if ( ${_pos} EQUAL "-1" )
set ( _graphblas_library_name ${GRAPHBLAS_STATIC} )
else ( )
set ( _kinds "SHARED" "STATIC" )
if ( WIN32 )
list ( PREPEND _kinds "IMPORT" )
endif ( )
foreach ( _kind IN LISTS _kinds )
set ( _regex ".*\\/(lib)?([^\\.]*)(${CMAKE_${_kind}_LIBRARY_SUFFIX})" )
if ( ${GRAPHBLAS_STATIC} MATCHES ${_regex} )
string ( REGEX REPLACE ${_regex} "\\2" _libname ${GRAPHBLAS_STATIC} )
if ( NOT "${_libname}" STREQUAL "" )
set ( _graphblas_library_name ${_libname} )
break ()
endif ( )
endif ( )
endforeach ( )
endif ( )

add_library ( GraphBLAS::GraphBLAS_static UNKNOWN IMPORTED )
set_target_properties ( GraphBLAS::GraphBLAS_static PROPERTIES
IMPORTED_LOCATION "${GRAPHBLAS_STATIC}"
INTERFACE_INCLUDE_DIRECTORIES "${GRAPHBLAS_INCLUDE_DIR}" )
INTERFACE_INCLUDE_DIRECTORIES "${GRAPHBLAS_INCLUDE_DIR}"
OUTPUT_NAME ${_graphblas_library_name} )
endif ( )
4 changes: 2 additions & 2 deletions config/LAGraph.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ URL: https://github.com/DrTimothyAldenDavis/SuiteSparse
Description: Library plus test harness for collecting algorithms that use GraphBLAS in SuiteSparse
Version: @LAGraph_VERSION_MAJOR@.@LAGraph_VERSION_MINOR@.@LAGraph_VERSION_SUB@
Requires.private: GraphBLAS
Libs: -L${libdir} -llagraph@CMAKE_RELEASE_POSTFIX@
Libs.private: -lgraphblas @LAGRAPH_STATIC_LIBS@
Libs: -L${libdir} -l@SUITESPARSE_LIB_BASE_NAME@
Libs.private: @LAGRAPH_STATIC_LIBS@
Cflags: -I${includedir} -DLG_DLL
Cflags.private: -ULG_DLL
2 changes: 1 addition & 1 deletion src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ foreach( testsourcefile ${TEST_SOURCES} )
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:GraphBLAS::GraphBLAS>>" )
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:GraphBLAS::GraphBLAS>" )
endif ( )
endif ( )
endforeach( testsourcefile ${TEST_SOURCES} )
Expand Down

0 comments on commit 55ad380

Please sign in to comment.