Skip to content

Commit ad082fc

Browse files
committed
meson: add FreeImage wrap
1 parent d78ce57 commit ad082fc

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

meson.build

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ install_headers(
210210
subdir: 'openframeworks'
211211
)
212212

213-
compiler = meson.get_compiler('cpp')
214213
cmake = import('cmake')
215214

216215
deps = [
@@ -233,7 +232,6 @@ deps = [
233232
dependency('rtaudio'),
234233
dependency('sndfile'),
235234
dependency('utf8cpp'),
236-
compiler.find_library('freeimage', has_headers: ['FreeImage.h']),
237235
]
238236

239237
if host_machine.system() == 'linux'
@@ -293,6 +291,22 @@ endif
293291

294292
deps += [kissfft_dep]
295293

294+
# FreeImage is a special snowflake: no pkg-config / cmake / etc.. file is installed by it
295+
# so we need to use the compiler to find it
296+
compiler = meson.get_compiler('cpp')
297+
freeimage_dep = compiler.find_library('freeimage', has_headers: ['FreeImage.h'], required: false)
298+
if not freeimage_dep.found()
299+
freeimage_opts = cmake.subproject_options()
300+
# doesn't compile with the define bellow
301+
# freeimage_opts.add_cmake_defines({'BUILD_SHARED_LIBS': true})
302+
# We need -fPIC to link against the produced static library
303+
freeimage_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': true})
304+
freeimage_proj = cmake.subproject('freeimage', options: freeimage_opts)
305+
freeimage_dep = freeimage_proj.dependency('FreeImage')
306+
endif
307+
308+
deps += [freeimage_dep]
309+
296310
lib = library('openFrameworks',
297311
sources,
298312
include_directories: inc,

subprojects/freeimage.wrap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[wrap-git]
2+
url = https://github.com/danoli3/FreeImage.git
3+
revision = 3.19.7
4+
depth = 1
5+
method = cmake
6+
7+
[provide]
8+
freeimage = FreeImage_dep

0 commit comments

Comments
 (0)