Skip to content

Commit 2be6969

Browse files
authored
Enable shared library builds and improve CMake script (#3)
* cmake: don't hardcode static library * cmake: remove incomplete option that breaks shared libs * cmake: don't assume that Windows == MSVC
1 parent 6cee4d7 commit 2be6969

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ set(CMAKE_CXX_STANDARD 11)
2626

2727
project(OpenCLRuntimeLoader LANGUAGES C CXX)
2828

29+
option(BUILD_SHARED_LIBS "Set to ON to build a shared library." OFF)
30+
2931
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
3032
include(CTest)
3133
endif()
@@ -40,17 +42,16 @@ set( OpenCLRuntimeLoader_SOURCE_FILES
4042

4143
source_group(Source FILES ${OpenCLRuntimeLoader_SOURCE_FILES})
4244

43-
add_library(OpenCLRuntimeLoader STATIC ${OpenCLRuntimeLoader_SOURCE_FILES})
45+
add_library(OpenCLRuntimeLoader ${OpenCLRuntimeLoader_SOURCE_FILES})
4446
set_target_properties(OpenCLRuntimeLoader PROPERTIES FOLDER "OpenCLRuntimeLoader")
4547
target_include_directories(OpenCLRuntimeLoader PUBLIC ${OpenCL_INCLUDE_DIRS})
4648
target_compile_definitions(OpenCLRuntimeLoader PRIVATE CL_TARGET_OPENCL_VERSION=300)
4749
target_link_libraries(OpenCLRuntimeLoader PRIVATE ${CMAKE_DL_LIBS})
4850

49-
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
51+
if(MSVC)
5052
target_compile_options(OpenCLRuntimeLoader PRIVATE /EHsc)
5153
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
5254
target_compile_options(OpenCLRuntimeLoader PRIVATE -Wall)
53-
set_target_properties(OpenCLRuntimeLoader PROPERTIES LINK_FLAGS "-Wl,--version-script")
5455
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
5556
# TODO
5657
endif()

0 commit comments

Comments
 (0)