diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2016-05-25 16:34:52 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2016-05-25 21:02:07 +0200 |
| commit | 54179fe1d53156c6b440166fe71a10f238a6ea56 (patch) | |
| tree | 172d5acad3367ac753ea2105b315f7ce738b3c6c /src/lib/openjp2/CMakeLists.txt | |
| parent | 7092f7ea112fcc44e7426c462bf01a406b076620 (diff) | |
Add threading and thread pool API
Diffstat (limited to 'src/lib/openjp2/CMakeLists.txt')
| -rw-r--r-- | src/lib/openjp2/CMakeLists.txt | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/lib/openjp2/CMakeLists.txt b/src/lib/openjp2/CMakeLists.txt index c02a9948..f45ceb34 100644 --- a/src/lib/openjp2/CMakeLists.txt +++ b/src/lib/openjp2/CMakeLists.txt @@ -9,6 +9,8 @@ include_directories( ) # Defines the source code for the library set(OPENJPEG_SRCS + ${CMAKE_CURRENT_SOURCE_DIR}/thread.c + ${CMAKE_CURRENT_SOURCE_DIR}/thread.h ${CMAKE_CURRENT_SOURCE_DIR}/bio.c ${CMAKE_CURRENT_SOURCE_DIR}/bio.h ${CMAKE_CURRENT_SOURCE_DIR}/cio.c @@ -74,6 +76,11 @@ if(OPJ_DISABLE_TPSOT_FIX) add_definitions(-DOPJ_DISABLE_TPSOT_FIX) endif() +# Special case for old i586-mingw32msvc-gcc cross compiler +if(NOT WIN32 AND CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER MATCHES ".*mingw32msvc.*" ) + set(WIN32 YES) +endif() + # Build the library if(WIN32) if(BUILD_SHARED_LIBS) @@ -143,3 +150,36 @@ if(OPJ_USE_DSYMUTIL) DEPENDS ${OPENJPEG_LIBRARY_NAME}) endif() endif() + +################################################################################# +# threading configuration +################################################################################# +set(CMAKE_THREAD_PREFER_PTHREAD TRUE) + +option(USE_THREAD "Build with thread/mutex support " ON) +if(NOT USE_THREAD) + add_definitions( -DMUTEX_stub) +endif(NOT USE_THREAD) + +find_package(Threads QUIET) + +if(USE_THREAD AND WIN32 AND NOT Threads_FOUND ) + add_definitions( -DMUTEX_win32) + set(Threads_FOUND YES) +endif() + +if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_WIN32_THREADS_INIT ) + add_definitions( -DMUTEX_win32) +endif(USE_THREAD AND Threads_FOUND AND CMAKE_USE_WIN32_THREADS_INIT ) + +if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT ) + add_definitions( -DMUTEX_pthread) +endif(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT ) + +if(USE_THREAD AND NOT Threads_FOUND) + message(FATAL_ERROR "No thread library found and thread/mutex support is required by USE_THREAD option") +endif(USE_THREAD AND NOT Threads_FOUND) + +if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT) + TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME} ${CMAKE_THREAD_LIBS_INIT}) +endif(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT) |
