Changeset View
Changeset View
Standalone View
Standalone View
files/OpenColorIOConfig-generation.patch
- This file was added.
| From b173d4e0c6656026b9ad0c9dce769fc12ef65a68 Mon Sep 17 00:00:00 2001 | |||||
| From: =?UTF-8?q?R=C3=A9mi=20Achard?= <remiachard@gmail.com> | |||||
| Date: Tue, 4 May 2021 12:19:25 +0100 | |||||
| Subject: [PATCH 1/2] Initial OpenColorIO Config CMake implementation | |||||
| MIME-Version: 1.0 | |||||
| Content-Type: text/plain; charset=UTF-8 | |||||
| Content-Transfer-Encoding: 8bit | |||||
| Signed-off-by: Rémi Achard <remiachard@gmail.com> | |||||
| --- | |||||
| CMakeLists.txt | 45 ++++++++++++++++++++++++++++ | |||||
| include/OpenColorIO/CMakeLists.txt | 19 +++++++++--- | |||||
| share/cmake/macros/TargetUtils.cmake | 22 ++++++++++++++ | |||||
| src/OpenColorIO/CMakeLists.txt | 9 +++--- | |||||
| src/bindings/python/CMakeLists.txt | 2 +- | |||||
| src/cmake/Config.cmake.in | 5 ++++ | |||||
| tests/cpu/CMakeLists.txt | 2 +- | |||||
| 7 files changed, 93 insertions(+), 11 deletions(-) | |||||
| create mode 100644 share/cmake/macros/TargetUtils.cmake | |||||
| create mode 100644 src/cmake/Config.cmake.in | |||||
| diff --git a/CMakeLists.txt b/CMakeLists.txt | |||||
| index c33067646..d3fcb5118 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 e4c8a79ff..88d19dbaa 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,5 @@ list(APPEND core_export_headers ${CMAKE_CURRENT_BINARY_DIR}/OpenColorABI.h) | |||||
| install(FILES ${core_export_headers} | |||||
| DESTINATION include/OpenColorIO) | |||||
| + | |||||
| +install_targets(OpenColorIOHeaders) | |||||
| diff --git a/share/cmake/macros/TargetUtils.cmake b/share/cmake/macros/TargetUtils.cmake | |||||
| new file mode 100644 | |||||
| index 000000000..591911d03 | |||||
| --- /dev/null | |||||
| +++ b/share/cmake/macros/TargetUtils.cmake | |||||
| @@ -0,0 +1,22 @@ | |||||
| +# SPDX-License-Identifier: BSD-3-Clause | |||||
| +# Copyright Contributors to the OpenColorIO Project. | |||||
| +# | |||||
| +# Imported from the OpenImageIO project. | |||||
| +# | |||||
| + | |||||
| +########################################################################### | |||||
| +# Macro to install targets to the appropriate locations. Use this instead | |||||
| +# of the install(TARGETS ...) signature. Note that it adds it to the | |||||
| +# export targets list for when we generate config files. | |||||
| +# | |||||
| +# Usage: | |||||
| +# | |||||
| +# install_targets (target1 [target2 ...]) | |||||
| +# | |||||
| +macro (install_targets) | |||||
| + install (TARGETS ${ARGN} | |||||
| + EXPORT ${PROJECT_NAME}_EXPORTED_TARGETS | |||||
| + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT user | |||||
| + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT user | |||||
| + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT developer) | |||||
| +endmacro() | |||||
| diff --git a/src/OpenColorIO/CMakeLists.txt b/src/OpenColorIO/CMakeLists.txt | |||||
| index 2ce801e68..da3209cc1 100755 | |||||
| --- a/src/OpenColorIO/CMakeLists.txt | |||||
| +++ b/src/OpenColorIO/CMakeLists.txt | |||||
| @@ -182,9 +182,6 @@ if(NOT WIN32) | |||||
| configure_file(res/OpenColorIO.pc.in ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc @ONLY) | |||||
| install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) | |||||
| endif() | |||||
| - | |||||
| -# TODO: Install the OpenColorIO-config.cmake. | |||||
| - | |||||
| add_library(OpenColorIO ${SOURCES}) | |||||
| if(BUILD_SHARED_LIBS AND WIN32) | |||||
| @@ -199,12 +196,12 @@ if(BUILD_SHARED_LIBS AND WIN32) | |||||
| endif() | |||||
| target_include_directories(OpenColorIO | |||||
| - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} | |||||
| + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} | |||||
| ) | |||||
| target_link_libraries(OpenColorIO | |||||
| PUBLIC | |||||
| - public_api | |||||
| + OpenColorIOHeaders | |||||
| PRIVATE | |||||
| expat::expat | |||||
| IlmBase::Half | |||||
| @@ -283,3 +280,5 @@ install(TARGETS OpenColorIO | |||||
| RUNTIME DESTINATION bin | |||||
| ARCHIVE DESTINATION lib | |||||
| ) | |||||
| + | |||||
| +install_targets(OpenColorIO) | |||||
| diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt | |||||
| index 3e9d70fd4..8690ea425 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 000000000..eebb2c190 | |||||
| --- /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 673899628..cb03e1da9 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 | |||||
| From 393a89a048851af56942ccea04a9d778a3eb60aa Mon Sep 17 00:00:00 2001 | |||||
| From: =?UTF-8?q?R=C3=A9mi=20Achard?= <remiachard@gmail.com> | |||||
| Date: Wed, 5 May 2021 20:09:19 +0100 | |||||
| Subject: [PATCH 2/2] Remove macro, improve documentation | |||||
| MIME-Version: 1.0 | |||||
| Content-Type: text/plain; charset=UTF-8 | |||||
| Content-Transfer-Encoding: 8bit | |||||
| Signed-off-by: Rémi Achard <remiachard@gmail.com> | |||||
| --- | |||||
| include/OpenColorIO/CMakeLists.txt | 4 +++- | |||||
| src/OpenColorIO/CMakeLists.txt | 3 +-- | |||||
| 4 files changed, 6 insertions(+), 33 deletions(-) | |||||
| delete mode 100644 share/cmake/macros/TargetUtils.cmake | |||||
| diff --git a/include/OpenColorIO/CMakeLists.txt b/include/OpenColorIO/CMakeLists.txt | |||||
| index 88d19dbaa..64980f661 100644 | |||||
| --- a/include/OpenColorIO/CMakeLists.txt | |||||
| +++ b/include/OpenColorIO/CMakeLists.txt | |||||
| @@ -27,4 +27,6 @@ list(APPEND core_export_headers ${CMAKE_CURRENT_BINARY_DIR}/OpenColorABI.h) | |||||
| install(FILES ${core_export_headers} | |||||
| DESTINATION include/OpenColorIO) | |||||
| -install_targets(OpenColorIOHeaders) | |||||
| +install(TARGETS OpenColorIOHeaders | |||||
| + EXPORT ${PROJECT_NAME}_EXPORTED_TARGETS | |||||
| +) | |||||
| diff --git a/src/OpenColorIO/CMakeLists.txt b/src/OpenColorIO/CMakeLists.txt | |||||
| index da3209cc1..48061251b 100755 | |||||
| --- a/src/OpenColorIO/CMakeLists.txt | |||||
| +++ b/src/OpenColorIO/CMakeLists.txt | |||||
| @@ -276,9 +276,8 @@ if(MSVC AND BUILD_SHARED_LIBS) | |||||
| endif() | |||||
| install(TARGETS OpenColorIO | |||||
| + EXPORT ${PROJECT_NAME}_EXPORTED_TARGETS | |||||
| LIBRARY DESTINATION lib | |||||
| RUNTIME DESTINATION bin | |||||
| ARCHIVE DESTINATION lib | |||||
| ) | |||||
| - | |||||
| -install_targets(OpenColorIO) | |||||
Copyright © 2015-2021 Solus Project. The Solus logo is Copyright © 2016-2021 Solus Project. All Rights Reserved.