From: Bernd Waibel <waebbl-gentoo@posteo.net>
Date: Tue, 3 Aug 2021 19:50:40 +0200
Subject: [PATCH 1/2] changes needed for proper slotting

Signed-off-by: Bernd Waibel <waebbl-gentoo@posteo.net>
---
 cmake/CMakeLists.txt             | 8 ++++----
 cmake/LibraryDefine.cmake        | 8 ++++----
 cmake/OpenEXR.pc.in              | 4 ++--
 cmake/OpenEXRLibraryDefine.cmake | 8 ++++----
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 79497d9..a22afd1 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -205,7 +205,7 @@ if(OPENEXR_INSTALL_PKG_CONFIG)
         DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
     )
   endfunction()
-  openexr_pkg_config_help(OpenEXR.pc.in)
+  openexr_pkg_config_help(OpenEXR-${OpenEXR_VERSION_MAJOR}.pc.in)
 else()
   message(STATUS "-- pkg-config generation disabled")
 endif()
@@ -225,7 +225,7 @@ include(CMakePackageConfigHelpers)
 if(OPENEXR_INSTALL)
 configure_package_config_file(${PROJECT_NAME}Config.cmake.in
   ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
-  INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
+  INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${OpenEXR_VERSION_MAJOR}
 )
 write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake"
   VERSION ${PROJECT_VERSION}
@@ -234,11 +234,11 @@ write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake"
 
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
               ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
-  DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
+  DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${OpenEXR_VERSION_MAJOR}
 )
 
 install(EXPORT ${PROJECT_NAME}
-  DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
+  DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${OpenEXR_VERSION_MAJOR}
   FILE ${PROJECT_NAME}Targets.cmake
   NAMESPACE ${PROJECT_NAME}::
   EXPORT_LINK_INTERFACE_LIBRARIES
diff --git a/cmake/LibraryDefine.cmake b/cmake/LibraryDefine.cmake
index 5696f3f..b4787b1 100644
--- a/cmake/LibraryDefine.cmake
+++ b/cmake/LibraryDefine.cmake
@@ -79,8 +79,8 @@ function(OPENEXR_DEFINE_LIBRARY libname)
     install(TARGETS ${libname}
       EXPORT ${PROJECT_NAME}
       RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
-      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${OPENEXR_OUTPUT_SUBDIR}
+      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/${OPENEXR_OUTPUT_SUBDIR}
       INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
       PUBLIC_HEADER
         DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${OPENEXR_OUTPUT_SUBDIR}
@@ -90,8 +90,8 @@ function(OPENEXR_DEFINE_LIBRARY libname)
     string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
     set(verlibname ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}${OPENEXR_LIB_SUFFIX}${CMAKE_${uppercase_CMAKE_BUILD_TYPE}_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX})
     set(baselibname ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}${CMAKE_${uppercase_CMAKE_BUILD_TYPE}_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX})
-    install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E chdir \"\$ENV\{DESTDIR\}${CMAKE_INSTALL_FULL_LIBDIR}\" ${CMAKE_COMMAND} -E create_symlink ${verlibname} ${baselibname})")
-    install(CODE "message(STATUS \"Creating symlink ${CMAKE_INSTALL_FULL_LIBDIR}/${baselibname} -> ${verlibname}\")")
+    install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E chdir \"\$ENV\{DESTDIR\}${CMAKE_INSTALL_FULL_LIBDIR}/${OPENEXR_OUTPUT_SUBDIR}\" ${CMAKE_COMMAND} -E create_symlink ${verlibname} ${baselibname})")
+    install(CODE "message(STATUS \"Creating symlink ${CMAKE_INSTALL_FULL_LIBDIR}/${OPENEXR_OUTPUT_SUBDIR}/${baselibname} -> ${verlibname}\")")
     set(verlibname)
     set(baselibname)
   endif()
diff --git a/cmake/OpenEXR.pc.in b/cmake/OpenEXR.pc.in
index a74979b..e124b8f 100644
--- a/cmake/OpenEXR.pc.in
+++ b/cmake/OpenEXR.pc.in
@@ -5,9 +5,9 @@
 
 prefix=@prefix@
 exec_prefix=@exec_prefix@
-libdir=@libdir@
+libdir=@libdir@/@OPENEXR_OUTPUT_SUBDIR@
 includedir=@includedir@
-OpenEXR_includedir=@includedir@/OpenEXR
+OpenEXR_includedir=@includedir@/@OPENEXR_OUTPUT_SUBDIR@
 libsuffix=@LIB_SUFFIX_DASH@
 
 Name: OpenEXR
diff --git a/cmake/OpenEXRLibraryDefine.cmake b/cmake/OpenEXRLibraryDefine.cmake
index c6ddd2e..0dc3663 100644
--- a/cmake/OpenEXRLibraryDefine.cmake
+++ b/cmake/OpenEXRLibraryDefine.cmake
@@ -54,8 +54,8 @@ function(OPENEXR_DEFINE_LIBRARY libname)
     install(TARGETS ${libname}
       EXPORT ${PROJECT_NAME}
       RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
-      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${OPENEXR_OUTPUT_SUBDIR}
+      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/${OPENEXR_OUTPUT_SUBDIR}
       INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
       PUBLIC_HEADER
         DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${OPENEXR_OUTPUT_SUBDIR}
@@ -65,8 +65,8 @@ function(OPENEXR_DEFINE_LIBRARY libname)
     string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
     set(verlibname ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}${OPENEXR_LIB_SUFFIX}${CMAKE_${uppercase_CMAKE_BUILD_TYPE}_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX})
     set(baselibname ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}${CMAKE_${uppercase_CMAKE_BUILD_TYPE}_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX})
-    install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E chdir \"\$ENV\{DESTDIR\}${CMAKE_INSTALL_FULL_LIBDIR}\" ${CMAKE_COMMAND} -E create_symlink ${verlibname} ${baselibname})")
-    install(CODE "message(STATUS \"Creating symlink ${CMAKE_INSTALL_FULL_DIR}/${baselibname} -> ${verlibname}\")")
+    install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E chdir \"\$ENV\{DESTDIR\}${CMAKE_INSTALL_FULL_LIBDIR}/${OPENEXR_OUTPUT_SUBDIR}\" ${CMAKE_COMMAND} -E create_symlink ${verlibname} ${baselibname})")
+    install(CODE "message(STATUS \"Creating symlink ${CMAKE_INSTALL_FULL_DIR}/${OPENEXR_OUTPUT_SUBDIR}/${baselibname} -> ${verlibname}\")")
     set(verlibname)
     set(baselibname)
   endif()
-- 
2.32.0

