Skip to content

Commit fde6878

Browse files
author
Stéphane Cerveau
committed
openjpeg: add meson build
Build support: - thirdparties(z, tiff, png, cms2) - jp2 - jpip - jpwl - mj2 - jp3d
1 parent de18f9c commit fde6878

File tree

31 files changed

+2177
-0
lines changed

31 files changed

+2177
-0
lines changed

doc/meson.build

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Generate target to build the html documentation through CMake tool
2+
# After having configured the project with the "build_doc" option you can run make doc
3+
# to generate the html documentation in the doc/html repository of the build folder.
4+
# Try to find the doxygen tool
5+
doxygen_dep = dependency('Doxygen')
6+
if doxygen_dep.found()
7+
# Configure the doxygen config file with variable from CMake and move it
8+
# configure_file([cmake_current_source_dir, '/Doxyfile.dox.cmake.in', cmake_binary_dir, '/doc/Doxyfile-html.dox', '@ONLY'])
9+
# Configure the html mainpage file of the doxygen documentation with variable
10+
# from CMake and move it
11+
# configure_file([cmake_current_source_dir, '/mainpage.dox.in', cmake_binary_dir, '/doc/mainpage.dox', '@ONLY'])
12+
# configure_file([cmake_current_source_dir, '/openjpip.dox.in', cmake_binary_dir, '/doc/openjpip.dox', '@ONLY'])
13+
# copy png file to make local (binary tree) documentation valid:
14+
# configure_file([cmake_current_source_dir, '/jpip_architect.png', cmake_binary_dir, '/doc/html/jpip_architect.png', 'COPYONLY'])
15+
# configure_file([cmake_current_source_dir, '/jpip_protocol.png', cmake_binary_dir, '/doc/html/jpip_protocol.png', 'COPYONLY'])
16+
# file(['GLOB', 'headers', openjpeg_source_dir, '/src/lib/openjp2/*.h', openjpeg_source_dir, '/src/lib/openjp2/*.c', openjpeg_source_dir, '/src/lib/openjpip/*.h', openjpeg_source_dir, '/src/lib/openjpip/*.c'])
17+
# Generate new target to build the html documentation
18+
# add_custom_command(['OUTPUT', cmake_current_binary_dir, '/html/index.html', 'COMMAND', doxygen_executable, cmake_binary_dir, '/doc/Doxyfile-html.dox', 'DEPENDS', cmake_binary_dir, '/doc/Doxyfile-html.dox', cmake_binary_dir, '/doc/mainpage.dox', cmake_binary_dir, '/doc/openjpip.dox', headers])
19+
# add_custom_target(['doc', 'ALL', 'DEPENDS', cmake_binary_dir, '/doc/html/index.html', 'COMMENT', 'Building doxygen documentation'])
20+
# install HTML documentation (install png files too):
21+
# install(['DIRECTORY', cmake_binary_dir, '/doc/html', 'DESTINATION', 'share/doc', 'PATTERN', '.svn', 'EXCLUDE'])
22+
else
23+
message('STATUS: Doxygen not found, we cannot generate the documentation')
24+
endif

