Fix building with openjph >= 0.23.0
This patch seems to work fine here and pass the testsuite.
Index: openexr-3.4.0/cmake/OpenEXRSetup.cmake
===================================================================
--- openexr-3.4.0.orig/cmake/OpenEXRSetup.cmake
+++ openexr-3.4.0/cmake/OpenEXRSetup.cmake
@@ -280,6 +280,9 @@ if (NOT OPENEXR_FORCE_INTERNAL_OPENJPH)
endif()
endif()
endif()
+if(openjph_VERSION VERSION_GREATER_EQUAL "0.23.0")
+ add_compile_definitions("OPENJPH_NEWER_THAN_0_23")
+endif()
if(NOT EXR_OPENJPH_LIB)
# Using internal OpenJPH
Index: openexr-3.4.0/src/lib/OpenEXRCore/internal_ht.cpp
===================================================================
--- openexr-3.4.0.orig/src/lib/OpenEXRCore/internal_ht.cpp
+++ openexr-3.4.0/src/lib/OpenEXRCore/internal_ht.cpp
@@ -7,12 +7,21 @@
#include <string>
#include <fstream>
+#ifdef OPENJPH_NEWER_THAN_0_23
+#include <openjph/ojph_arch.h>
+#include <openjph/ojph_file.h>
+#include <openjph/ojph_params.h>
+#include <openjph/ojph_mem.h>
+#include <openjph/ojph_codestream.h>
+#include <openjph/ojph_message.h>
+#else
#include <ojph_arch.h>
#include <ojph_file.h>
#include <ojph_params.h>
#include <ojph_mem.h>
#include <ojph_codestream.h>
#include <ojph_message.h>
+#endif
#include "openexr_decode.h"
#include "openexr_encode.h"
No need for ifdef, just add the header folder for any version. See also https://github.com/AcademySoftwareFoundation/openexr/pull/2122
That wouldnt break on older versions?
Nope, because the system "include" should be in the path. But I guess there might be some corner case setup where it might break...
yeah it will only work if you install to any of the default include paths. so my thing is still cleaner.
How about this alternative: do an unconditional "set and forget" change in the header file, but in CMake for < 0.23 do
get_target_property(OPENJPH_INCLUDE_DIR openjph INTERFACE_INCLUDE_DIRECTORIES)
cmake_path(GET OPENJPH_INCLUDE_DIR PARENT_PATH OPENJPH_PARENT_INCLUDE_DIR)
set_target_properties(openjph PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${OPENJPH_PARENT_INCLUDE_DIR})
unset(OPENJPH_INCLUDE_DIR)
unset(OPENJPH_PARENT_INCLUDE_DIR)
Requires CMake bump to min 3.20 though for cmake_path, otherwise some manual string manipulation could be done.
Note that this is only required if finding in config mode, the pkgconf path doesn't need this as the include path there was ok ("bare") all along...