summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorL. E. Segovia <amy@centricular.com>2026-05-20 12:48:19 -0300
committerL. E. Segovia <amy@centricular.com>2026-06-27 01:11:58 +0000
commitc89abe6eaad0dace8b619981fc1ffee2b6093c95 (patch)
tree009f838059446ae9bfd8036ffab37d6c166dcc73
parent1df137c26415f81b77cf8b3e019eccf279c0002a (diff)
openjpeg: update to 2.5.4 and fix LibraryType.BOTH for MSVC
The library supports building static and shared libraries simultaneously, but they use by mistake the shared objects for archiving the static library. Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/2254>
-rw-r--r--recipes/openjpeg.recipe13
-rw-r--r--recipes/openjpeg/0001-Add-static-Win32-build.patch49
-rw-r--r--recipes/openjpeg/0002-Fix-pkgconfig-deps-generation.patch36
-rw-r--r--recipes/openjpeg/0003-Handle-lpthread.patch26
4 files changed, 119 insertions, 5 deletions
diff --git a/recipes/openjpeg.recipe b/recipes/openjpeg.recipe
index a7c451bf..d565f7e5 100644
--- a/recipes/openjpeg.recipe
+++ b/recipes/openjpeg.recipe
@@ -4,26 +4,29 @@ from cerbero.enums import Symbolication
from cerbero.tools.libtool import LibtoolLibrary
class Recipe(recipe.Recipe):
- version = '2.5.3'
+ version = '2.5.4'
name = 'openjpeg'
licenses = [{License.BSD_2_Clause: ['LICENSE']}]
stype = SourceType.TARBALL
btype = BuildType.CMAKE
can_msvc = True
url = 'https://github.com/uclouvain/openjpeg/archive/refs/tags/v%(version)s.tar.gz'
- tarball_checksum = '368fe0468228e767433c9ebdea82ad9d801a3ad1e4234421f352c8b06e7aa707'
+ tarball_checksum = 'a695fbe19c0165f295a8531b1e4e855cd94d0875d2f88ec4b61080677e27188a'
configure_options = [
'-DBUILD_CODEC:bool=off'
]
+ patches = [
+ f'{name}/0001-Add-static-Win32-build.patch',
+ f'{name}/0002-Fix-pkgconfig-deps-generation.patch',
+ f'{name}/0003-Handle-lpthread.patch',
+ ]
+
files_libs = ['libopenjp2']
files_devel = ['include/openjpeg-2.5/',
'%(libdir)s/pkgconfig/libopenjp2.pc']
def prepare(self):
- if self.config.target_platform in [Platform.WINDOWS]:
- self.library_type = LibraryType.SHARED
-
if self.config.variants.visualstudio:
self.symbolication_patterns = {
Symbolication.SKIP: [],
diff --git a/recipes/openjpeg/0001-Add-static-Win32-build.patch b/recipes/openjpeg/0001-Add-static-Win32-build.patch
new file mode 100644
index 00000000..c669a63a
--- /dev/null
+++ b/recipes/openjpeg/0001-Add-static-Win32-build.patch
@@ -0,0 +1,49 @@
+From 93dfe2baa3143927786aff901edebc7a3aa8af28 Mon Sep 17 00:00:00 2001
+From: "L. E. Segovia" <amy@centricular.com>
+Date: Wed, 20 May 2026 12:44:42 -0300
+Subject: [PATCH 1/3] Add static Win32 build
+
+---
+ src/lib/openjp2/CMakeLists.txt | 20 ++++++++++++++------
+ 1 file changed, 14 insertions(+), 6 deletions(-)
+
+diff --git a/src/lib/openjp2/CMakeLists.txt b/src/lib/openjp2/CMakeLists.txt
+index fd62335f..0fd55243 100644
+--- a/src/lib/openjp2/CMakeLists.txt
++++ b/src/lib/openjp2/CMakeLists.txt
+@@ -84,18 +84,26 @@ endif()
+ # Build the library
+ add_library(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS})
+ set(INSTALL_LIBS ${OPENJPEG_LIBRARY_NAME})
++if(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
++ # Builds both static and dynamic libs
++ add_library(openjp2_static STATIC ${OPENJPEG_SRCS})
++ if (NOT MSVC)
++ set_target_properties(openjp2_static PROPERTIES OUTPUT_NAME ${OPENJPEG_LIBRARY_NAME})
++ endif()
++ list(APPEND INSTALL_LIBS openjp2_static)
++ target_include_directories(openjp2_static PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${OPENJPEG_INSTALL_SUBDIR}>)
++ target_compile_options(openjp2_static PRIVATE ${OPENJP2_COMPILE_OPTIONS})
++endif()
++
+ if(WIN32)
+ if(BUILD_SHARED_LIBS)
+ target_compile_definitions(${OPENJPEG_LIBRARY_NAME} PRIVATE OPJ_EXPORTS)
+ else()
+ target_compile_definitions(${OPENJPEG_LIBRARY_NAME} PUBLIC OPJ_STATIC)
+ endif()
+-elseif(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
+- # Builds both static and dynamic libs
+- add_library(openjp2_static STATIC ${OPENJPEG_SRCS})
+- set_target_properties(openjp2_static PROPERTIES OUTPUT_NAME ${OPENJPEG_LIBRARY_NAME})
+- list(APPEND INSTALL_LIBS openjp2_static)
+- target_include_directories(openjp2_static PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${OPENJPEG_INSTALL_SUBDIR}>)
++ if(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
++ target_compile_definitions(openjp2_static PUBLIC OPJ_STATIC)
++ endif()
+ endif()
+
+ target_include_directories(${OPENJPEG_LIBRARY_NAME} PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${OPENJPEG_INSTALL_SUBDIR}>)
+--
+2.53.0.windows.3
+
diff --git a/recipes/openjpeg/0002-Fix-pkgconfig-deps-generation.patch b/recipes/openjpeg/0002-Fix-pkgconfig-deps-generation.patch
new file mode 100644
index 00000000..4a2f8de5
--- /dev/null
+++ b/recipes/openjpeg/0002-Fix-pkgconfig-deps-generation.patch
@@ -0,0 +1,36 @@
+From 182d6ad802a6748a22c2175c3beae5783ee1719c Mon Sep 17 00:00:00 2001
+From: Kai Pastor <dg0yt@darc.de>
+Date: Fri, 26 Sep 2025 06:15:15 +0200
+Subject: [PATCH 2/3] Fix pkgconfig 'deps' generation
+
+(cherry picked from commit 5e258319332800f7a9937dc0b8b16b19a07dea8f)
+---
+ CMakeLists.txt | 12 ++++++++----
+ 1 file changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 29a89939..7403e189 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -332,10 +332,14 @@ set_variable_from_rel_or_absolute_path("includedir" "\\\${prefix}" "${CMAKE_INST
+ function(get_pkgconfig_deps NAME OUT)
+ get_target_property(link_libs ${NAME} LINK_LIBRARIES)
+ if(NOT link_libs STREQUAL "link_libs-NOTFOUND")
+- foreach(lib ${link_libs})
+- # omit -lopenjp2 from Libs.private because libopenjp2 is in Requires
+- if(NOT ${lib} STREQUAL ${OPENJPEG_LIBRARY_NAME})
+- string(APPEND deps "-l${lib} ")
++ # omit openjp2 from Libs.private because libopenjp2 is in Requires
++ list(REMOVE_ITEM link_libs "${OPENJPEG_LIBRARY_NAME}")
++ set(deps "")
++ foreach(item IN LISTS link_libs)
++ if(item STREQUAL "-pthread")
++ string(APPEND deps " ${item}")
++ else()
++ string(APPEND deps " -l${item}")
+ endif()
+ endforeach()
+ endif()
+--
+2.54.0
+
diff --git a/recipes/openjpeg/0003-Handle-lpthread.patch b/recipes/openjpeg/0003-Handle-lpthread.patch
new file mode 100644
index 00000000..ad85f12b
--- /dev/null
+++ b/recipes/openjpeg/0003-Handle-lpthread.patch
@@ -0,0 +1,26 @@
+From 7f8b1050209ebf5e2875482a7f40578fc935951a Mon Sep 17 00:00:00 2001
+From: Kai Pastor <dg0yt@darc.de>
+Date: Fri, 26 Sep 2025 07:19:41 +0200
+Subject: [PATCH 3/3] Handle '-lpthread'
+
+(cherry picked from commit 7b508bb00f7fc5e7b61a6035fc4e2622d4ddff0d)
+---
+ CMakeLists.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 7403e189..5c5f4e5c 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -336,7 +336,7 @@ function(get_pkgconfig_deps NAME OUT)
+ list(REMOVE_ITEM link_libs "${OPENJPEG_LIBRARY_NAME}")
+ set(deps "")
+ foreach(item IN LISTS link_libs)
+- if(item STREQUAL "-pthread")
++ if(item STREQUAL "-pthread" OR item STREQUAL "-lpthread")
+ string(APPEND deps " ${item}")
+ else()
+ string(APPEND deps " -l${item}")
+--
+2.54.0
+