Skip to content

Commit

Permalink
GraphBLAS: Don't use dllexport or dllimport attribute for static library
Browse files Browse the repository at this point in the history
Facilitate using the static GraphBLAS library on Windows by adding the
necessary preprocessor definition to the CMake target and pkg-config file.
  • Loading branch information
mmuetzel committed Nov 28, 2023
1 parent 5ae67fb commit 88a1ddf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions GraphBLAS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ if ( BUILD_STATIC_LIBS )
target_compile_definitions ( GraphBLAS_static PRIVATE "SUITESPARSE_CUDA" )
endif ( )

if ( WIN32 )
# On Windows, don't use __declspec ( dllimport ) for static library.
target_compile_definitions ( GraphBLAS PUBLIC GB_STATIC )
endif ( )

if ( NOT NJIT )
# Make sure compressed sources are built before library
add_dependencies ( GraphBLAS_static grb_jitpackage )
Expand Down
6 changes: 3 additions & 3 deletions GraphBLAS/Config/GraphBLAS.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@
#define GB_GLOBAL extern __declspec ( dllexport )
#elif defined ( GB_STATIC )
// Compiling the user application on Windows, importing symbols from
// a static GraphBLAS library on Windows. The user application must do:
// #define GB_STATIC
// #include "GraphBLAS.h"
// a static GraphBLAS library on Windows. The user application must
// define GB_STATIC (e.g., with the pre-processor flag -DGB_STATIC) for
// all compilation units that include "GraphBLAS.h".
#define GB_GLOBAL extern
#else
// Compiling the user application on Windows, importing symbols from
Expand Down
1 change: 1 addition & 0 deletions GraphBLAS/Config/GraphBLAS.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Requires.private: @GRAPHBLAS_STATIC_MODULES@
Libs: -L${libdir} -lgraphblas
Libs.private: @GRAPHBLAS_STATIC_LIBS@
Cflags: -I${includedir}
Cflags.private: -DGB_STATIC
6 changes: 3 additions & 3 deletions GraphBLAS/Include/GraphBLAS.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@
#define GB_GLOBAL extern __declspec ( dllexport )
#elif defined ( GB_STATIC )
// Compiling the user application on Windows, importing symbols from
// a static GraphBLAS library on Windows. The user application must do:
// #define GB_STATIC
// #include "GraphBLAS.h"
// a static GraphBLAS library on Windows. The user application must
// define GB_STATIC (e.g., with the pre-processor flag -DGB_STATIC) for
// all compilation units that include "GraphBLAS.h".
#define GB_GLOBAL extern
#else
// Compiling the user application on Windows, importing symbols from
Expand Down

0 comments on commit 88a1ddf

Please sign in to comment.