Skip to content

Commit

Permalink
libopenjp2: don't link with pthreads on Windows
Browse files Browse the repository at this point in the history
OpenJPEG uses the Windows threading primitives directly, so linking with
-pthread is unnecessary.

Also stop defining both MUTEX_win32 and MUTEX_pthread on Windows.
  • Loading branch information
bgilbert authored and neheb committed Sep 23, 2023
1 parent ac336f4 commit b8d0aed
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,7 @@
"libopenjp2"
],
"versions": [
"2.5.0-3",
"2.5.0-2",
"2.5.0-1",
"2.3.1-9",
Expand Down
2 changes: 1 addition & 1 deletion subprojects/packagefiles/libopenjp2/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ openjpeg_version_subdir = 'openjpeg-@0@.@1@'.format(
)

m_dep = cc.find_library('m', required: false)
thread_dep = dependency('threads')
pthread_dep = dependency('threads', required: false)
rt_dep = cc.find_library('rt', required: false)

wxwidgets_dep = dependency('wxWidgets', required: get_option('build_viewer'))
Expand Down
17 changes: 6 additions & 11 deletions subprojects/packagefiles/libopenjp2/src/lib/openjp2/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,19 @@ endif
#################################################################################
# threading configuration
#################################################################################
cmake_thread_prefer_pthread = 'TRUE'
if not get_option('opj_use_thread')
message('Use stub thread implementation')
openjp2_c_args += '-DMUTEX_stub'
endif

if get_option('opj_use_thread') and host_system == 'windows'
# add_definitions('-DMUTEX_win32')
thread_dep = dependency('', required: false)
elif host_system == 'windows'
message('Use win32 thread implementation')
openjp2_c_args += '-DMUTEX_win32'
endif

if get_option('opj_use_thread') and thread_dep.found()
thread_dep = dependency('', required: false)
elif pthread_dep.found()
message('Use pthread implementation')
openjp2_c_args += '-DMUTEX_pthread'
endif

if get_option('opj_use_thread') and not thread_dep.found()
thread_dep = pthread_dep
else
error('FATAL_ERROR: No thread library found and thread/mutex support is required by "opj_use_thread" option')
endif

Expand Down

0 comments on commit b8d0aed

Please sign in to comment.