When attempting to build on CMake 3.17 using external OpenEXR, I found there is an issue when creating the ALIAS target OpenColorIO::ImageIOBackend because aliasing a non global target is not supported before CMake 3.18.
CMake Error at share/cmake/modules/FindExtPackages.cmake:130 (add_library):
add_library cannot create ALIAS target "OpenColorIO::ImageIOBackend"
because target "OpenEXR::OpenEXR" is imported but not globally visible.
It seems like the following change can solve the issue:
diff --git a/share/cmake/modules/FindOpenEXR.cmake b/share/cmake/modules/FindOpenEXR.cmake
index 8c14635..bc8c2bb 100644
--- a/share/cmake/modules/FindOpenEXR.cmake
+++ b/share/cmake/modules/FindOpenEXR.cmake
@@ -45,6 +45,7 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL)
if(OpenEXR_FOUND)
get_target_property(OpenEXR_LIBRARY OpenEXR::OpenEXR LOCATION)
get_target_property(OpenEXR_INCLUDE_DIR OpenEXR::OpenEXR INTERFACE_INCLUDE_DIRECTORIES)
+ set_target_properties(OpenEXR::OpenEXR PROPERTIES IMPORTED_GLOBAL TRUE)
endif()
# Override REQUIRED if package can be installed
When attempting to build on CMake 3.17 using external OpenEXR, I found there is an issue when creating the ALIAS target
OpenColorIO::ImageIOBackendbecause aliasing a non global target is not supported before CMake 3.18.It seems like the following change can solve the issue: