diff --git a/CMakeLists.txt b/CMakeLists.txt index 2586106b69..f2e0b939d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,16 +110,16 @@ if (VERBOSE) else () set (CMAKE_MESSAGE_LOG_LEVEL "STATUS" CACHE STRING "CMake log level to display") endif () -option (${PROJ_NAME}_BUILD_TOOLS "Build the command-line tools" ON) -option (${PROJ_NAME}_BUILD_TESTS "Build the unit tests" ON) +set_option (${PROJ_NAME}_BUILD_TOOLS "Build the command-line tools" ON) +set_option (${PROJ_NAME}_BUILD_TESTS "Build the unit tests" ON) set_option (OIIO_USE_HWY "Enable experimental Google Highway SIMD optimizations (if Highway is available)" OFF VERBOSE) set (OIIO_LIBNAME_SUFFIX "" CACHE STRING "Optional name appended to ${PROJECT_NAME} libraries that are built") -option (BUILD_OIIOUTIL_ONLY "If ON, will build *only* libOpenImageIO_Util" OFF) -option (BUILD_DOCS "If ON, build documentation and man pages." ON) -option (INSTALL_DOCS "If ON, install documentation and man pages." ON) -option (INSTALL_FONTS "If ON, install default fonts" ON) -option (EMBEDPLUGINS "Embed format plugins in libOpenImageIO" ON) +set_option (BUILD_OIIOUTIL_ONLY "If ON, will build *only* libOpenImageIO_Util" OFF) +set_option (BUILD_DOCS "If ON, build documentation and man pages." ON) +set_option (INSTALL_DOCS "If ON, install documentation and man pages." ON) +set_option (INSTALL_FONTS "If ON, install default fonts" ON) +set_option (EMBEDPLUGINS "Embed format plugins in libOpenImageIO" ON) set (PLUGIN_SEARCH_PATH "" CACHE STRING "Default plugin search path") file (TO_NATIVE_PATH "${PLUGIN_SEARCH_PATH}" PLUGIN_SEARCH_PATH_NATIVE) set (CMAKE_DEBUG_POSTFIX "_d" CACHE STRING "Library naming postfix for Debug builds") diff --git a/src/cmake/add_oiio_plugin.cmake b/src/cmake/add_oiio_plugin.cmake index d722b4abb2..4e23810979 100644 --- a/src/cmake/add_oiio_plugin.cmake +++ b/src/cmake/add_oiio_plugin.cmake @@ -76,8 +76,9 @@ macro (add_oiio_plugin) OpenImageIO_EXPORTS) target_compile_options (${_plugin_NAME} PRIVATE ${_plugin_COMPILE_OPTIONS}) target_include_directories (${_plugin_NAME} BEFORE PRIVATE ${_plugin_INCLUDE_DIRS}) - target_link_directories (${_plugin_NAME} PUBLIC OpenImageIO - PRIVATE ${_plugin_LINK_DIRECTORIES}) + if (_plugin_LINK_DIRECTORIES) + target_link_directories (${_plugin_NAME} PRIVATE ${_plugin_LINK_DIRECTORIES}) + endif () target_link_libraries (${_plugin_NAME} PUBLIC OpenImageIO PRIVATE ${_plugin_LINK_LIBRARIES}) set_target_properties (${_plugin_NAME} PROPERTIES PREFIX "" FOLDER "Plugins") diff --git a/src/dpx.imageio/CMakeLists.txt b/src/dpx.imageio/CMakeLists.txt index bc9f015a3e..f156b3a6ba 100644 --- a/src/dpx.imageio/CMakeLists.txt +++ b/src/dpx.imageio/CMakeLists.txt @@ -6,4 +6,9 @@ add_oiio_plugin (dpxinput.cpp dpxoutput.cpp libdpx/DPX.cpp libdpx/OutStream.cpp libdpx/RunLengthEncoding.cpp libdpx/Codec.cpp libdpx/Reader.cpp libdpx/Writer.cpp libdpx/DPXHeader.cpp libdpx/ElementReadStream.cpp libdpx/InStream.cpp libdpx/DPXColorConverter.cpp + LINK_LIBRARIES + # dpxinput.cpp uses Imf::TimeCode from OpenEXR. In the embedded build this + # comes in transitively via libOpenImageIO; a standalone plugin must link + # it explicitly. + $ ) diff --git a/src/ffmpeg.imageio/CMakeLists.txt b/src/ffmpeg.imageio/CMakeLists.txt index ac76c21473..8450a8034b 100644 --- a/src/ffmpeg.imageio/CMakeLists.txt +++ b/src/ffmpeg.imageio/CMakeLists.txt @@ -25,10 +25,17 @@ if (FFmpeg_FOUND) endif() endif() + # Newer ffmpeg versions (3.1.1+) marked some fields and functions (e.g. + # av_init_packet, m_format_context->streams[i]->codec) as deprecated. + # Suppress those warnings here so they apply in both the embedded and + # standalone (EMBEDPLUGINS=0) build paths. + # FIXME -- at some point, come back and figure out how to fix for real + # before the fields disappear entirely. add_oiio_plugin (ffmpeginput.cpp INCLUDE_DIRS ${FFMPEG_INCLUDES} LINK_LIBRARIES ${FFMPEG_LIBRARIES} $ + COMPILE_OPTIONS $<$>:-Wno-deprecated-declarations> DEFINITIONS "USE_FFMPEG" "-DOIIO_FFMPEG_VERSION=\"${FFMPEG_VERSION}\"") else() diff --git a/src/heif.imageio/heifoutput.cpp b/src/heif.imageio/heifoutput.cpp index 729798aad9..b1b054e5d1 100644 --- a/src/heif.imageio/heifoutput.cpp +++ b/src/heif.imageio/heifoutput.cpp @@ -83,12 +83,19 @@ class HeifWriter final : public heif::Context::Writer { }; +// Defined in heifinput.cpp. Declare here at C++ namespace scope (not inside +// the extern "C" block below) so the linkage matches the definition in the +// non-embedded (dynamic plugin) build where OIIO_PLUGIN_EXPORTS_BEGIN is +// `extern "C"`. +extern void +oiio_heif_init(); + + OIIO_PLUGIN_EXPORTS_BEGIN OIIO_EXPORT ImageOutput* heif_output_imageio_create() { - extern void oiio_heif_init(); oiio_heif_init(); return new HeifOutput; } diff --git a/src/include/imageio_pvt.h b/src/include/imageio_pvt.h index eb1aebb798..f794a6dad0 100644 --- a/src/include/imageio_pvt.h +++ b/src/include/imageio_pvt.h @@ -39,8 +39,8 @@ extern std::string extension_list; extern std::string library_list; extern OIIO_UTIL_API int oiio_print_debug; extern OIIO_UTIL_API int oiio_print_uncaught_errors; -extern int oiio_log_times; -extern int openexr_core; +extern OIIO_API int oiio_log_times; +extern OIIO_API int openexr_core; extern int jpeg_com_attributes; extern int png_linear_premult; extern int enable_hwy; diff --git a/src/libOpenImageIO/CMakeLists.txt b/src/libOpenImageIO/CMakeLists.txt index 4a0fedf1da..2fa1c457c3 100644 --- a/src/libOpenImageIO/CMakeLists.txt +++ b/src/libOpenImageIO/CMakeLists.txt @@ -21,15 +21,6 @@ if (NOT USE_EXTERNAL_PUGIXML) endif () endif() -# Make the build complete for newer ffmpeg versions (3.1.1+) that have -# marked m_format_context->streams[i]->codec as deprecated. -# FIXME -- at some point, come back and figure out how to fix for real -# before the field disappears entirely. -if (NOT MSVC) - set_source_files_properties (../ffmpeg.imageio/ffmpeginput.cpp - PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations") -endif() - if (CMAKE_COMPILER_IS_GNUCC) set_source_files_properties (../libutil/SHA1.cpp PROPERTIES COMPILE_FLAGS -Wno-stringop-truncation) diff --git a/src/openexr.imageio/exrinput.cpp b/src/openexr.imageio/exrinput.cpp index 4166642cb9..bfe749747f 100644 --- a/src/openexr.imageio/exrinput.cpp +++ b/src/openexr.imageio/exrinput.cpp @@ -82,6 +82,16 @@ OIIO_PLUGIN_NAMESPACE_BEGIN +#ifdef USE_OPENEXR_CORE +// Defined in exrinput_c.cpp. Declare here at C++ namespace scope (not inside +// the extern "C" block below) so the linkage matches the definition in the +// non-embedded (dynamic plugin) build where OIIO_PLUGIN_EXPORTS_BEGIN is +// `extern "C"`. +extern ImageInput* +openexrcore_input_imageio_create(); +#endif + + // Obligatory material to make this a recognizable imageio plugin: OIIO_PLUGIN_EXPORTS_BEGIN @@ -91,7 +101,6 @@ openexr_input_imageio_create() #ifdef USE_OPENEXR_CORE if (pvt::openexr_core) { // Strutil::print("selecting core\n"); - extern ImageInput* openexrcore_input_imageio_create(); return openexrcore_input_imageio_create(); } #endif diff --git a/src/psd.imageio/CMakeLists.txt b/src/psd.imageio/CMakeLists.txt index 65dc3c8882..28b44b1070 100644 --- a/src/psd.imageio/CMakeLists.txt +++ b/src/psd.imageio/CMakeLists.txt @@ -2,5 +2,6 @@ # SPDX-License-Identifier: Apache-2.0 # https://github.com/AcademySoftwareFoundation/OpenImageIO -add_oiio_plugin (psdinput.cpp) +add_oiio_plugin (psdinput.cpp + LINK_LIBRARIES ZLIB::ZLIB)