diff options
-rw-r--r-- | CMakeLists.txt | 13 | ||||
-rw-r--r-- | include/clblast.h | 12 | ||||
-rw-r--r-- | include/clblast_c.h | 12 |
3 files changed, 28 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3927858e..140b35a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,15 @@ elseif(MSVC) endif() endif() +# DLL Settings +if(MSVC) + if(BUILD_SHARED_LIBS) + add_definitions(" /DCLBLAST_DLL") + else(BUILD_SHARED_LIBS) + add_definitions(" /DCLBLAST_STATIC") + endif(BUILD_SHARED_LIBS) +endif(MSVC) + # C++ compiler settings if(MSVC) set(FLAGS "/Ox") @@ -195,7 +204,9 @@ target_include_directories(clblast PUBLIC # Sets the proper __declspec(dllexport) keyword for Visual Studio when the library is built if(MSVC) - target_compile_definitions(clblast PRIVATE COMPILING_DLL=1) # requires at least CMake 2.8.11 + if(BUILD_SHARED_LIBS) + target_compile_definitions(clblast PRIVATE COMPILING_DLL=1) # requires at least CMake 2.8.11 + endif(BUILD_SHARED_LIBS) endif() # Installs the library diff --git a/include/clblast.h b/include/clblast.h index e1d4f25b..335ca8e3 100644 --- a/include/clblast.h +++ b/include/clblast.h @@ -28,10 +28,14 @@ // Exports library functions under Windows when building a DLL. See also: // https://msdn.microsoft.com/en-us/library/a90k134d.aspx #ifdef _WIN32 - #ifdef COMPILING_DLL - #define PUBLIC_API __declspec(dllexport) - #else - #define PUBLIC_API __declspec(dllimport) + #if defined(CLBLAST_DLL) + #if defined(COMPILING_DLL) + #define PUBLIC_API __declspec(dllexport) + #else + #define PUBLIC_API __declspec(dllimport) + #endif + #elif defined(CLBLAST_STATIC) + #define PUBLIC_API #endif #else #define PUBLIC_API diff --git a/include/clblast_c.h b/include/clblast_c.h index a13b8e64..6a454015 100644 --- a/include/clblast_c.h +++ b/include/clblast_c.h @@ -25,10 +25,14 @@ // Exports library functions under Windows when building a DLL. See also: // https://msdn.microsoft.com/en-us/library/a90k134d.aspx #ifdef _WIN32 - #ifdef COMPILING_DLL - #define PUBLIC_API __declspec(dllexport) - #else - #define PUBLIC_API __declspec(dllimport) + #if defined(CLBLAST_DLL) + #if defined(COMPILING_DLL) + #define PUBLIC_API __declspec(dllexport) + #else + #define PUBLIC_API __declspec(dllimport) + #endif + #elif defined(CLBLAST_STATIC) + #define PUBLIC_API #endif #else #define PUBLIC_API |