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) 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()