diff --git a/cmake/oe_osx.cmake b/cmake/oe_osx.cmake index 71eb49bfd4..3d0bf38f8a 100644 --- a/cmake/oe_osx.cmake +++ b/cmake/oe_osx.cmake @@ -2,7 +2,7 @@ # Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4 # and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support. -IF(APPLE AND NOT ANDROID) +IF(APPLE) # These are just defaults/recommendations, but how we want to build # out of the box. But the user needs to be able to change these options. @@ -34,5 +34,8 @@ IF(APPLE AND NOT ANDROID) OPTION(OSGEARTH_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF) OPTION(OSGEARTH_BUILD_FRAMEWORKS "Compile frameworks instead of dylibs" OFF) SET(OSGEARTH_BUILD_FRAMEWORKS_INSTALL_NAME_DIR "@executable_path/../Frameworks" CACHE STRING "Install name dir for compiled frameworks") + + # MacOS required this in order to find the protobuf_generate_cpp function: + set(OSGEARTH_PROTOBUF_FORCE_CONFIG_MODE ON) -ENDIF(APPLE AND NOT ANDROID) \ No newline at end of file +ENDIF() \ No newline at end of file diff --git a/src/osgEarth/CMakeLists.txt b/src/osgEarth/CMakeLists.txt index f5dd8a8253..aa8042be9e 100644 --- a/src/osgEarth/CMakeLists.txt +++ b/src/osgEarth/CMakeLists.txt @@ -15,7 +15,6 @@ find_package(SQLite3 REQUIRED) # optional find_package(geos QUIET) -find_package(Protobuf QUIET) find_package(blend2d QUIET) find_package(blosc QUIET) find_package(spdlog QUIET) @@ -25,6 +24,14 @@ if(OSGEARTH_BUILD_ZIP_PLUGIN) find_package(LibZip QUIET) endif() +if(OSGEARTH_PROTOBUF_FORCE_CONFIG_MODE) + # https://stackoverflow.com/a/56896032/4218920 + set(protobuf_MODULE_COMPATIBLE ON CACHE BOOL "") + find_package(Protobuf CONFIG QUIET) +else() + find_package(Protobuf QUIET) +endif() + # Other options ................................................... @@ -819,9 +826,9 @@ endif() # generate the google protocol buffers headers and sources -if(Protobuf_FOUND AND Protobuf_PROTOC_EXECUTABLE) - PROTOBUF_GENERATE_CPP(PROTO_VECTOR_TILE_CPP PROTO_VECTOR_TILE_H vector_tile.proto) - PROTOBUF_GENERATE_CPP(PROTO_GLYPHS_CPP PROTO_GLYPHS_H glyphs.proto) +if(Protobuf_FOUND AND Protobuf_PROTOC_EXECUTABLE) + protobuf_generate_cpp(PROTO_VECTOR_TILE_CPP PROTO_VECTOR_TILE_H vector_tile.proto) + protobuf_generate_cpp(PROTO_GLYPHS_CPP PROTO_GLYPHS_H glyphs.proto) list(APPEND TARGET_H ${PROTO_VECTOR_TILE_H} ${PROTO_GLYPHS_H}) list(APPEND TARGET_SRC ${PROTO_VECTOR_TILE_CPP} ${PROTO_GLYPHS_CPP})