From 8a9d3cdf3733ed03093ec5c6e4a65549646a6c74 Mon Sep 17 00:00:00 2001 From: Cedric Nugteren Date: Mon, 10 Oct 2016 22:45:39 +0200 Subject: Added support for compiling the library, the client, and the samples under MSVC 2013 --- include/clblast_half.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/clblast_half.h b/include/clblast_half.h index 269a520e..05d96f9f 100644 --- a/include/clblast_half.h +++ b/include/clblast_half.h @@ -25,6 +25,11 @@ #include #endif +// MSVC 2013 doesn't fully support C99 +#ifdef _MSC_VER + #define inline __inline +#endif + // ================================================================================================= // Host data-type for half-precision floating-point (16-bit). This is based on the OpenCL type, -- cgit v1.2.3 From 0d958bf3b3485a17071d7d4d17030f75f28412e4 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Fri, 14 Oct 2016 18:45:34 -0400 Subject: Fixes for static lib compilation on Windows --- CMakeLists.txt | 13 ++++++++++++- include/clblast.h | 12 ++++++++---- include/clblast_c.h | 12 ++++++++---- 3 files changed, 28 insertions(+), 9 deletions(-) (limited to 'include') 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 -- cgit v1.2.3 From 53deed298facc005f71e9ec2a96d5c4e90d826af Mon Sep 17 00:00:00 2001 From: Cedric Nugteren Date: Sat, 15 Oct 2016 17:11:08 +0200 Subject: Added documentation and minor refactoring for the recent support of static library compilation --- CHANGELOG | 1 + CMakeLists.txt | 2 +- README.md | 4 ++++ include/clblast.h | 14 +++++--------- include/clblast_c.h | 14 +++++--------- 5 files changed, 16 insertions(+), 19 deletions(-) (limited to 'include') diff --git a/CHANGELOG b/CHANGELOG index 0d517869..2affaadd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ Development version (next release) - Added support for compilation under Visual Studio 2013 (MSVC++ 12.0) - Added an option to set OpenCL compiler options through the env variable CLBLAST_BUILD_OPTIONS - Added an option to run tuned kernels multiple times to average execution times +- Added an option to build a static version of the library - Various minor fixes and enhancements - Added tuned parameters for various devices (see README) diff --git a/CMakeLists.txt b/CMakeLists.txt index 140b35a6..bf2a36dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ set(clblast_VERSION_MINOR 9) set(clblast_VERSION_PATCH 0) # Options and their default values -option(BUILD_SHARED_LIBS "Build shared or static library" ON) +option(BUILD_SHARED_LIBS "Build a shared (ON) or static library (OFF)" ON) option(SAMPLES "Enable compilation of the examples" OFF) option(TUNERS "Enable compilation of the tuners" OFF) option(CLIENTS "Enable compilation of the clients to test and compare performance" OFF) diff --git a/README.md b/README.md index 33282d8f..a88f5ce1 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,10 @@ A custom installation folder can be specified when calling CMake: cmake -DCMAKE_INSTALL_PREFIX=/path/to/install/directory .. +Building a static version of the library instead of shared one (.dylib/.so/.dll) can be done by disabling the `BUILD_SHARED_LIBS` option when calling CMake. For example: + + cmake -DBUILD_SHARED_LIBS=OFF .. + Using the library ------------- diff --git a/include/clblast.h b/include/clblast.h index 335ca8e3..0f52b2f9 100644 --- a/include/clblast.h +++ b/include/clblast.h @@ -27,15 +27,11 @@ // Exports library functions under Windows when building a DLL. See also: // https://msdn.microsoft.com/en-us/library/a90k134d.aspx -#ifdef _WIN32 - #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 +#if defined(_WIN32) && defined(CLBLAST_DLL) + #if defined(COMPILING_DLL) + #define PUBLIC_API __declspec(dllexport) + #else + #define PUBLIC_API __declspec(dllimport) #endif #else #define PUBLIC_API diff --git a/include/clblast_c.h b/include/clblast_c.h index 6a454015..33fb4acf 100644 --- a/include/clblast_c.h +++ b/include/clblast_c.h @@ -24,15 +24,11 @@ // Exports library functions under Windows when building a DLL. See also: // https://msdn.microsoft.com/en-us/library/a90k134d.aspx -#ifdef _WIN32 - #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 +#if defined(_WIN32) && defined(CLBLAST_DLL) + #if defined(COMPILING_DLL) + #define PUBLIC_API __declspec(dllexport) + #else + #define PUBLIC_API __declspec(dllimport) #endif #else #define PUBLIC_API -- cgit v1.2.3