|
| 1 | +diff --git a/CMakeLists.txt b/CMakeLists.txt |
| 2 | +index f06aada..3c6c6e2 100644 |
| 3 | +--- a/CMakeLists.txt |
| 4 | ++++ b/CMakeLists.txt |
| 5 | +@@ -31,8 +31,6 @@ IF(CCACHE_BINARY) |
| 6 | + ENDIF() |
| 7 | + |
| 8 | + # ---[ Options. |
| 9 | +-SET(PTHREADPOOL_LIBRARY_TYPE "default" CACHE STRING "Type of library (shared, static, or default) to build") |
| 10 | +-SET_PROPERTY(CACHE PTHREADPOOL_LIBRARY_TYPE PROPERTY STRINGS default static shared) |
| 11 | + OPTION(PTHREADPOOL_ALLOW_DEPRECATED_API "Enable deprecated API functions" ON) |
| 12 | + SET(PTHREADPOOL_SYNC_PRIMITIVE "default" CACHE STRING "Synchronization primitive (condvar, futex, gcd, event, or default) for worker threads") |
| 13 | + SET_PROPERTY(CACHE PTHREADPOOL_SYNC_PRIMITIVE PROPERTY STRINGS default condvar futex gcd event) |
| 14 | +@@ -41,7 +39,7 @@ IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86(_64)?)$") |
| 15 | + ELSE() |
| 16 | + OPTION(PTHREADPOOL_ENABLE_FASTPATH "Enable fast path using atomic decrement instead of atomic compare-and-swap" OFF) |
| 17 | + ENDIF() |
| 18 | +-IF("${CMAKE_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}") |
| 19 | ++IF(FALSE) |
| 20 | + OPTION(PTHREADPOOL_BUILD_TESTS "Build pthreadpool unit tests" ON) |
| 21 | + OPTION(PTHREADPOOL_BUILD_BENCHMARKS "Build pthreadpool micro-benchmarks" ON) |
| 22 | + ELSE() |
| 23 | +@@ -67,7 +65,8 @@ MACRO(PTHREADPOOL_TARGET_ENABLE_CXX11 target) |
| 24 | + ENDMACRO() |
| 25 | + |
| 26 | + # ---[ Download deps |
| 27 | +-IF(NOT DEFINED FXDIV_SOURCE_DIR) |
| 28 | ++find_path(FXDIV_INCLUDE_DIRS "fxdiv.h") |
| 29 | ++IF(FALSE) |
| 30 | + MESSAGE(STATUS "Downloading FXdiv to ${CMAKE_BINARY_DIR}/FXdiv-source (define FXDIV_SOURCE_DIR to avoid it)") |
| 31 | + CONFIGURE_FILE(cmake/DownloadFXdiv.cmake "${CMAKE_BINARY_DIR}/FXdiv-download/CMakeLists.txt") |
| 32 | + EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . |
| 33 | +@@ -118,21 +117,13 @@ ELSE() |
| 34 | + ENDIF() |
| 35 | + |
| 36 | + ADD_LIBRARY(pthreadpool_interface INTERFACE) |
| 37 | +-TARGET_INCLUDE_DIRECTORIES(pthreadpool_interface INTERFACE include) |
| 38 | ++TARGET_INCLUDE_DIRECTORIES(pthreadpool_interface INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) |
| 39 | + IF(NOT PTHREADPOOL_ALLOW_DEPRECATED_API) |
| 40 | + TARGET_COMPILE_DEFINITIONS(pthreadpool_interface INTERFACE PTHREADPOOL_NO_DEPRECATED_API=1) |
| 41 | + ENDIF() |
| 42 | + INSTALL(FILES include/pthreadpool.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
| 43 | + |
| 44 | +-IF(PTHREADPOOL_LIBRARY_TYPE STREQUAL "default") |
| 45 | +- ADD_LIBRARY(pthreadpool ${PTHREADPOOL_SRCS}) |
| 46 | +-ELSEIF(PTHREADPOOL_LIBRARY_TYPE STREQUAL "shared") |
| 47 | +- ADD_LIBRARY(pthreadpool SHARED ${PTHREADPOOL_SRCS}) |
| 48 | +-ELSEIF(PTHREADPOOL_LIBRARY_TYPE STREQUAL "static") |
| 49 | +- ADD_LIBRARY(pthreadpool STATIC ${PTHREADPOOL_SRCS}) |
| 50 | +-ELSE() |
| 51 | +- MESSAGE(FATAL_ERROR "Unsupported library type ${PTHREADPOOL_LIBRARY_TYPE}") |
| 52 | +-ENDIF() |
| 53 | ++ADD_LIBRARY(pthreadpool ${PTHREADPOOL_SRCS}) |
| 54 | + |
| 55 | + IF(PTHREADPOOL_SYNC_PRIMITIVE STREQUAL "condvar") |
| 56 | + TARGET_COMPILE_DEFINITIONS(pthreadpool PRIVATE PTHREADPOOL_USE_FUTEX=0) |
| 57 | +@@ -181,18 +172,22 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 58 | + ENDIF() |
| 59 | + |
| 60 | + # ---[ Configure FXdiv |
| 61 | +-IF(NOT TARGET fxdiv) |
| 62 | ++IF(FALSE) |
| 63 | + SET(FXDIV_BUILD_TESTS OFF CACHE BOOL "") |
| 64 | + SET(FXDIV_BUILD_BENCHMARKS OFF CACHE BOOL "") |
| 65 | + ADD_SUBDIRECTORY( |
| 66 | + "${FXDIV_SOURCE_DIR}" |
| 67 | + "${CMAKE_BINARY_DIR}/FXdiv") |
| 68 | + ENDIF() |
| 69 | +-TARGET_LINK_LIBRARIES(pthreadpool PRIVATE fxdiv) |
| 70 | ++TARGET_INCLUDE_DIRECTORIES(pthreadpool PRIVATE ${FXDIV_INCLUDE_DIRS}) |
| 71 | + |
| 72 | +-INSTALL(TARGETS pthreadpool |
| 73 | ++INSTALL(TARGETS pthreadpool pthreadpool_interface |
| 74 | ++ EXPORT unofficial-pthreadpool-config |
| 75 | ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| 76 | + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 77 | + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
| 78 | ++install(EXPORT unofficial-pthreadpool-config NAMESPACE unofficial:: |
| 79 | ++ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/unofficial-${PROJECT_NAME}) # share/unofficial-pthreadpool |
| 80 | + |
| 81 | + IF(PTHREADPOOL_BUILD_TESTS) |
| 82 | + # ---[ Build google test |
0 commit comments