fix(build): fix EMBEDPLUGINS=0, make many build options env-override (#5272)
Change several build-time options from `option()` to our `set_option()`, which mostly has the effect of allowing them to be overridden by environment variables of the same name, which is really handy for CI variants. In the process, realized that we had some real problems with handling of EMBEDPLUGINS=0, it probably hasn't worked properly for years and went unnoticed because the one CI job variant that was trying to test EMBEDPLUGINS=0 actually *was not* because it was trying to do it by setting the environment variable, unaware that it could not be used to set the option until this patch. So there is a bit of cmake and linkage fixing that needed to be done to get it squared away. Assisted-by: Claude Code / opus-4.8 Signed-off-by: Larry Gritz <lg@larrygritz.com>
This commit is contained in:
+7
-7
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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.
|
||||
$<TARGET_NAME_IF_EXISTS:OpenEXR::OpenEXR>
|
||||
)
|
||||
|
||||
@@ -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}
|
||||
$<TARGET_NAME_IF_EXISTS:BZip2::BZip2>
|
||||
COMPILE_OPTIONS $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-deprecated-declarations>
|
||||
DEFINITIONS "USE_FFMPEG"
|
||||
"-DOIIO_FFMPEG_VERSION=\"${FFMPEG_VERSION}\"")
|
||||
else()
|
||||
|
||||
@@ -83,12 +83,19 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user