meson.build

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
2+
project('openjp2', 'c', 'cpp', version : '2.3.1',
3+
meson_version : '>= 0.55.0',
4+
default_options : [
5+
'buildtype=debugoptimized',
6+
'c_std=gnu89'
7+
]
8+
)
9+
10+
cc = meson.get_compiler('c')
11+
cxx = meson.get_compiler('cpp')
12+
host_system = host_machine.system()
13+
host_cpu = host_machine.cpu_family()
14+
15+
fs = import('fs')
16+
17+
openjpeg_version_major = '2'
18+
openjpeg_version_minor = '3'
19+
openjpeg_version_build = '1'
20+
openjpeg_package_version = '@0@.@1@.@2@'.format(openjpeg_version_major, openjpeg_version_minor, openjpeg_version_build)
21+
22+
23+
m_dep = cc.find_library('m')
24+
thread_dep = dependency('threads')
25+
26+
27+
# clock_gettime might require -rt, or it might not. find out
28+
if not cc.has_function('clock_gettime', prefix : '#define _GNU_SOURCE\n#include <time.h>')
29+
# XXX: untested
30+
rt_dep = cc.find_library('rt')
31+
else
32+
rt_dep = []
33+
endif
34+
35+
wxwidgets_dep = dependency('wxWidgets')
36+
37+
subdir('thirdparty')
38+
39+
if host_system == 'windows'
40+
if get_option('default_library') == 'static'
41+
add_project_arguments(['-DOPJ_STATIC'], language: 'c')
42+
else
43+
add_project_arguments(['-DOPJ_EXPORTS'], language: 'c')
44+
endif
45+
endif
46+
47+
#-----------------------------------------------------------------------------
48+
# Big endian test:
49+
# test_big_endian('OPJ_BIG_ENDIAN')
50+
51+
#-----------------------------------------------------------------------------
52+
# OpenJPEG build configuration options.
53+
#executable_output_path = [openjpeg_binary_dir, '/bin', 'CACHE', 'PATH', 'Single output directory for building all executables.']
54+
#library_output_path = [openjpeg_binary_dir, '/bin', 'CACHE', 'PATH', 'Single output directory for building all libraries.']
55+
# mark_as_advanced(['LIBRARY_OUTPUT_PATH', 'EXECUTABLE_OUTPUT_PATH'])
56+
#-----------------------------------------------------------------------------
57+
# configure name mangling to allow multiple libraries to coexist
58+
# peacefully
59+
60+
#if fs.exists('openjpeg_mangle.h.in')
61+
# mangle_prefix = openjpeg_library_name
62+
# configure_file([cmake_current_source_dir, '/openjpeg_mangle.h.in', cmake_current_binary_dir, '/openjpeg_mangle.h', '@ONLY'])
63+
#endif
64+
#-----------------------------------------------------------------------------
65+
66+
67+
#-----------------------------------------------------------------------------
68+
# Build Library
69+
if get_option('build_jpip_server')
70+
curl_dep = dependency('libcurl', version : '>= 7.55.0', required : false)
71+
fcgi_dep = dependency('fcgi')
72+
threads_dep = dependency('threads')
73+
endif
74+
75+
subdir('src/lib')
76+
77+
#-----------------------------------------------------------------------------
78+
# Build Applications
79+
80+
if get_option('build_codec') or get_option('build_mj2')
81+
# OFF: It will only build 3rd party libs if they are not found on the system
82+
# ON: 3rd party libs will ALWAYS be build, and used
83+
subdir('src/bin')
84+
endif
85+
86+
subdir('wrapping')
87+
#-----------------------------------------------------------------------------
88+
# opj_config.h generation (2/2)
89+
# configure_file([cmake_current_source_dir, '/src/lib/openjp2/opj_config.h.cmake.in', cmake_current_binary_dir, '/src/lib/openjp2/opj_config.h', '@ONLY'])
90+
# configure_file([cmake_current_source_dir, '/src/lib/openjp2/opj_config_private.h.cmake.in', cmake_current_binary_dir, '/src/lib/openjp2/opj_config_private.h', '@ONLY'])
91+
#-----------------------------------------------------------------------------
92+
93+
# build documentation in doc subdir(TODO)
94+
#if get_option('build_doc')
95+
# subdir('doc')
96+
#endif
97+
98+
#-----------------------------------------------------------------------------
99+
# Buld Testing
100+
if get_option('build_testing')
101+
if get_option('build_codec')
102+
# Search openjpeg data needed for the tests
103+
# They could be found via git on the OpenJPEG GitHub code project
104+
# git clone https://github.com/uclouvain/openjpeg-data.git
105+
# find_path(['OPJ_DATA_ROOT', 'README-OPJ-Data', 'PATHS', '$ENV{OPJ_DATA_ROOT}', cmake_source_dir, '/../data', 'NO_DEFAULT_PATH', 'NO_CMAKE_FIND_ROOT_PATH'])
106+
# Add repository where to find tests
107+
#subdir('tests')
108+
else
109+
# message('FATAL_ERROR: You need build codec to run the tests')
110+
endif
111+
endif
112+
113+
# install CHANGES and LICENSE
114+
#if get_option('build_doc')
115+
# if fs.exists('./CHANGES')
116+
# # install(['FILES', 'CHANGES', 'DESTINATION', openjpeg_install_doc_dir])
117+
# endif
118+
# install(['FILES', 'LICENSE', 'DESTINATION', openjpeg_install_doc_dir])
119+
#endif
120+
#-----------------------------------------------------------------------------
121+
# pkgconfig support
122+
123+
if get_option('build_pkgconfig_files')
124+
pkgconfig = import('pkgconfig')
125+
pkgconfig.generate(openjp2_lib, name: 'libopenjp2',
126+
description: 'JPEG2000 library (Part 1 and 2)',
127+
version: meson.project_version(),
128+
libraries: openjp2_lib)
129+
if get_option('build_jpwl')
130+
pkgconfig.generate(openjpwl_lib, name: 'libopenjpwl',
131+
description: 'JPEG2000 Wireless library (Part 11)',
132+
version: meson.project_version(),
133+
libraries: openjpwl_lib)
134+
endif
135+
if get_option('build_jpip')
136+
pkgconfig.generate(openjpip_lib, name: 'libopenjpip',
137+
description: 'JPEG2000 Interactivity tools, APIs and protocols (Part 9)',
138+
version: meson.project_version(),
139+
libraries: openjpip_lib)
140+
endif
141+
if get_option('build_jp3d')
142+
pkgconfig.generate(openjp3d_lib, name: 'libopenjp3d',
143+
description: 'JPEG2000 Extensions for three-dimensional data (Part 10)',
144+
version: meson.project_version(),
145+
libraries: openjp3d_lib)
146+
endif
147+
endif
148+
#-----------------------------------------------------------------------------
149+
# build our version of astyle
150+
#with_astyle = ['FALSE', 'CACHE', 'BOOL', 'If you plan to contribute you should reindent with scripts/prepare-commit.sh (using 'our' astyle)']

