Subject: [PATCH] changes needed for proper slotting
From: Bernd Waibel <[email-masked]>
Date: Fri, 2 Jul 2021 17:46:33 +0200

Signed-off-by: Bernd Waibel <[email-masked]>
---
 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 2014d27..7dfb2f2 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -200,7 +200,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()
@@ -220,7 +220,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}
@@ -229,11 +229,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 aa5bb46..2767420 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(\"-- Creating symlink in ${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(\"-- Creating symlink in ${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 7d9bb7c..c7e1dd6 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 8022e2e..9f919c8 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(\"-- Creating symlink in ${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(\"-- Creating symlink in ${CMAKE_INSTALL_FULL_DIR}/${OPENEXR_OUTPUT_SUBDIR} ${baselibname} -> ${verlibname}\")")
     set(verlibname)
     set(baselibname)
   endif()
-- 
2.32.0