From 372026ae18cbdb527fe7bf84d6240a3f413e430f Mon Sep 17 00:00:00 2001 From: Marat Dukhan Date: Fri, 3 Nov 2017 15:52:32 -0700 Subject: CMake: build pthreadpool as a static library by default --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index f70bd96..e6d2a60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ INCLUDE(GNUInstallDirs) PROJECT(pthreadpool C CXX) # ---[ Options. +OPTION(PTHREADPOOL_BUILD_SHARED "Build pthreadpool as a shared library" OFF) OPTION(PTHREADPOOL_BUILD_TESTS "Build pthreadpool unit tests" ON) OPTION(PTHREADPOOL_BUILD_BENCHMARKS "Build pthreadpool micro-benchmarks" ON) @@ -66,7 +67,11 @@ ENDIF() TARGET_INCLUDE_DIRECTORIES(pthreadpool_interface INTERFACE include) INSTALL(FILES include/pthreadpool.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -ADD_LIBRARY(pthreadpool ${PTHREADPOOL_SRCS}) +IF(PTHREADPOOL_BUILD_SHARED) + ADD_LIBRARY(pthreadpool SHARED ${PTHREADPOOL_SRCS}) +ELSE() + ADD_LIBRARY(pthreadpool STATIC ${PTHREADPOOL_SRCS}) +ENDIF() TARGET_LINK_LIBRARIES(pthreadpool PUBLIC pthreadpool_interface) IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten") SET(CMAKE_THREAD_PREFER_PTHREAD TRUE) -- cgit v1.2.3