diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a28a5b..405249e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,8 @@ project(clew) option( BUILD_TESTS "Build test program." ON ) -option( BUILD_SHARED_LIBRARY "Shared library, rather than static library." OFF ) +option( BUILD_SHARED_LIBRARY "Build shared library." OFF ) +option( BUILD_STATIC_LIBRARY "Build static library." OFF ) option( INSTALL_CL_HEADER "Install cl.h / opencl.h proxy headers to ease compilation of software not aware of CLEW" OFF ) cmake_minimum_required (VERSION 2.6) @@ -25,7 +26,10 @@ if(CMAKE_COMPILER_IS_GNUCC) endif() add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_1_APIS) -if( NOT BUILD_SHARED_LIBRARY ) +if(BUILD_SHARED_LIBRARY AND BUILD_STATIC_LIBRARY) + message(FATAL_ERROR "Choose either BUILD_SHARED_LIBRARY or BUILD_STATIC_LIBRARY, or disable both to rely on global BUILD_SHARED_LIBS") +endif() +if(BUILD_STATIC_LIBRARY OR NOT BUILD_SHARED_LIBS) add_definitions(-Dclew_STATIC) endif() @@ -38,4 +42,3 @@ add_subdirectory(include) if( BUILD_TESTS ) add_subdirectory(clewTest) endif( BUILD_TESTS ) - diff --git a/README.md b/README.md index 486e803..d06d7e3 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,10 @@ To test it works ok. You'll need at least one OpenCL-enabled device to do this ## Build options * BUILD_TESTS: build test executable, default ON -* BUILD_SHARED_LIBRARY: build dll/so, instead of .lib/.a. default OFF +* BUILD_SHARED_LIBRARY: explicitly build dll/so, default OFF +* BUILD_STATIC_LIBRARY: explicitly build lib/a, default OFF * INSTALL_CL_HEADER: creates include files directory `proxy-opencl`, which you can give eg to clBLAS during build, and it will build ok, without needing opencl headers installed +BUILD_SHARED_LIBRARY and BUILD_STATIC_LIBRARY may not be used simultaneously. +If none of them is on (it's the default), then CMake's global BUILD_SHARED_LIBS +will be used to decide which type of library to build. diff --git a/include/clew.h b/include/clew.h index 34a5398..8fa9e1c 100644 --- a/include/clew.h +++ b/include/clew.h @@ -2605,10 +2605,8 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)( # define CLEWAPI extern #else # ifdef clew_EXPORTS -#pragma message("exporting") # define CLEWAPI extern __declspec(dllexport) # else -#pragma message("importing") # define CLEWAPI extern __declspec(dllimport) # endif #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 04c377d..56be495 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,6 +4,8 @@ SET(MICRO_VERSION 0) if( BUILD_SHARED_LIBRARY ) add_library( clew SHARED clew.c ) +elseif( BUILD_STATIC_LIBRARY ) + add_library( clew STATIC clew.c ) else() add_library( clew clew.c ) endif()