@@ -210,7 +210,6 @@ install_headers(
210210 subdir : ' openframeworks'
211211)
212212
213- compiler = meson .get_compiler(' cpp' )
214213cmake = import (' cmake' )
215214
216215deps = [
@@ -232,7 +231,6 @@ deps = [
232231 dependency (' rtaudio' ),
233232 dependency (' sndfile' ),
234233 dependency (' utf8cpp' ),
235- compiler.find_library (' freeimage' , has_headers : [' FreeImage.h' ]),
236234]
237235
238236if host_machine .system() == ' linux'
@@ -293,6 +291,22 @@ endif
293291
294292deps += [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+
296310lib = library (' openFrameworks' ,
297311 sources,
298312 include_directories : inc,
0 commit comments