meson_options.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
option('build_doc', type : 'boolean', value : false, description : 'Build the HTML documentation (with doxygen if available).')
2+
option('opj_use_dsymutil', type : 'boolean', value : false, description : 'Call dsymutil on binaries after build.')
3+
option('opj_disable_tpsot_fix', type : 'boolean', value : false, description : 'Disable TPsot==TNsot fix. See https://github.com/uclouvain/openjpeg/issues/254.')
4+
option('opj_use_thread', type : 'boolean', value : true, description : 'Build with thread/mutex support ')
5+
option('build_luts_generator', type : 'boolean', value : false, description : 'Build utility to generate t1_luts.h')
6+
option('build_unit_tests', type : 'boolean', value : false, description : 'Build unit tests (bench_dwt, test_sparse_array, etc..)')
7+
option('build_codec', type : 'boolean', value : true, description : 'Build the CODEC executables')
8+
option('build_mj2', type : 'boolean', value : false, description : 'Build the MJ2 executables.')
9+
option('build_jpwl', type : 'boolean', value : false, description : 'Build the JPWL library and executables')
10+
option('build_jpip', type : 'boolean', value : false, description : 'Build the JPIP library and executables.')
11+
option('build_jpip_server', type : 'boolean', value : false, description : 'Build the JPIP server.')
12+
option('build_viewer', type : 'boolean', value : false, description : 'Build the OPJViewer executable (C++)')
13+
option('build_java', type : 'boolean', value : false, description : 'Build the openjpeg jar (Java)')
14+
option('build_jp3d', type : 'boolean', value : false, description : 'Build the JP3D comp')
15+
option('build_thirdparty', type : 'boolean', value : false, description : 'Build the thirdparty executables if it is needed')
16+
option('build_testing', type : 'boolean', value : false, description : 'Build the tests.')
17+
option('build_pkgconfig_files', type : 'boolean', value : true, description : 'Build and install pkg-config files')
18+
option('with_astyle', type : 'boolean', value : false, description : 'Build with astyle')

src/bin/common/meson.build

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# opj_apps_config.h generation
2+
configure_file(input : 'opj_apps_config.h.cmake.in', output : 'opj_apps_config.h', configuration : cappdata, format: 'cmake@')
3+
4+
common_srcs = [ 'color.c']
5+
6+
7+
inc_dirs = include_directories('.','../../lib/openjp2')
8+
9+
common_lib = static_library('common', common_srcs,
10+
include_directories : inc_dirs
11+
)
12+
common_dep = declare_dependency(link_with : common_lib,
13+
include_directories : inc_dirs)

src/bin/jp2/meson.build

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Build the demo app, small examples
2+
3+
# First thing define the common source:
4+
common_srcs = ['convert.c'
5+
, 'convertbmp.c'
6+
, 'index.c'
7+
, '../common/color.c'
8+
, '../common/opj_getopt.c'
9+
]
10+
11+
if libtiff_dep.found()
12+
common_srcs += ['converttif.c']
13+
endif
14+
15+
if libpng_dep.found()
16+
common_srcs += ['convertpng.c']
17+
endif
18+
19+
# Headers file are located here:
20+
inc_dirs = include_directories('../../lib/openjp2', '../common')
21+
22+
openjp2_c_args = []
23+
24+
# Loop over all executables:
25+
foreach exe : ['opj_decompress', 'opj_compress', 'opj_dump']
26+
exe_c = exe + '.c'
27+
exe_src = [exe_c] + common_srcs
28+
exe_deps = [libopenjp2_dep, libpng_dep, libtiff_dep, liblcms2_dep, zlib_dep, rt_dep, m_dep]
29+
exe_exe = executable (exe, exe_src
30+
, c_args : openjp2_c_args
31+
, include_directories : inc_dirs
32+
, dependencies : exe_deps
33+
, install : true
34+
)
35+
endforeach
36+
37+
#if get_option('opj_use_dsymutil')
38+
# add_custom_command(['TARGET', exe, 'POST_BUILD', 'COMMAND', 'dsymutil', '$<TARGET_FILE:${exe}>', 'COMMENT', 'dsymutil $<TARGET_FILE:${exe}>', 'DEPENDS', exe])
39+
#endif
40+
41+
#if get_option('build_doc')
42+
# Install man pages
43+
# install(['FILES', openjpeg_source_dir, '/doc/man/man1/opj_compress.1', openjpeg_source_dir, '/doc/man/man1/opj_decompress.1', openjpeg_source_dir, '/doc/man/man1/opj_dump.1', 'DESTINATION', openjpeg_install_man_dir, '/man1'])
44+
#
45+
#endif

src/bin/jp3d/meson.build

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Build the demo app, small examples
2+
# First thing define the common source:
3+
common_srcs = ['convert.c'
4+
,'../common/opj_getopt.c']
5+
6+
inc_dirs = include_directories('../../lib/openjp2', '../../lib/openjp3d', '../common')
7+
8+
openjp3d_c_args = []
9+
10+
# Loop over all executables:
11+
foreach exe : ['opj_jp3d_compress', 'opj_jp3d_decompress']
12+
exe_c = exe + '.c'
13+
exe_src = [exe_c] + common_srcs
14+
exe_deps = [libopenjp3d_dep, zlib_dep, rt_dep, m_dep]
15+
exe_exe = executable (exe, exe_src
16+
, c_args : openjp3d_c_args
17+
, include_directories : inc_dirs
18+
, dependencies: exe_deps
19+
, install: true
20+
)
21+
endforeach

