From 332462e7f5051b7e26ee3d8c22890cd5e71e7c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= <105517825+cedrik-fuoco-adsk@users.noreply.github.com> Date: Mon, 5 Dec 2022 23:10:29 -0500 Subject: [PATCH] Adsk contrib - Configure the OpenColorIO.pc file on Windows (#1720) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Configure the OpenColorIO.pc file on Windows and fix an issue where CMAKE_INSTALL_PREFIX wasn't included in the cmake build command in ocio.bat. Signed-off-by: Cédrik Fuoco * Removing pkconfig folder since that PC file is not used. Signed-off-by: Cédrik Fuoco * Small tweak in the configuration of OpenColorIO.cmake.in to handle absolute path with CMAKE_INSTALL_LIBDIR or CMAKE_INSTALL_INCLUDEDIR. Keeping exec_prefix for CMAKE_INSTALL_INCLUDE_DIR since it was changed for a specific issue on Mac (see PR #1120). Signed-off-by: Cédrik Fuoco * Using ${prefix} for includedir Signed-off-by: Cédrik Fuoco Signed-off-by: Cédrik Fuoco Co-authored-by: Doug Walker --- share/dev/windows/ocio.bat | 3 ++- src/OpenColorIO/CMakeLists.txt | 26 +++++++++++++++------ src/OpenColorIO/pkgconfig/OpenColorIO.pc.in | 11 --------- 3 files changed, 21 insertions(+), 19 deletions(-) delete mode 100644 src/OpenColorIO/pkgconfig/OpenColorIO.pc.in diff --git a/share/dev/windows/ocio.bat b/share/dev/windows/ocio.bat index 04e61b709..7f24bc279 100644 --- a/share/dev/windows/ocio.bat +++ b/share/dev/windows/ocio.bat @@ -193,6 +193,7 @@ IF NOT EXIST "!PYTHON_PATH!" ( if !DO_CONFIGURE!==1 ( echo Running CMake... cmake -B "!BUILD_PATH!"^ + -DCMAKE_INSTALL_PREFIX=!INSTALL_PATH!^ -DOCIO_INSTALL_EXT_PACKAGES=ALL^ -DCMAKE_BUILD_TYPE=!CMAKE_BUILD_TYPE!^ -DGLEW_ROOT="!GLEW_ROOT!"^ @@ -231,7 +232,7 @@ if Not "%CMAKE_CONFIGURE_STATUS%"=="Failed" ( rem Run cmake --install only if cmake --build was successful. if Not "%CMAKE_BUILD_STATUS%"=="Failed" ( rem Install OCIO - cmake --install !BUILD_PATH! --config !CMAKE_BUILD_TYPE! --prefix !INSTALL_PATH! + cmake --install !BUILD_PATH! --config !CMAKE_BUILD_TYPE! if not ErrorLevel 1 ( set CMAKE_INSTALL_STATUS=Ok ) else ( diff --git a/src/OpenColorIO/CMakeLists.txt b/src/OpenColorIO/CMakeLists.txt index 2bc379e11..b667a6d1f 100755 --- a/src/OpenColorIO/CMakeLists.txt +++ b/src/OpenColorIO/CMakeLists.txt @@ -174,18 +174,30 @@ set(SOURCES SystemMonitor.cpp ) -if(NOT WIN32) +# Install the pkg-config file. - # Install the pkg-config file. +set(prefix ${CMAKE_INSTALL_PREFIX}) +set(exec_prefix "\${prefix}") - set(prefix ${CMAKE_INSTALL_PREFIX}) - set(exec_prefix "\${prefix}") +# CMAKE_INSTALL_LIBDIR is not guaranteed to be relative. +# Not using cmake_path function since it is only available from CMake ≥ 3.20. +if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") + set(libdir "${CMAKE_INSTALL_LIBDIR}") +else() set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") - set(includedir "\${exec_prefix}/${CMAKE_INSTALL_INCLUDEDIR}") - 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() +# CMAKE_INSTALL_INCLUDEDIR is not guaranteed to be relative. +# Not using cmake_path function since it is only available from CMake ≥ 3.20. +if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") + set(includedir "${CMAKE_INSTALL_INCLUDEDIR}") +else() + set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") +endif() + +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) + add_library(OpenColorIO ${SOURCES}) # Require at least a C++11 compatible compiler for consumer projects. diff --git a/src/OpenColorIO/pkgconfig/OpenColorIO.pc.in b/src/OpenColorIO/pkgconfig/OpenColorIO.pc.in deleted file mode 100644 index ed1d5c454..000000000 --- a/src/OpenColorIO/pkgconfig/OpenColorIO.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright Contributors to the OpenColorIO Project. - -libdir=@CMAKE_INSTALL_FULL_LIBDIR@ -includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ - -Name: OpenColorIO -Description: A color management framework for visual effects and animation -Version: @OCIO_VERSION_FULL_STR@ -Cflags: -I${includedir} -Libs: -L${libdir} -lOpenColorIO