diff --git a/share/ExternalProject/CMakeLists.txt b/share/ExternalProject/CMakeLists.txt new file mode 100644 index 0000000000..8659e83281 --- /dev/null +++ b/share/ExternalProject/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.20) + +project(ExternalExample) + +find_package(osgEarth CONFIG REQUIRED) + +add_executable(ExternalExample main.cpp) + +target_link_libraries(ExternalExample PRIVATE osgEarth) diff --git a/share/ExternalProject/README.md b/share/ExternalProject/README.md new file mode 100644 index 0000000000..36e01e26ae --- /dev/null +++ b/share/ExternalProject/README.md @@ -0,0 +1,10 @@ +# External Project Example +This is a simple example to test the `osgEarthConfig.cmake` packaging configuration file for CMake. + +These line in your `CMakeLists.txt` will tell CMake to look for `osgEarthConfig.cmake` and use it to resolve osgEarth and its public-facing dependencies: +``` +find_package(osgEarth CONFIG REQUIRED) +... +target_link_libraries(my_project PRIVATE osgEarth) +``` +You may need to update your `CMAKE_PREFIX_PATH` to include the location of `osgEarthConfig.cmake`. \ No newline at end of file diff --git a/share/ExternalProject/main.cpp b/share/ExternalProject/main.cpp new file mode 100644 index 0000000000..40732fabdb --- /dev/null +++ b/share/ExternalProject/main.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#include + +int main(int argc, char** argv) +{ + osg::ArgumentParser args(&argc, argv); + osgViewer::Viewer viewer(args); + + osgEarth::initialize(); + osgEarth::setNotifyLevel(osg::INFO); + + auto layer = new osgEarth::TMSImageLayer(); + layer->setURL("https://readymap.org/readymap/tiles/1.0.0/7/"); + + auto mapNode = new osgEarth::MapNode(); + mapNode->getMap()->addLayer(layer); + + viewer.setCameraManipulator(new osgEarth::Util::EarthManipulator()); + + viewer.setSceneData(mapNode); + return viewer.run(); +} \ No newline at end of file diff --git a/src/osgEarth/CMakeLists.txt b/src/osgEarth/CMakeLists.txt index 0e838482d5..5c7730a894 100644 --- a/src/osgEarth/CMakeLists.txt +++ b/src/osgEarth/CMakeLists.txt @@ -41,8 +41,9 @@ IF(WIN32) LIST(APPEND TARGET_EXTERNAL_LIBRARIES psapi) ENDIF(WIN32) - -LIST(APPEND TARGET_EXTERNAL_LIBRARIES meshoptimizer::meshoptimizer) +IF(meshoptimizer_FOUND) + LIST(APPEND TARGET_EXTERNAL_LIBRARIES meshoptimizer::meshoptimizer) +ENDIF() # Generate the Version header. diff --git a/src/osgEarth/weejobs.h b/src/osgEarth/weejobs.h index 26427ce053..8fde5fe356 100644 --- a/src/osgEarth/weejobs.h +++ b/src/osgEarth/weejobs.h @@ -16,6 +16,7 @@ #include #include #include +#include // OPTIONAL: Define WEEJOBS_EXPORT if you want to use this library from multiple modules (DLLs) #ifndef WEEJOBS_EXPORT