From 05e38b135c6473f4928f97b2420d3f002beb284e Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Fri, 23 Jan 2026 17:21:12 +0100 Subject: [PATCH 1/2] Fully embrace GNUInstallDirs - Consolidate the use of different variables for bin, lib and include - Keep ${exec_prefix}/ in pkgconfig, deriving relative paths from std vars - Use CMAKE_INSTALL_FULL_* where absolute paths are expected - Ensure GNUInstallDirs is included early in the project - For WIN32, keep the existing bin installdir for libraries Signed-off-by: Andreas Sturmlechner --- CMakeLists.txt | 36 +++++++------------ CMakeModules/ModuleInstall.cmake | 34 +++++++++--------- CMakeModules/OsgMacroUtils.cmake | 20 +++++------ packaging/ld.so.conf.d/openscenegraph.conf.in | 2 +- packaging/pkgconfig/openscenegraph-osg.pc.in | 2 +- .../openscenegraph-osgAnimation.pc.in | 2 +- .../pkgconfig/openscenegraph-osgDB.pc.in | 2 +- .../pkgconfig/openscenegraph-osgFX.pc.in | 2 +- .../pkgconfig/openscenegraph-osgGA.pc.in | 2 +- .../openscenegraph-osgManipulator.pc.in | 2 +- .../openscenegraph-osgParticle.pc.in | 2 +- .../pkgconfig/openscenegraph-osgShadow.pc.in | 2 +- .../pkgconfig/openscenegraph-osgSim.pc.in | 2 +- .../pkgconfig/openscenegraph-osgTerrain.pc.in | 2 +- .../pkgconfig/openscenegraph-osgText.pc.in | 2 +- .../pkgconfig/openscenegraph-osgUtil.pc.in | 2 +- .../pkgconfig/openscenegraph-osgViewer.pc.in | 2 +- .../pkgconfig/openscenegraph-osgVolume.pc.in | 2 +- .../pkgconfig/openscenegraph-osgWidget.pc.in | 2 +- packaging/pkgconfig/openscenegraph.pc.in | 2 +- packaging/pkgconfig/openthreads.pc.in | 2 +- src/OpenThreads/CMakeLists.txt | 2 +- src/OpenThreads/pthreads/CMakeLists.txt | 8 ++--- src/OpenThreads/win32/CMakeLists.txt | 14 ++++---- src/osgDB/CMakeLists.txt | 2 +- src/osgViewer/CMakeLists.txt | 2 +- 26 files changed, 70 insertions(+), 84 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 446359ae7e3..87232baee73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,13 @@ IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) ENDIF() +include(GNUInstallDirs) + +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20.0") + cmake_path(RELATIVE_PATH CMAKE_INSTALL_FULL_LIBDIR BASE_DIRECTORY "${CMAKE_INSTALL_PREFIX}" OUTPUT_VARIABLE RELATIVE_LIBDIR) +else() + file(RELATIVE_PATH RELATIVE_LIBDIR ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_FULL_LIBDIR}) +endif() IF(ANDROID) INCLUDE(OsgAndroidMacroUtils) @@ -883,18 +890,6 @@ IF(CYGWIN) SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") ENDIF() -# Set OSG_INSTALL_LIBDIR to specify the installation directories of object code libraries -IF(DEFINED LIB_POSTFIX) - # Use LIB_POSTFIX if defined - SET(OSG_INSTALL_LIBDIR lib${LIB_POSTFIX}) -ELSE() - INCLUDE(GNUInstallDirs) - SET(OSG_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}) -ENDIF() -IF(NOT DEFINED LIB_POSTFIX) - SET(LIB_POSTFIX "") -ENDIF() - # Here we apparently do some funky stuff with making the bin/ and lib/ # folders which is probably needed to work around a very old CMake bug? @@ -936,11 +931,6 @@ FOREACH(CONF ${CMAKE_CONFIGURATION_TYPES}) # For each configuration (Debu ENDIF() ENDFOREACH() -#SET(INSTALL_BINDIR OpenSceneGraph/bin) -#SET(INSTALL_INCDIR OpenSceneGraph/include) -#SET(INSTALL_LIBDIR OpenSceneGraph/lib) -#SET(INSTALL_DOCDIR OpenSceneGraph/doc) - ################################################################################ # User Options @@ -1190,7 +1180,7 @@ IF(BUILD_DOCUMENTATION) CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PlatformSpecifics/Windows/icons/src/osg32-32.png ${PROJECT_BINARY_DIR}/doc/OpenSceneGraphReferenceDocs/osg32-32.png COPYONLY ) - #INSTALL(FILES ${PROJECT_BINARY_DIR}/doc/${PROJECT_NAME}ReferenceDocs-${OPENSCENEGRAPH_VERSION}.chm DESTINATION doc OPTIONAL COMPONENT openscenegraph-doc) + INSTALL(DIRECTORY ${PROJECT_BINARY_DIR}/doc/OpenSceneGraphReferenceDocs DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT openscenegraph-doc) # now set up openthreads documentation generation @@ -1206,7 +1196,7 @@ IF(BUILD_DOCUMENTATION) CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PlatformSpecifics/Windows/icons/src/osg32-32.png ${PROJECT_BINARY_DIR}/doc/OpenThreadsReferenceDocs/osg32-32.png COPYONLY ) - #INSTALL(FILES ${PROJECT_BINARY_DIR}/doc/${PROJECT_NAME}ReferenceDocs-${OPENSCENEGRAPH_VERSION}.chm DESTINATION doc OPTIONAL COMPONENT openscenegraph-doc) + INSTALL(DIRECTORY ${PROJECT_BINARY_DIR}/doc/OpenThreadsReferenceDocs DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT openthreads-doc) # Process our other doxyfiles but don't create targets for these @@ -1275,7 +1265,7 @@ FOREACH(PKGCONFIG_FILE ${PKGCONFIG_FILES}) ${PROJECT_BINARY_DIR}/packaging/pkgconfig/${PKGCONFIG_FILE}.pc @ONLY ) - INSTALL(FILES ${PROJECT_BINARY_DIR}/packaging/pkgconfig/${PKGCONFIG_FILE}.pc DESTINATION lib${LIB_POSTFIX}/pkgconfig COMPONENT libopenscenegraph-dev) + INSTALL(FILES ${PROJECT_BINARY_DIR}/packaging/pkgconfig/${PKGCONFIG_FILE}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT libopenscenegraph-dev) ENDFOREACH(PKGCONFIG_FILE) @@ -1288,7 +1278,7 @@ IF(REQUIRES_LIBPATH_MESSAGE) IF (NOT OSG_LIBPATH_MESSAGE_HAS_BEEN_RUN_BEFORE) SET(OSG_LIBPATH_MESSAGE_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether the libpath message has been reported before") - MESSAGE("\nThe build system is configured to install libraries to ${CMAKE_INSTALL_PREFIX}/lib${LIB_POSTFIX}\n" + MESSAGE("\nThe build system is configured to install libraries to ${CMAKE_INSTALL_FULL_LIBDIR}\n" "Your applications may not be able to find your installed libraries unless you:\n" " set your LD_LIBRARY_PATH (user specific) or\n" " update your ld.so configuration (system wide)") @@ -1310,12 +1300,12 @@ IF(REQUIRES_LIBPATH_MESSAGE) IF(EXISTS /etc/ld.so.conf) MESSAGE("You have an ld.so.conf file in /etc, if you wish to ensure \n" "that applications find the installed osg libraries, system wide, you\n" - "could add ${CMAKE_INSTALL_PREFIX}/lib${LIB_POSTFIX} to it.") + "could add ${CMAKE_INSTALL_FULL_LIBDIR} to it.") ENDIF() ENDIF() # emit a message during installation. - INSTALL(CODE "MESSAGE(\"Libraries were installed to ${CMAKE_INSTALL_PREFIX}lib${LIB_POSTFIX}.\\nYou may need to update your ld.so configuration. \")") + INSTALL(CODE "MESSAGE(\"Libraries were installed to ${CMAKE_INSTALL_FULL_LIBDIR}.\\nYou may need to update your ld.so configuration. \")") ENDIF() diff --git a/CMakeModules/ModuleInstall.cmake b/CMakeModules/ModuleInstall.cmake index 15a79f57789..7d5d7940fe1 100644 --- a/CMakeModules/ModuleInstall.cmake +++ b/CMakeModules/ModuleInstall.cmake @@ -4,16 +4,6 @@ # ${LIB_NAME} # ${TARGET_H} -SET(INSTALL_INCDIR include) -SET(INSTALL_BINDIR bin) -IF(WIN32) - SET(INSTALL_LIBDIR bin) - SET(INSTALL_ARCHIVEDIR lib) -ELSE() - SET(INSTALL_LIBDIR lib${LIB_POSTFIX}) - SET(INSTALL_ARCHIVEDIR lib${LIB_POSTFIX}) -ENDIF() - SET(HEADERS_GROUP "Header Files") SOURCE_GROUP( @@ -25,21 +15,29 @@ IF(MSVC AND OSG_MSVC_VERSIONED_DLL) HANDLE_MSVC_DLL() ENDIF() -INSTALL( - TARGETS ${LIB_NAME} - RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT libopenscenegraph - LIBRARY DESTINATION ${INSTALL_LIBDIR} COMPONENT libopenscenegraph - ARCHIVE DESTINATION ${INSTALL_ARCHIVEDIR} COMPONENT libopenscenegraph-dev -) +# Keep pre-existing WIN32 INSTALL_LIBDIR=bin setting +IF(WIN32) + INSTALL(TARGETS ${LIB_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libopenscenegraph + LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libopenscenegraph + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libopenscenegraph-dev + ) +ELSE() + INSTALL(TARGETS ${LIB_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libopenscenegraph + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libopenscenegraph + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libopenscenegraph-dev + ) +ENDIF() IF(MSVC AND DYNAMIC_OPENSCENEGRAPH) - INSTALL(FILES $ DESTINATION ${INSTALL_BINDIR} COMPONENT libopenthreads) + INSTALL(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libopenthreads) ENDIF(MSVC AND DYNAMIC_OPENSCENEGRAPH) IF(NOT OSG_COMPILE_FRAMEWORKS) INSTALL ( FILES ${TARGET_H} - DESTINATION ${INSTALL_INCDIR}/${LIB_NAME} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${LIB_NAME} COMPONENT libopenscenegraph-dev ) ELSE() diff --git a/CMakeModules/OsgMacroUtils.cmake b/CMakeModules/OsgMacroUtils.cmake index e9f1d0c3dd9..226cff99185 100644 --- a/CMakeModules/OsgMacroUtils.cmake +++ b/CMakeModules/OsgMacroUtils.cmake @@ -264,21 +264,21 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME) ENDIF() SETUP_LINK_LIBRARIES() -#the installation path are differentiated for win32 that install in bin versus other architecture that install in lib${LIB_POSTFIX}/${OSG_PLUGINS} +# installation paths are differentiated for win32 installing in bin versus other architectures that install in ${CMAKE_INSTALL_LIBDIR}/${OSG_PLUGINS} IF(WIN32) INSTALL(TARGETS ${TARGET_TARGETNAME} - RUNTIME DESTINATION bin COMPONENT ${PACKAGE_COMPONENT} - ARCHIVE DESTINATION lib/${OSG_PLUGINS} COMPONENT libopenscenegraph-dev - LIBRARY DESTINATION bin/${OSG_PLUGINS} COMPONENT ${PACKAGE_COMPONENT}) + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${PACKAGE_COMPONENT} + LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}/${OSG_PLUGINS} COMPONENT ${PACKAGE_COMPONENT} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/${OSG_PLUGINS} COMPONENT libopenscenegraph-dev) IF(MSVC AND DYNAMIC_OPENSCENEGRAPH) INSTALL(FILES $ DESTINATION bin/${OSG_PLUGINS} COMPONENT ${PACKAGE_COMPONENT}) - ENDIF(MSVC AND DYNAMIC_OPENSCENEGRAPH) - ELSE(WIN32) + ENDIF() + ELSE() INSTALL(TARGETS ${TARGET_TARGETNAME} - RUNTIME DESTINATION bin COMPONENT ${PACKAGE_COMPONENT} - ARCHIVE DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} COMPONENT libopenscenegraph-dev - LIBRARY DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} COMPONENT ${PACKAGE_COMPONENT}) - ENDIF(WIN32) + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${PACKAGE_COMPONENT} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${OSG_PLUGINS} COMPONENT ${PACKAGE_COMPONENT} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/${OSG_PLUGINS} COMPONENT libopenscenegraph-dev) + ENDIF() ENDMACRO(SETUP_PLUGIN) diff --git a/packaging/ld.so.conf.d/openscenegraph.conf.in b/packaging/ld.so.conf.d/openscenegraph.conf.in index 51d1e5a7bbe..a0ec7248138 100644 --- a/packaging/ld.so.conf.d/openscenegraph.conf.in +++ b/packaging/ld.so.conf.d/openscenegraph.conf.in @@ -1,2 +1,2 @@ # openscenegraph library configuration -${CMAKE_INSTALL_PREFIX}/lib${LIB_POSTFIX} +${CMAKE_INSTALL_FULL_LIBDIR} diff --git a/packaging/pkgconfig/openscenegraph-osg.pc.in b/packaging/pkgconfig/openscenegraph-osg.pc.in index 2ebe47ddb96..67cdc6ea4c2 100644 --- a/packaging/pkgconfig/openscenegraph-osg.pc.in +++ b/packaging/pkgconfig/openscenegraph-osg.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openscenegraph-osg diff --git a/packaging/pkgconfig/openscenegraph-osgAnimation.pc.in b/packaging/pkgconfig/openscenegraph-osgAnimation.pc.in index eb9cb85eafc..725963f679f 100644 --- a/packaging/pkgconfig/openscenegraph-osgAnimation.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgAnimation.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openscenegraph-osgAnimation diff --git a/packaging/pkgconfig/openscenegraph-osgDB.pc.in b/packaging/pkgconfig/openscenegraph-osgDB.pc.in index 0015a529ebf..044c4e2ca4a 100644 --- a/packaging/pkgconfig/openscenegraph-osgDB.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgDB.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openscenegraph-osgDB diff --git a/packaging/pkgconfig/openscenegraph-osgFX.pc.in b/packaging/pkgconfig/openscenegraph-osgFX.pc.in index 92ce51edaff..80504615568 100644 --- a/packaging/pkgconfig/openscenegraph-osgFX.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgFX.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openscenegraph-osgFX diff --git a/packaging/pkgconfig/openscenegraph-osgGA.pc.in b/packaging/pkgconfig/openscenegraph-osgGA.pc.in index 17d7125b273..5db887da073 100644 --- a/packaging/pkgconfig/openscenegraph-osgGA.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgGA.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openscenegraph-osgGA diff --git a/packaging/pkgconfig/openscenegraph-osgManipulator.pc.in b/packaging/pkgconfig/openscenegraph-osgManipulator.pc.in index 6ef410c067d..303571b9373 100644 --- a/packaging/pkgconfig/openscenegraph-osgManipulator.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgManipulator.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openscenegraph-osgManipulator diff --git a/packaging/pkgconfig/openscenegraph-osgParticle.pc.in b/packaging/pkgconfig/openscenegraph-osgParticle.pc.in index 2f504e2284d..a2dd6aeb8c7 100644 --- a/packaging/pkgconfig/openscenegraph-osgParticle.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgParticle.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openscenegraph-osgParticle diff --git a/packaging/pkgconfig/openscenegraph-osgShadow.pc.in b/packaging/pkgconfig/openscenegraph-osgShadow.pc.in index 00c5462443b..746f6737346 100644 --- a/packaging/pkgconfig/openscenegraph-osgShadow.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgShadow.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openscenegraph-osgShadow diff --git a/packaging/pkgconfig/openscenegraph-osgSim.pc.in b/packaging/pkgconfig/openscenegraph-osgSim.pc.in index 68e6f2b125c..ff2e854c207 100644 --- a/packaging/pkgconfig/openscenegraph-osgSim.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgSim.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openscenegraph-osgSim diff --git a/packaging/pkgconfig/openscenegraph-osgTerrain.pc.in b/packaging/pkgconfig/openscenegraph-osgTerrain.pc.in index 549494b2960..5d045a70df8 100644 --- a/packaging/pkgconfig/openscenegraph-osgTerrain.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgTerrain.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openscenegraph-osgTerrain diff --git a/packaging/pkgconfig/openscenegraph-osgText.pc.in b/packaging/pkgconfig/openscenegraph-osgText.pc.in index 68f4b74abb7..3a0d73363b5 100644 --- a/packaging/pkgconfig/openscenegraph-osgText.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgText.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openscenegraph-osgText diff --git a/packaging/pkgconfig/openscenegraph-osgUtil.pc.in b/packaging/pkgconfig/openscenegraph-osgUtil.pc.in index 4b1950d4b95..651cd3930ae 100644 --- a/packaging/pkgconfig/openscenegraph-osgUtil.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgUtil.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openscenegraph-osgUtil diff --git a/packaging/pkgconfig/openscenegraph-osgViewer.pc.in b/packaging/pkgconfig/openscenegraph-osgViewer.pc.in index 6172d0db4c5..d2bf33fd194 100644 --- a/packaging/pkgconfig/openscenegraph-osgViewer.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgViewer.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openscenegraph-osgViewer diff --git a/packaging/pkgconfig/openscenegraph-osgVolume.pc.in b/packaging/pkgconfig/openscenegraph-osgVolume.pc.in index 5a283826fbf..07ef92c4775 100644 --- a/packaging/pkgconfig/openscenegraph-osgVolume.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgVolume.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openscenegraph-osgVolume diff --git a/packaging/pkgconfig/openscenegraph-osgWidget.pc.in b/packaging/pkgconfig/openscenegraph-osgWidget.pc.in index 4e7eaea5df2..75dc44311a4 100644 --- a/packaging/pkgconfig/openscenegraph-osgWidget.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgWidget.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openscenegraph-osgWidget diff --git a/packaging/pkgconfig/openscenegraph.pc.in b/packaging/pkgconfig/openscenegraph.pc.in index 784ac468896..c5b57e0dbe1 100644 --- a/packaging/pkgconfig/openscenegraph.pc.in +++ b/packaging/pkgconfig/openscenegraph.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openscenegraph diff --git a/packaging/pkgconfig/openthreads.pc.in b/packaging/pkgconfig/openthreads.pc.in index 125c4fc7a4f..0a696403608 100644 --- a/packaging/pkgconfig/openthreads.pc.in +++ b/packaging/pkgconfig/openthreads.pc.in @@ -2,7 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_POSTFIX@ +libdir=${exec_prefix}/@RELATIVE_LIBDIR@ includedir=${prefix}/include Name: openthreads diff --git a/src/OpenThreads/CMakeLists.txt b/src/OpenThreads/CMakeLists.txt index 9cd054381b3..67013568831 100644 --- a/src/OpenThreads/CMakeLists.txt +++ b/src/OpenThreads/CMakeLists.txt @@ -113,4 +113,4 @@ CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/packaging/pkgconfig/openthreads.pc.in @ONLY ) -INSTALL(FILES ${PROJECT_BINARY_DIR}/packaging/pkgconfig/openthreads.pc DESTINATION lib${LIB_POSTFIX}/pkgconfig COMPONENT libopenthreads-dev) +INSTALL(FILES ${PROJECT_BINARY_DIR}/packaging/pkgconfig/openthreads.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT libopenthreads-dev) diff --git a/src/OpenThreads/pthreads/CMakeLists.txt b/src/OpenThreads/pthreads/CMakeLists.txt index e18969c744f..003755622fc 100644 --- a/src/OpenThreads/pthreads/CMakeLists.txt +++ b/src/OpenThreads/pthreads/CMakeLists.txt @@ -157,15 +157,15 @@ ELSE() INSTALL( TARGETS OpenThreads - ARCHIVE DESTINATION lib${LIB_POSTFIX} COMPONENT libopenthreads-dev - LIBRARY DESTINATION lib${LIB_POSTFIX} COMPONENT libopenthreads - RUNTIME DESTINATION bin COMPONENT libopenthreads + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libopenthreads-dev + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libopenthreads + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libopenthreads ) IF(NOT OSG_COMPILE_FRAMEWORKS) INSTALL( FILES ${OpenThreads_PUBLIC_HEADERS} - DESTINATION include/OpenThreads + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/OpenThreads COMPONENT libopenthreads-dev ) diff --git a/src/OpenThreads/win32/CMakeLists.txt b/src/OpenThreads/win32/CMakeLists.txt index be5d14f0323..1e718fc5d9a 100644 --- a/src/OpenThreads/win32/CMakeLists.txt +++ b/src/OpenThreads/win32/CMakeLists.txt @@ -43,22 +43,20 @@ IF(MSVC AND OSG_MSVC_VERSIONED_DLL) HANDLE_MSVC_DLL(ot ${OPENTHREADS_SOVERSION}) ENDIF() -SET(INSTALL_BINDIR bin) - INSTALL( TARGETS OpenThreads - ARCHIVE DESTINATION lib COMPONENT libopenthreads-dev - LIBRARY DESTINATION lib COMPONENT libopenthreads - RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT libopenthreads + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libopenthreads + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libopenthreads + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libopenthreads-dev ) INSTALL( FILES ${OpenThreads_PUBLIC_HEADERS} - DESTINATION include/OpenThreads + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/OpenThreads COMPONENT libopenthreads-dev ) IF(MSVC AND DYNAMIC_OPENSCENEGRAPH) - INSTALL(FILES $ DESTINATION ${INSTALL_BINDIR} COMPONENT libopenthreads) -ENDIF(MSVC AND DYNAMIC_OPENSCENEGRAPH) + INSTALL(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libopenthreads) +ENDIF() #commented out# INCLUDE(ModuleInstall OPTIONAL) diff --git a/src/osgDB/CMakeLists.txt b/src/osgDB/CMakeLists.txt index 340aae0952b..0a526e70fe1 100644 --- a/src/osgDB/CMakeLists.txt +++ b/src/osgDB/CMakeLists.txt @@ -7,7 +7,7 @@ IF (DYNAMIC_OPENSCENEGRAPH) IF(OSG_PLUGIN_SEARCH_INSTALL_DIR_FOR_PLUGINS) # Add a default plugin search path component - ADD_DEFINITIONS(-DOSG_DEFAULT_LIBRARY_PATH=\"${CMAKE_INSTALL_PREFIX}/lib${LIB_POSTFIX}/${OSG_PLUGINS}\") + ADD_DEFINITIONS(-DOSG_DEFAULT_LIBRARY_PATH=\"${CMAKE_INSTALL_FULL_LIBDIR}/${OSG_PLUGINS}\") ENDIF() # Set the library extension according to what configuration is being built. diff --git a/src/osgViewer/CMakeLists.txt b/src/osgViewer/CMakeLists.txt index 1f21cf2224d..4f132f44857 100644 --- a/src/osgViewer/CMakeLists.txt +++ b/src/osgViewer/CMakeLists.txt @@ -263,7 +263,7 @@ FOREACH(HEADERFILE ${TARGET_H_NO_MODULE_INSTALL} ${CONFIG_HEADER_FILES}) GET_FILENAME_COMPONENT(REL_INCLUDE_PATH ${REL_INCLUDEFILE} PATH) INSTALL(FILES ${HEADERFILE} - DESTINATION ${INSTALL_INCDIR}/${LIB_NAME}/${REL_INCLUDE_PATH} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${LIB_NAME}/${REL_INCLUDE_PATH} COMPONENT libopenscenegraph-dev ) ENDFOREACH() From ff1a0946b8da7a2645b48d04b7f8a853a457a47b Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Fri, 23 Jan 2026 22:22:48 +0100 Subject: [PATCH 2/2] Also propagate relative include dir to pkgconfig files Signed-off-by: Andreas Sturmlechner --- CMakeLists.txt | 2 ++ packaging/pkgconfig/openscenegraph-osg.pc.in | 2 +- packaging/pkgconfig/openscenegraph-osgAnimation.pc.in | 2 +- packaging/pkgconfig/openscenegraph-osgDB.pc.in | 2 +- packaging/pkgconfig/openscenegraph-osgFX.pc.in | 2 +- packaging/pkgconfig/openscenegraph-osgGA.pc.in | 2 +- packaging/pkgconfig/openscenegraph-osgManipulator.pc.in | 2 +- packaging/pkgconfig/openscenegraph-osgParticle.pc.in | 2 +- packaging/pkgconfig/openscenegraph-osgShadow.pc.in | 2 +- packaging/pkgconfig/openscenegraph-osgSim.pc.in | 2 +- packaging/pkgconfig/openscenegraph-osgTerrain.pc.in | 2 +- packaging/pkgconfig/openscenegraph-osgText.pc.in | 2 +- packaging/pkgconfig/openscenegraph-osgUtil.pc.in | 2 +- packaging/pkgconfig/openscenegraph-osgViewer.pc.in | 2 +- packaging/pkgconfig/openscenegraph-osgVolume.pc.in | 2 +- packaging/pkgconfig/openscenegraph-osgWidget.pc.in | 2 +- packaging/pkgconfig/openscenegraph.pc.in | 2 +- packaging/pkgconfig/openthreads.pc.in | 2 +- 18 files changed, 19 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87232baee73..bb57f27ebb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,8 +145,10 @@ include(GNUInstallDirs) if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20.0") cmake_path(RELATIVE_PATH CMAKE_INSTALL_FULL_LIBDIR BASE_DIRECTORY "${CMAKE_INSTALL_PREFIX}" OUTPUT_VARIABLE RELATIVE_LIBDIR) + cmake_path(RELATIVE_PATH CMAKE_INSTALL_FULL_INCLUDEDIR BASE_DIRECTORY "${CMAKE_INSTALL_PREFIX}" OUTPUT_VARIABLE RELATIVE_INCLUDEDIR) else() file(RELATIVE_PATH RELATIVE_LIBDIR ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_FULL_LIBDIR}) + file(RELATIVE_PATH RELATIVE_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_FULL_INCLUDEDIR}) endif() IF(ANDROID) diff --git a/packaging/pkgconfig/openscenegraph-osg.pc.in b/packaging/pkgconfig/openscenegraph-osg.pc.in index 67cdc6ea4c2..c3ef87a56a9 100644 --- a/packaging/pkgconfig/openscenegraph-osg.pc.in +++ b/packaging/pkgconfig/openscenegraph-osg.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openscenegraph-osg Description: 3D scenegraph diff --git a/packaging/pkgconfig/openscenegraph-osgAnimation.pc.in b/packaging/pkgconfig/openscenegraph-osgAnimation.pc.in index 725963f679f..f6bf0c15ebe 100644 --- a/packaging/pkgconfig/openscenegraph-osgAnimation.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgAnimation.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openscenegraph-osgAnimation Description: Skinning and morphing library for Openscenegraph diff --git a/packaging/pkgconfig/openscenegraph-osgDB.pc.in b/packaging/pkgconfig/openscenegraph-osgDB.pc.in index 044c4e2ca4a..a678ae71448 100644 --- a/packaging/pkgconfig/openscenegraph-osgDB.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgDB.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openscenegraph-osgDB Description: File format reading library for Openscenegraph diff --git a/packaging/pkgconfig/openscenegraph-osgFX.pc.in b/packaging/pkgconfig/openscenegraph-osgFX.pc.in index 80504615568..ba23dc3bd55 100644 --- a/packaging/pkgconfig/openscenegraph-osgFX.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgFX.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openscenegraph-osgFX Description: Special effects library for Openscenegraph diff --git a/packaging/pkgconfig/openscenegraph-osgGA.pc.in b/packaging/pkgconfig/openscenegraph-osgGA.pc.in index 5db887da073..75b68ca7467 100644 --- a/packaging/pkgconfig/openscenegraph-osgGA.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgGA.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openscenegraph-osgGA Description: GUI event library for Openscenegraph diff --git a/packaging/pkgconfig/openscenegraph-osgManipulator.pc.in b/packaging/pkgconfig/openscenegraph-osgManipulator.pc.in index 303571b9373..16d00c7c70c 100644 --- a/packaging/pkgconfig/openscenegraph-osgManipulator.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgManipulator.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openscenegraph-osgManipulator Description: Manipulator library for Openscenegraph diff --git a/packaging/pkgconfig/openscenegraph-osgParticle.pc.in b/packaging/pkgconfig/openscenegraph-osgParticle.pc.in index a2dd6aeb8c7..082b8231a1a 100644 --- a/packaging/pkgconfig/openscenegraph-osgParticle.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgParticle.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openscenegraph-osgParticle Description: Particle system library for Openscenegraph diff --git a/packaging/pkgconfig/openscenegraph-osgShadow.pc.in b/packaging/pkgconfig/openscenegraph-osgShadow.pc.in index 746f6737346..99948597b17 100644 --- a/packaging/pkgconfig/openscenegraph-osgShadow.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgShadow.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openscenegraph-osgShadow Description: Shadow techniques library for Openscenegraph diff --git a/packaging/pkgconfig/openscenegraph-osgSim.pc.in b/packaging/pkgconfig/openscenegraph-osgSim.pc.in index ff2e854c207..3a26eccfd86 100644 --- a/packaging/pkgconfig/openscenegraph-osgSim.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgSim.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openscenegraph-osgSim Description: Simulator utility library for Openscenegraph diff --git a/packaging/pkgconfig/openscenegraph-osgTerrain.pc.in b/packaging/pkgconfig/openscenegraph-osgTerrain.pc.in index 5d045a70df8..4297fda1ed0 100644 --- a/packaging/pkgconfig/openscenegraph-osgTerrain.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgTerrain.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openscenegraph-osgTerrain Description: Terrain library for Openscenegraph diff --git a/packaging/pkgconfig/openscenegraph-osgText.pc.in b/packaging/pkgconfig/openscenegraph-osgText.pc.in index 3a0d73363b5..9e1cb478cd7 100644 --- a/packaging/pkgconfig/openscenegraph-osgText.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgText.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openscenegraph-osgText Description: Text rendering library for Openscenegraph diff --git a/packaging/pkgconfig/openscenegraph-osgUtil.pc.in b/packaging/pkgconfig/openscenegraph-osgUtil.pc.in index 651cd3930ae..1e6a33c31c0 100644 --- a/packaging/pkgconfig/openscenegraph-osgUtil.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgUtil.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openscenegraph-osgUtil Description: Utility library for Openscenegraph diff --git a/packaging/pkgconfig/openscenegraph-osgViewer.pc.in b/packaging/pkgconfig/openscenegraph-osgViewer.pc.in index d2bf33fd194..f7739e8319d 100644 --- a/packaging/pkgconfig/openscenegraph-osgViewer.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgViewer.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openscenegraph-osgViewer Description: Windowing system setup, thread scene manager library for Openscenegraph diff --git a/packaging/pkgconfig/openscenegraph-osgVolume.pc.in b/packaging/pkgconfig/openscenegraph-osgVolume.pc.in index 07ef92c4775..562e29baf0f 100644 --- a/packaging/pkgconfig/openscenegraph-osgVolume.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgVolume.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openscenegraph-osgVolume Description: Volume library for Openscenegraph diff --git a/packaging/pkgconfig/openscenegraph-osgWidget.pc.in b/packaging/pkgconfig/openscenegraph-osgWidget.pc.in index 75dc44311a4..e7d78b209a8 100644 --- a/packaging/pkgconfig/openscenegraph-osgWidget.pc.in +++ b/packaging/pkgconfig/openscenegraph-osgWidget.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openscenegraph-osgWidget Description: Windowing toolkit library for Openscenegraph diff --git a/packaging/pkgconfig/openscenegraph.pc.in b/packaging/pkgconfig/openscenegraph.pc.in index c5b57e0dbe1..f0eccb3a50e 100644 --- a/packaging/pkgconfig/openscenegraph.pc.in +++ b/packaging/pkgconfig/openscenegraph.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openscenegraph Description: 3D scenegraph diff --git a/packaging/pkgconfig/openthreads.pc.in b/packaging/pkgconfig/openthreads.pc.in index 0a696403608..f403ddbcb6e 100644 --- a/packaging/pkgconfig/openthreads.pc.in +++ b/packaging/pkgconfig/openthreads.pc.in @@ -3,7 +3,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/@RELATIVE_LIBDIR@ -includedir=${prefix}/include +includedir=${prefix}/@RELATIVE_INCLUDEDIR@ Name: openthreads Description: Object-Oriented (OO) thread interface for C++ programmers