Skip to content

Export Target fixes for better transitive properties #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
24 changes: 23 additions & 1 deletion osgQOpenGLConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -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")

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()
1 change: 1 addition & 0 deletions src/osgQOpenGL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ IF ( Qt5Widgets_FOUND )

SETUP_LIBRARY(${LIB_NAME})

target_include_directories(${LIB_NAME} PUBLIC $<INSTALL_INTERFACE:include>)
generate_export_header(${LIB_NAME} EXPORT_FILE_NAME "Export")

ENDIF()