Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpenColorIO] Fix OpenColorIO v2.0.1 can't be find_package #19725

Merged
merged 6 commits into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions ports/opencolorio/add-opencolorio-config-cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9295acb6..3f2c3b25 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -265,3 +265,42 @@ configure_file(${CMAKE_SOURCE_DIR}/share/ocio/${OCIO_SETUP_NAME}.in
${CMAKE_CURRENT_BINARY_DIR}/share/ocio/${OCIO_SETUP_NAME} @ONLY)

INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/share/ocio/${OCIO_SETUP_NAME} DESTINATION share/ocio/)
+
+
+###############################################################################
+# Generate OpenColorIO-config.cmake
+# Targets exported to ${PROJECT_NAME}_EXPORTED_TARGETS will be available for
+# import using find_package(OpenColorIO).
+
+include(CMakePackageConfigHelpers)
+
+set(OCIO_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets.cmake")
+set(OCIO_VERSION_CONFIG "${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
+set(OCIO_PROJECT_CONFIG "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake")
+set(OCIO_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
+
+# Version fetched from the top level project()
+write_basic_package_version_file(
+ ${OCIO_VERSION_CONFIG}
+ # Version range supported only if generated by CMake 3.19.2 or newer.
+ COMPATIBILITY SameMajorVersion
+)
+
+configure_package_config_file(
+ ${CMAKE_CURRENT_LIST_DIR}/src/cmake/Config.cmake.in ${OCIO_PROJECT_CONFIG}
+ INSTALL_DESTINATION ${OCIO_CONFIG_INSTALL_DIR}
+ NO_SET_AND_CHECK_MACRO
+ NO_CHECK_REQUIRED_COMPONENTS_MACRO
+)
+
+install(
+ EXPORT ${PROJECT_NAME}_EXPORTED_TARGETS
+ DESTINATION ${OCIO_CONFIG_INSTALL_DIR}
+ NAMESPACE ${PROJECT_NAME}::
+ FILE ${OCIO_TARGETS_EXPORT_NAME}
+)
+
+install(
+ FILES "${OCIO_PROJECT_CONFIG}" "${OCIO_VERSION_CONFIG}"
+ DESTINATION "${OCIO_CONFIG_INSTALL_DIR}"
+)
diff --git a/include/OpenColorIO/CMakeLists.txt b/include/OpenColorIO/CMakeLists.txt
index e4c8a79f..64980f66 100644
--- a/include/OpenColorIO/CMakeLists.txt
+++ b/include/OpenColorIO/CMakeLists.txt
@@ -2,13 +2,22 @@
# Copyright Contributors to the OpenColorIO Project.

configure_file("OpenColorABI.h.in" "${CMAKE_CURRENT_BINARY_DIR}/OpenColorABI.h" @ONLY)
-add_library(public_api INTERFACE)
+add_library(OpenColorIOHeaders INTERFACE)

-set_property(TARGET public_api
- PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/..;${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO
+set(BUILD_INCLUDES
+ ${CMAKE_CURRENT_SOURCE_DIR}/..
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO
)

-add_dependencies(public_api "${CMAKE_CURRENT_BINARY_DIR}/OpenColorABI.h")
+target_include_directories(OpenColorIOHeaders
+ INTERFACE
+ "$<BUILD_INTERFACE:${BUILD_INCLUDES}>"
+ "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+)
+
+add_dependencies(OpenColorIOHeaders "${CMAKE_CURRENT_BINARY_DIR}/OpenColorABI.h")

# public interface

@@ -17,3 +26,7 @@ list(APPEND core_export_headers ${CMAKE_CURRENT_BINARY_DIR}/OpenColorABI.h)

install(FILES ${core_export_headers}
DESTINATION include/OpenColorIO)
+
+install(TARGETS OpenColorIOHeaders
+ EXPORT ${PROJECT_NAME}_EXPORTED_TARGETS
+)
diff --git a/src/OpenColorIO/CMakeLists.txt b/src/OpenColorIO/CMakeLists.txt
index 2ce801e6..a5c1447c 100755
--- a/src/OpenColorIO/CMakeLists.txt
+++ b/src/OpenColorIO/CMakeLists.txt
@@ -204,7 +204,7 @@ target_include_directories(OpenColorIO

target_link_libraries(OpenColorIO
PUBLIC
- public_api
+ OpenColorIOHeaders
PRIVATE
expat::expat
IlmBase::Half
@@ -279,6 +279,7 @@ if(MSVC AND BUILD_SHARED_LIBS)
endif()

install(TARGETS OpenColorIO
+ EXPORT ${PROJECT_NAME}_EXPORTED_TARGETS
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt
index 3e9d70fd..8690ea42 100644
--- a/src/bindings/python/CMakeLists.txt
+++ b/src/bindings/python/CMakeLists.txt
@@ -191,7 +191,7 @@ target_include_directories(PyOpenColorIO
# macOS, to prevent segfaults when potentially working with multiple Python
# installations. See note in:
# https://pybind11.readthedocs.io/en/stable/compiling.html#building-manually
-set(PYOCIO_LINK_PUBLIC public_api)
+set(PYOCIO_LINK_PUBLIC OpenColorIOHeaders)
if(WIN32)
list(INSERT PYOCIO_LINK_PUBLIC 0 ${Python_LIBRARIES})
endif()
diff --git a/src/cmake/Config.cmake.in b/src/cmake/Config.cmake.in
new file mode 100644
index 00000000..eebb2c19
--- /dev/null
+++ b/src/cmake/Config.cmake.in
@@ -0,0 +1,5 @@
+@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+
+include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake)
diff --git a/tests/cpu/CMakeLists.txt b/tests/cpu/CMakeLists.txt
index 67389962..cb03e1da 100755
--- a/tests/cpu/CMakeLists.txt
+++ b/tests/cpu/CMakeLists.txt
@@ -15,7 +15,7 @@ function(add_ocio_test NAME SOURCES PRIVATE_INCLUDES)
)
target_link_libraries(${TEST_BINARY}
PUBLIC
- public_api
+ OpenColorIOHeaders
PRIVATE
expat::expat
IlmBase::Half
7 changes: 6 additions & 1 deletion ports/opencolorio/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ vcpkg_from_github(
SHA512 51568e21eaf863747f67fbcffa7f42ba32f5892e8295dac6c9deb0f6205f57c231ea34ce028d84915e4be2f2773e362b74eaf057c2e4cf3ad4b60bf13a0b73db
HEAD_REF master
PATCHES
add-opencolorio-config-cmake.patch
jixingcn marked this conversation as resolved.
Show resolved Hide resolved
fix-pystring-name.patch
use-find-openxer.patch
use-find-openexr.patch
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
Expand All @@ -31,12 +32,16 @@ vcpkg_cmake_configure(

vcpkg_cmake_install()

vcpkg_fixup_cmake_targets(CONFIG_PATH "lib/cmake/OpenColorIO")

vcpkg_copy_pdbs()

# Clean redundant files
file(REMOVE_RECURSE
${CURRENT_PACKAGES_DIR}/debug/include
${CURRENT_PACKAGES_DIR}/debug/share
${CURRENT_PACKAGES_DIR}/debug/OpenColorIOConfig.cmake
${CURRENT_PACKAGES_DIR}/OpenColorIOConfig.cmake
)
if (OCIO_BUILD_APPS)
vcpkg_copy_tools(
Expand Down
1 change: 1 addition & 0 deletions ports/opencolorio/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "opencolorio",
"version-semver": "2.0.1",
"port-version": 1,
"description": "OpenColorIO (OCIO) is a complete color management solution geared towards motion picture production with an emphasis on visual effects and computer animation. OCIO provides a straightforward and consistent user experience across all supporting applications while allowing for sophisticated back-end configuration options suitable for high-end production usage. OCIO is compatible with the Academy Color Encoding Specification (ACES) and is LUT-format agnostic, supporting many popular formats.",
"homepage": "https://opencolorio.org/",
"dependencies": [
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4606,7 +4606,7 @@
},
"opencolorio": {
"baseline": "2.0.1",
"port-version": 0
"port-version": 1
},
"opencolorio-tools": {
"baseline": "1.1.1",
Expand Down
5 changes: 5 additions & 0 deletions versions/o-/opencolorio.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "bfabad2ccead9d49768c9e9ed622612b0af77986",
"version-semver": "2.0.1",
"port-version": 1
},
{
"git-tree": "3f0f60f376d80012eb0c3bd17ce51e3788070fe4",
"version-semver": "2.0.1",
Expand Down