src/bin/jpip/meson.build

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Headers file are located here:
2+
inc_dirs = ['../../lib/openjp2',
3+
'../common',
4+
'../jp2',
5+
'../../lib/openjpip']
6+
7+
# Tool to embed metadata into JP2 file
8+
opj_jpip_addxml_exe = executable ('opj_jpip_addxml', ['opj_jpip_addxml.c'], install : true)
9+
10+
# Install exe
11+
if get_option('build_jpip_server')
12+
opj_server_srcs = ['opj_server.c']
13+
# Build executable
14+
15+
# target_link_libraries(['opj_server', fcgi_libraries, 'openjpip_server'])
16+
# set_property(['TARGET', 'opj_server', 'APPEND', 'PROPERTY', 'COMPILE_DEFINITIONS', 'SERVER', 'QUIT_SIGNAL=', 'quitJPIP'])
17+
# On unix you need to link to the math library:
18+
19+
opj_server_exe = executable('opj_server', opj_server_srcs,
20+
dependencies : [m_dep],
21+
install : True)
22+
endif
23+
24+
# Loop over all executables:
25+
foreach exe : ['opj_dec_server', 'opj_jpip_transcode', 'opj_jpip_test']
26+
exe_c = exe + '.c'
27+
exe_c_args = []
28+
exe_src = [exe_c] + common_srcs
29+
exe_deps = [libopenjpip_dep, rt_dep, m_dep]
30+
exe_exe = executable (exe, exe_src
31+
, c_args : exe_c_args
32+
, dependencies: exe_deps
33+
, install: true
34+
)
35+
endforeach
36+
37+
message ('no java client')
38+
# Build the two java clients:
39+
#java_dep = dependency('Java')
40+
# javac, jar
41+
# User can override this:
42+
#if 'NOT', 'DEFINED', 'JAVA_SOURCE_VERSION'
43+
# java_source_version = '1.5'
44+
#endif
45+
#if 'NOT', 'DEFINED', 'JAVA_TARGET_VERSION'
46+
# java_target_version = '1.5'
47+
#endif
48+
49+
# Only build the java viewer if dev is found:
50+
#if 'Java_Development_FOUND' and 'Java_JAVAC_EXECUTABLE'
51+
#jflags = '$ENV{JFLAGS}'
52+
# search for package org.apache.xerces.parsers
53+
# find_file(['APACHE_XERCES_JAR', 'NAMES', 'xerces-j2.jar', 'xercesImpl.jar', 'PATHS', '/usr/share/java/', 'NO_DEFAULT_PATH'])
54+
# mark_as_advanced('APACHE_XERCES_JAR')
55+
# Decide to build the simple viewer or the xerces one:
56+
#if 'EXISTS', apache_xerces_jar
57+
# configure_file([cmake_current_source_dir, '/opj_viewer_xerces/dist/manifest.txt.in', cmake_current_binary_dir, '/opj_viewer_xerces/dist/manifest.txt', '@ONLY'])
58+
# build dep list:
59+
# file(['GLOB', 'java2_srcs', 'opj_viewer_xerces/src/*.java'])
60+
# Need some common files:
61+
# list(['APPEND', 'java2_srcs', cmake_current_source_dir, '/opj_viewer/src/ImageManager.java', cmake_current_source_dir, '/opj_viewer/src/ImgdecClient.java', cmake_current_source_dir, '/opj_viewer/src/JPIPHttpClient.java', cmake_current_source_dir, '/opj_viewer/src/MML.java', cmake_current_source_dir, '/opj_viewer/src/PnmImage.java', cmake_current_source_dir, '/opj_viewer/src/RegimViewer.java', cmake_current_source_dir, '/opj_viewer/src/ResizeListener.java'])
62+
# make sure target javac dir exists:
63+
# file(['MAKE_DIRECTORY', cmake_current_binary_dir, '/classes2'])
64+
# Build java
65+
# add_custom_command(['OUTPUT', library_output_path, '/opj_jpip_viewer.jar', 'COMMAND', java_javac_executable, jflags, '-source', java_source_version, '-target', java_target_version, '-classpath', apache_xerces_jar, java2_srcs, '-d', cmake_current_binary_dir, '/classes2', 'COMMAND', java_jar_executable, 'cfm', library_output_path, '/opj_jpip_viewer.jar', cmake_current_binary_dir, '/opj_viewer_xerces/dist/manifest.txt', '-C', cmake_current_binary_dir, '/classes2', '.', 'DEPENDS', java2_srcs, cmake_current_source_dir, '/opj_viewer_xerces/dist/manifest.txt.in', 'COMMENT', 'javac *.java; jar cvf -> opj_viewer_xerces.jar'])
66+
# name the target
67+
# add_custom_target(['OPJViewerXercesJar', 'ALL', 'DEPENDS', library_output_path, '/opj_jpip_viewer.jar', 'COMMENT', 'building opj_jpip_viewer.jar (xerces)'])
68+
# install(['FILES', library_output_path, '/opj_jpip_viewer.jar', 'DESTINATION', openjpeg_install_share_dir, 'COMPONENT', 'JavaModule'])
69+
#else
70+
# opj_viewer (simple, no xerces)
71+
# build dep list:
72+
# file(['GLOB', 'java1_srcs', 'opj_viewer/src/*.java'])
73+
# make sure target javac dir exists:
74+
# file(['MAKE_DIRECTORY', cmake_current_binary_dir, '/classes1'])
75+
# Build java
76+
# add_custom_command(['OUTPUT', library_output_path, '/opj_jpip_viewer.jar', 'COMMAND', java_javac_executable, jflags, '-source', java_source_version, '-target', java_target_version, java1_srcs, '-d', cmake_current_binary_dir, '/classes1', 'COMMAND', java_jar_executable, 'cfm', library_output_path, '/opj_jpip_viewer.jar', cmake_current_source_dir, '/opj_viewer/dist/manifest.txt', '-C', cmake_current_binary_dir, '/classes1', '.', 'DEPENDS', java1_srcs, cmake_current_source_dir, '/opj_viewer/dist/manifest.txt', 'COMMENT', 'javac *.java; jar cvf -> opj_jpip_viewer.jar'])
77+
# name the target
78+
# add_custom_target(['OPJViewerJar', 'ALL', 'DEPENDS', library_output_path, '/opj_jpip_viewer.jar', 'COMMENT', 'building opj_jpip_viewer.jar (no xerces found)'])
79+
# install(['FILES', library_output_path, '/opj_jpip_viewer.jar', 'DESTINATION', openjpeg_install_share_dir, 'COMPONENT', 'JavaModule'])
80+
#endif
81+
#else
82+
# message(['WARNING', 'No java compiler found. Wont be able to build java viewer'])
83+
#endif

src/bin/jpwl/meson.build

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# jpwl apps
2+
# First thing define the common source:
3+
common_srcs = ['convert.c'
4+
, 'index.c'
5+
, '../common/color.c'
6+
, '../common/opj_getopt.c']
7+
# Headers file are located here:
8+
inc_dirs = include_directories('../../lib/openmj2', '../../lib/openjp2', '../common')
9+
10+
openjpwl_c_args = []
11+
12+
13+
openjpwl_c_args += ['-DOPJ_USE_LEGACY', '-DUSE_JPWL']
14+
15+
16+
foreach exe : ['decompress', 'compress']
17+
jpwl_exe = 'opj_jpwl_' + exe
18+
exe_c = jpwl_exe + '.c'
19+
exe_src = [exe_c] + common_srcs
20+
exe_deps = [libopenjpwl_dep, libpng_dep, libtiff_dep, liblcms2_dep, m_dep, zlib_dep ]
21+
exe_exe = executable (exe, exe_src
22+
, c_args : openjpwl_c_args
23+
, include_directories : inc_dirs
24+
, dependencies: exe_deps
25+
, install: true
26+
)
27+
endforeach

0 commit comments

Comments
 (0)