diff --git a/CMakeLists.txt b/CMakeLists.txt
index 85839c3798..6a0e25f89a 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -125,10 +125,11 @@ find_package(OpenGL REQUIRED)
find_package(OSG REQUIRED)
find_package(CURL REQUIRED)
find_package(GDAL REQUIRED)
+find_package(Sqlite3 REQUIRED)
# optional
find_package(GEOS)
-find_package(Sqlite3)
+
find_package(Draco)
find_package(BASISU)
find_package(GLEW)
@@ -138,6 +139,27 @@ find_package(Blend2D)
find_package(Blosc)
find_package(spdlog)
+# Configure OSGEARTH_HAVE_XXX variables for the BuildConfig
+IF(Protobuf_FOUND AND Protobuf_PROTOC_EXECUTABLE)
+ SET(OSGEARTH_HAVE_MVT ON)
+ENDIF()
+
+if(SQLITE3_FOUND)
+ set(OSGEARTH_HAVE_MBTILES ON)
+endif(SQLITE3_FOUND)
+
+if(Protobuf_FOUND)
+ set(OSGEARTH_HAVE_PROTOBUF ON)
+endif()
+
+IF (GEOS_FOUND)
+ set(OSGEARTH_HAVE_GEOS ON)
+ENDIF(GEOS_FOUND)
+
+if(draco_FOUND)
+ set(OSGEARTH_HAVE_DRACO ON)
+endif(draco_FOUND)
+
if(OSGEARTH_BUILD_CESIUM_NODEKIT)
find_package(CesiumNative)
endif()
@@ -174,20 +196,6 @@ if(spdlog_FOUND)
add_definitions(-DHAVE_SPDLOG)
endif()
-# Sqlite enables the MBTiles format:
-if(SQLITE3_FOUND)
- ADD_DEFINITIONS(-DOSGEARTH_HAVE_MBTILES)
-endif(SQLITE3_FOUND)
-
-# DRACO enables geometry compression sometimes used in glTF:
-if(draco_FOUND)
- ADD_DEFINITIONS(-DOSGEARTH_HAVE_DRACO)
-endif(draco_FOUND)
-
-if(Protobuf_FOUND)
- add_definitions(-DOSGEARTH_HAVE_PROTOBUF)
-endif()
-
# Tracy is a profiler
if(TRACY_FOUND AND OSGEARTH_ENABLE_PROFILING)
ADD_DEFINITIONS(-DOSGEARTH_PROFILING)
@@ -199,9 +207,13 @@ if(GLEW_FOUND AND EXISTS "${OSGEARTH_SOURCE_DIR}/src/third_party/imgui/imgui.cpp
endif()
if(OSGEARTH_ENABLE_GEOCODER)
- add_definitions(-DOSGEARTH_HAVE_GEOCODER)
+ set(OSGEARTH_HAVE_GEOCODER ON)
endif()
+IF(BLEND2D_FOUND)
+ set(OSGEARTH_HAVE_BLEND2D ON)
+ENDIF()
+
if(OSGEARTH_ASSUME_SINGLE_GL_CONTEXT)
add_definitions(-DOSGEARTH_SINGLE_GL_CONTEXT)
endif()
diff --git a/src/applications/osgearth_mvtindex/osgearth_mvtindex.cpp b/src/applications/osgearth_mvtindex/osgearth_mvtindex.cpp
index 21b92158c2..59df989473 100644
--- a/src/applications/osgearth_mvtindex/osgearth_mvtindex.cpp
+++ b/src/applications/osgearth_mvtindex/osgearth_mvtindex.cpp
@@ -20,10 +20,6 @@
* along with this program. If not, see
*/
-// TODO: Reconfigure CMake to not require this.....
-#define OSGEARTH_HAVE_MVT 1
-#define OSGEARTH_HAVE_SQLITE3 1
-
#include
#include
#include
diff --git a/src/osgEarth/BuildConfig.in b/src/osgEarth/BuildConfig.in
new file mode 100644
index 0000000000..500746d9cd
--- /dev/null
+++ b/src/osgEarth/BuildConfig.in
@@ -0,0 +1,13 @@
+// BuildConfig - Generated by CMake
+#ifndef OSGEARTH_BUILDCONFIG_H
+#define OSGEARTH_BUILDCONFIG_H
+
+#cmakedefine OSGEARTH_HAVE_MVT
+#cmakedefine OSGEARTH_HAVE_MBTILES
+#cmakedefine OSGEARTH_HAVE_PROTOBUF
+#cmakedefine OSGEARTH_HAVE_GEOS
+#cmakedefine OSGEARTH_HAVE_DRACO
+#cmakedefine OSGEARTH_HAVE_GEOCODER
+#cmakedefine OSGEARTH_HAVE_BLEND2D
+
+#endif // OSGEARTH_BUILDCONFIG_H
\ No newline at end of file
diff --git a/src/osgEarth/CMakeLists.txt b/src/osgEarth/CMakeLists.txt
index db811ea08b..cc93248a54 100644
--- a/src/osgEarth/CMakeLists.txt
+++ b/src/osgEarth/CMakeLists.txt
@@ -47,6 +47,10 @@ set(OSGEARTH_VERSION_HEADER "${OSGEARTH_BUILDTIME_INCLUDE_DIR}/osgEarth/Version"
message(STATUS "Creating ${OSGEARTH_VERSION_HEADER}")
configure_file(Version.in ${OSGEARTH_VERSION_HEADER})
+set(OSGEARTH_BUILDCONFIG_HEADER "${OSGEARTH_BUILDTIME_INCLUDE_DIR}/osgEarth/BuildConfig")
+message(STATUS "Creating ${OSGEARTH_BUILDCONFIG_HEADER}")
+configure_file(BuildConfig.in ${OSGEARTH_BUILDCONFIG_HEADER})
+
# Name all the library files
SET(LIB_NAME osgEarth)
@@ -920,19 +924,15 @@ ENDIF(BLOSC_FOUND)
# GEOS support?
IF (GEOS_FOUND)
- ADD_DEFINITIONS(-DOSGEARTH_HAVE_GEOS)
INCLUDE_DIRECTORIES(${GEOS_INCLUDE_DIR})
LINK_WITH_VARIABLES(${LIB_NAME} GEOS_LIBRARY)
ENDIF(GEOS_FOUND)
# Protobuf/MVT?
-IF(Protobuf_FOUND AND Protobuf_PROTOC_EXECUTABLE)
-
- ADD_DEFINITIONS(-DOSGEARTH_HAVE_MVT)
+IF(Protobuf_FOUND AND Protobuf_PROTOC_EXECUTABLE)
IF (PROTOBUF_USE_DLLS)
ADD_DEFINITIONS(-DPROTOBUF_USE_DLLS)
ENDIF()
-
LINK_WITH_VARIABLES(${LIB_NAME} Protobuf_LIBRARIES)
ENDIF()
@@ -944,7 +944,6 @@ IF(FILEGDB_FOUND)
ENDIF()
IF(BLEND2D_FOUND)
- add_definitions(-DOSGEARTH_HAVE_BLEND2D)
include_directories(${BLEND2D_INCLUDES})
link_with_variables(${LIB_NAME} BLEND2D_LIBRARY)
ENDIF()
diff --git a/src/osgEarth/Common b/src/osgEarth/Common
index 64ae8138c1..cad69518eb 100644
--- a/src/osgEarth/Common
+++ b/src/osgEarth/Common
@@ -21,6 +21,7 @@
#include
#include
+#include
#include
#include
#include
diff --git a/src/osgEarth/FeatureRasterizer.cpp b/src/osgEarth/FeatureRasterizer.cpp
index ee0936465b..77eca03100 100644
--- a/src/osgEarth/FeatureRasterizer.cpp
+++ b/src/osgEarth/FeatureRasterizer.cpp
@@ -23,6 +23,7 @@
#include
#include
#include
+#include
using namespace osgEarth;
diff --git a/src/osgEarth/GEOS b/src/osgEarth/GEOS
index d3fcbbbb63..49701acb40 100644
--- a/src/osgEarth/GEOS
+++ b/src/osgEarth/GEOS
@@ -20,9 +20,10 @@
#ifndef OSGEARTHSYMBOLOGY_GEOS_H
#define OSGEARTHSYMBOLOGY_GEOS_H 1
+#include
+
#ifdef OSGEARTH_HAVE_GEOS
-#include
#include
#include
diff --git a/src/osgEarth/GEOS.cpp b/src/osgEarth/GEOS.cpp
index a664b33e83..0e98ce0f65 100644
--- a/src/osgEarth/GEOS.cpp
+++ b/src/osgEarth/GEOS.cpp
@@ -16,9 +16,10 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see
*/
+#include
+
#ifdef OSGEARTH_HAVE_GEOS
-#include
#include
using namespace osgEarth;
diff --git a/src/osgEarth/ImGui/ImGuiApp b/src/osgEarth/ImGui/ImGuiApp
index bbdf86f1ca..59a0dc7e3f 100644
--- a/src/osgEarth/ImGui/ImGuiApp
+++ b/src/osgEarth/ImGui/ImGuiApp
@@ -43,6 +43,7 @@
#include "CameraGUI"
#include "RenderingGUI"
#include "AnnotationsGUI"
+#include
#include
diff --git a/src/osgEarth/ImGui/LayersGUI b/src/osgEarth/ImGui/LayersGUI
index 277da092de..96466fbbfd 100644
--- a/src/osgEarth/ImGui/LayersGUI
+++ b/src/osgEarth/ImGui/LayersGUI
@@ -49,6 +49,7 @@
#endif
#endif
+#include
#include
#include
#include
diff --git a/src/osgEarth/MVT b/src/osgEarth/MVT
index 73c8847531..ddd72befdf 100644
--- a/src/osgEarth/MVT
+++ b/src/osgEarth/MVT
@@ -19,11 +19,13 @@
#ifndef OSGEARTH_FEATURES_MVT
#define OSGEARTH_FEATURES_MVT 1
+
#include
-#include
#ifdef OSGEARTH_HAVE_MVT
+#include
+
namespace osgEarth { namespace MVT
{
//! Reads features from an MVT stream for the specified tile.
@@ -48,8 +50,6 @@ namespace osgEarth { namespace MVT
} } // osgEarth::MVT
-#ifdef OSGEARTH_HAVE_SQLITE3
-
namespace osgEarth
{
/**
@@ -116,9 +116,9 @@ namespace osgEarth
OSGEARTH_SPECIALIZE_CONFIG(osgEarth::MVTFeatureSource::Options);
-#endif // OSGEARTH_HAVE_SQLITE3
-
-#endif // OSGEARTH_HAVE_MVT
+#else
+#pragma message("osgEarth was not built with MVT support")
+#endif
#endif // OSGEARTH_FEATURES_MVT
diff --git a/src/osgEarth/MVT.cpp b/src/osgEarth/MVT.cpp
index ac96de74a0..fb6b0c75d5 100644
--- a/src/osgEarth/MVT.cpp
+++ b/src/osgEarth/MVT.cpp
@@ -16,10 +16,11 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see
*/
-#ifdef OSGEARTH_HAVE_MVT
#include
+#ifdef OSGEARTH_HAVE_MVT
+
#include
#include
#include
@@ -30,9 +31,7 @@
#include
#include "vector_tile.pb.h"
-#ifdef OSGEARTH_HAVE_SQLITE3
#include
-#endif
using namespace osgEarth;
using namespace osgEarth::MVT;
diff --git a/src/osgEarth/MapboxGLImageLayer.cpp b/src/osgEarth/MapboxGLImageLayer.cpp
index f5a420b5a1..6d12d389df 100644
--- a/src/osgEarth/MapboxGLImageLayer.cpp
+++ b/src/osgEarth/MapboxGLImageLayer.cpp
@@ -260,7 +260,7 @@ void MapBoxGL::StyleSheet::Source::loadFeatureSource(const std::string& styleShe
}
else if (type() == "vector-mbtiles")
{
-#if defined(OSGEARTH_HAVE_MVT) && defined(OSGEARTH_HAVE_SQLITE3)
+#if defined(OSGEARTH_HAVE_MVT)
URI uri(url(), context);
osg::ref_ptr< MVTFeatureSource > featureSource = new MVTFeatureSource();