From 1966c9529eeff212e596a31b09fd2f70d10acf68 Mon Sep 17 00:00:00 2001 From: Glenn Waldron Date: Fri, 30 Aug 2024 10:16:33 -0400 Subject: [PATCH] Fix cmake issue with osgEarthImGui where find_dependency was not called for GLEW or OpenGL --- cmake/osgEarth-config.cmake.in | 19 +++++++++++++++---- src/CMakeLists.txt | 6 ++++++ src/osgEarthImGui/CMakeLists.txt | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/cmake/osgEarth-config.cmake.in b/cmake/osgEarth-config.cmake.in index 155cc8cd34..77dd7d29ff 100644 --- a/cmake/osgEarth-config.cmake.in +++ b/cmake/osgEarth-config.cmake.in @@ -1,8 +1,16 @@ # -# CMake Config TEMPLATE -# Inputs: +# osgEarth CMake Config +# +# Developer inputs: # OSGEARTH_VERSION : osgEarth version string # OSGEARTH_COMPONENTS : list of libraries for which to create namespaced imports +# OSGEARTH_PUBLIC_DEPENDENCIES : list of libraries for which to generate find_dependency +# +# User outputs: +# osgEarth::osgEarth import library (and one for each additonal nodekit) +# osgEarth_FOUND : true if successful +# osgEarth_INCLUDE_DIR : include root +# osgEarth_SHARE_DIR : location of share folder containing cmake files and external resources # cmake_minimum_required(VERSION 3.10.0) @@ -24,10 +32,13 @@ set_and_check(osgEarth_BUILD_DIR "${PACKAGE_PREFIX_DIR}") # always depend on the public-facing OSG libraries include(CMakeFindDependencyMacro) find_dependency(OpenSceneGraph REQUIRED COMPONENTS osg osgDB osgGA osgUtil osgViewer OpenThreads) - -# must foreably include the OSG include root include_directories(${OPENSCENEGRAPH_INCLUDE_DIR}) +# additional public dependencies +foreach(MY_DEPENDENCY @OSGEARTH_PUBLIC_DEPENDENCIES@) + find_dependency(${MY_DEPENDENCY} REQUIRED) +endforeach() + # include the target for each library in OSGEARTH_COMPONENTS: foreach(MY_COMPONENT @OSGEARTH_COMPONENTS@) if(NOT TARGET osgEarth::${MY_COMPONENT}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bd5554111c..c6caceb61c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,9 +3,15 @@ set(OSGEARTH_COMPONENTS) list(APPEND OSGEARTH_COMPONENTS osgEarth) +# A list of public-facing dependencies for the packaging targets +set(OSGEARTH_PUBLIC_DEPENDENCIES) + + if(OSGEARTH_BUILD_IMGUI_NODEKIT) add_subdirectory(osgEarthImGui) list(APPEND OSGEARTH_COMPONENTS osgEarthImGui) + list(APPEND OSGEARTH_PUBLIC_DEPENDENCIES GLEW) + list(APPEND OSGEARTH_PUBLIC_DEPENDENCIES OpenGL) endif() if(OSGEARTH_BUILD_PROCEDURAL_NODEKIT) diff --git a/src/osgEarthImGui/CMakeLists.txt b/src/osgEarthImGui/CMakeLists.txt index 3aa6559876..5296cf6a28 100644 --- a/src/osgEarthImGui/CMakeLists.txt +++ b/src/osgEarthImGui/CMakeLists.txt @@ -58,5 +58,5 @@ add_osgearth_library( TARGET ${LIB_NAME} SOURCES ${LIB_SOURCES} ${IMGUI_SOURCES} PUBLIC_HEADERS ${LIB_HEADERS} ${IMGUI_HEADERS} ${STOCK_PANELS} - LIBRARIES PRIVATE GLEW::GLEW OpenGL::GL + LIBRARIES PUBLIC GLEW::GLEW OpenGL::GL FOLDER "NodeKits")