mirror of https://github.com/xiph/flac
Add multithreading to CMake
This commit is contained in:
parent
d2f0a1a812
commit
8c41e7f62e
|
@ -24,6 +24,7 @@ option(INSTALL_PKGCONFIG_MODULES "Install PkgConfig modules" ON)
|
|||
option(INSTALL_CMAKE_CONFIG_MODULE "Install CMake package-config module" ON)
|
||||
option(WITH_OGG "ogg support (default: test for libogg)" ON)
|
||||
option(BUILD_SHARED_LIBS "Build shared instead of static libraries" OFF)
|
||||
option(ENABLE_MULTITHREADING "Enable multithreading if pthreads is available" ON)
|
||||
|
||||
set(VERSION ${PROJECT_VERSION})
|
||||
|
||||
|
@ -113,6 +114,7 @@ check_include_file("inttypes.h" HAVE_INTTYPES_H)
|
|||
check_include_file("stdint.h" HAVE_STDINT_H)
|
||||
check_include_file("stdbool.h" HAVE_STDBOOL_H)
|
||||
check_include_file("arm_neon.h" FLAC__HAS_NEONINTRIN)
|
||||
check_include_file("semaphore.h" HAVE_SEMAPHORE_H)
|
||||
|
||||
if(NOT HAVE_STDINT_H OR NOT HAVE_STDBOOL_H)
|
||||
message(SEND_ERROR "Header stdint.h and/or stdbool.h not found")
|
||||
|
@ -198,6 +200,15 @@ if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
|
|||
add_definitions(-DFLAC__OVERFLOW_DETECT)
|
||||
endif()
|
||||
|
||||
if(ENABLE_MULTITHREADING AND HAVE_SEMAPHORE_H)
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
if(CMAKE_USE_PTHREADS_INIT)
|
||||
set(HAVE_PTHREAD 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory("src")
|
||||
add_subdirectory("microbench")
|
||||
if(BUILD_DOCS)
|
||||
|
|
|
@ -88,6 +88,9 @@
|
|||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#cmakedefine HAVE_MEMORY_H
|
||||
|
||||
/* Define if multithreading is enabled */
|
||||
#cmakedefine HAVE_PTHREAD 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#cmakedefine HAVE_STDINT_H
|
||||
|
||||
|
|
|
@ -108,6 +108,10 @@ else()
|
|||
endif()
|
||||
endif()
|
||||
|
||||
if(HAVE_PTHREAD)
|
||||
target_link_libraries(FLAC PUBLIC Threads::Threads)
|
||||
endif()
|
||||
|
||||
add_library(FLAC::FLAC ALIAS FLAC)
|
||||
|
||||
install(TARGETS FLAC EXPORT targets
|
||||
|
|
Loading…
Reference in New Issue