From 2afd77a983a0b61c7129073671c32ccd9ec2c25f Mon Sep 17 00:00:00 2001 From: Daniel Emminizer Date: Mon, 19 May 2025 10:13:12 -0400 Subject: [PATCH 1/2] Export Target fixes for transitive properties: Include directory now correctly set; Qt5 and OSG are now correctly searched for if needed; link libraries and include path are now set transitively based on current system's OSG libraries, improving portability of install. --- osgQOpenGLConfig.cmake.in | 24 +++++++++++++++++++++++- src/osgQOpenGL/CMakeLists.txt | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/osgQOpenGLConfig.cmake.in b/osgQOpenGLConfig.cmake.in index a855839..2b275f9 100644 --- a/osgQOpenGLConfig.cmake.in +++ b/osgQOpenGLConfig.cmake.in @@ -1,2 +1,24 @@ +if(TARGET osg-qt::osgQOpenGL) + set(_OSGQOPENGL_ALREADY_DEFINED ON) +endif() + include(CMakeFindDependencyMacro) -include("${CMAKE_CURRENT_LIST_DIR}/osg-qtTargets.cmake") \ No newline at end of file + +if(NOT TARGET Qt5::OpenGL) + find_dependency(Qt5 COMPONENTS Gui OpenGL REQUIRED) +endif() +# Instead of checking OPENSCENEGRAPH_LIBRARIES, check osgViewer and osgUtil specifically +if(NOT DEFINED OSGUTIL_LIBRARIES OR NOT DEFINED OSGVIEWER_LIBRARIES OR NOT DEFINED OPENSCENEGRAPH_INCLUDE_DIRS) + find_dependency(OpenSceneGraph COMPONENTS osgUtil osgViewer REQUIRED) +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/osg-qtTargets.cmake") + +if(NOT _OSGQOPENGL_ALREADY_DEFINED) + # Replace the interface link libraries with those found by OSG, to allow this to be more easily relocatable. + # Without this, absolute paths to OSG are stored in the target, making the output library non-relocatable + # to other machines unless they have OSG in the exact same location. + set_target_properties(osg-qt::osgQOpenGL PROPERTIES INTERFACE_LINK_LIBRARIES "Qt5::Widgets;Qt5::OpenGL") + target_link_libraries(osg-qt::osgQOpenGL INTERFACE ${OPENSCENEGRAPH_LIBRARIES}) + target_include_directories(osg-qt::osgQOpenGL INTERFACE ${OPENSCENEGRAPH_INCLUDE_DIRS}) +endif() diff --git a/src/osgQOpenGL/CMakeLists.txt b/src/osgQOpenGL/CMakeLists.txt index eb7b077..21e6ce0 100644 --- a/src/osgQOpenGL/CMakeLists.txt +++ b/src/osgQOpenGL/CMakeLists.txt @@ -50,6 +50,7 @@ IF ( Qt5Widgets_FOUND ) SETUP_LIBRARY(${LIB_NAME}) + target_include_directories(${LIB_NAME} PUBLIC $) generate_export_header(${LIB_NAME} EXPORT_FILE_NAME "Export") ENDIF() From bfa769f5c928a89888d556a651f56716921e5887 Mon Sep 17 00:00:00 2001 From: Daniel Emminizer Date: Mon, 19 May 2025 11:29:23 -0400 Subject: [PATCH 2/2] CMakeLists: Use GNUInstallDirs to fix Linux duplication issue of lib64 vs lib. --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 640ce99..d83e105 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,6 +92,7 @@ ENDIF() PROJECT(osgQt) +INCLUDE(GNUInstallDirs) FIND_PACKAGE(OpenSceneGraph 3.6.0 REQUIRED osgDB osgGA osgUtil osgText osgViewer osgWidget) SET(OPENSCENEGRAPH_SOVERSION 145)