diff --git a/cmake/FindCesiumNative.cmake b/cmake/FindCesiumNative.cmake index 4bbc07b3d2..727b6d71e9 100644 --- a/cmake/FindCesiumNative.cmake +++ b/cmake/FindCesiumNative.cmake @@ -16,7 +16,7 @@ # set(CESIUM_NATIVE_DIR "" CACHE PATH "Root directory of cesium-native distribution") -set(CESIUM_NATIVE_FOUND FALSE) +unset(CESIUM_NATIVE_FOUND) # Location the cesium-native installation: find_path(CESIUM_NATIVE_INCLUDE_DIR CesiumUtility/Uri.h @@ -26,6 +26,8 @@ find_path(CESIUM_NATIVE_INCLUDE_DIR CesiumUtility/Uri.h PATH_SUFFIXES include ) +set(CESIUM_ANY_LIBRARY_MISSING FALSE) + # Macro to locate each cesium library. macro(find_cesium_library MY_LIBRARY_VAR MY_LIBRARY_NAME) @@ -34,7 +36,7 @@ macro(find_cesium_library MY_LIBRARY_VAR MY_LIBRARY_NAME) unset(${MY_LIBRARY_VAR}_LIBRARY_DEBUG CACHE) unset(${MY_LIBRARY_VAR}_LIBRARY_RELEASE CACHE) - if (NOT CESIUM_LIBRARY_MISSING) + if (NOT CESIUM_ANY_LIBRARY_MISSING) find_library(${MY_LIBRARY_VAR}_LIBRARY_DEBUG NAMES ${MY_LIBRARY_NAME}d @@ -76,8 +78,8 @@ macro(find_cesium_library MY_LIBRARY_VAR MY_LIBRARY_NAME) # finally, add it to the main list for later. list(APPEND CESIUM_NATIVE_IMPORT_LIBRARIES "${MY_IMPORT_LIBRARY_NAME}") else() - message(NOTICE "Cesium Native: Could not find ${MY_LIBRARY_NAME} ... ") - set(CESIUM_LIBRARY_MISSING TRUE) + message(WARNING "Cesium Native: Could NOT find ${MY_LIBRARY_NAME}") + set(CESIUM_ANY_LIBRARY_MISSING TRUE) endif() endif() endmacro() @@ -116,7 +118,7 @@ find_cesium_library(CESIUM_NATIVE_MESHOPTIMIZER meshoptimizer) -if(NOT CESIUM_LIBRARY_MISSING) +if(NOT CESIUM_ANY_LIBRARY_MISSING) set(CESIUM_NATIVE_FOUND TRUE) # Assemble all the component libraries into one single import library: @@ -126,6 +128,8 @@ if(NOT CESIUM_LIBRARY_MISSING) set_property(TARGET OE::CESIUM_NATIVE PROPERTY INTERFACE_LINK_LIBRARIES ${CESIUM_NATIVE_IMPORT_LIBRARIES} ) -else() - message(WARN "Failed to find all Cesium Native libraries. Check CESIUM_NATIVE_DIR.") endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CesiumNative DEFAULT_MSG CESIUM_NATIVE_FOUND) + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c6caceb61c..fdfff998d5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,6 +6,11 @@ list(APPEND OSGEARTH_COMPONENTS osgEarth) # A list of public-facing dependencies for the packaging targets set(OSGEARTH_PUBLIC_DEPENDENCIES) +# For a static build, we set the define OSGEARTH_STATIC_LIBRARY +# for both building the osgEarth.lib AND for building consumer libraries. +if(NOT OSGEARTH_BUILD_SHARED_LIBS) + add_definitions(-DOSGEARTH_LIBRARY_STATIC) +endif() if(OSGEARTH_BUILD_IMGUI_NODEKIT) add_subdirectory(osgEarthImGui) diff --git a/src/applications/CMakeLists.txt b/src/applications/CMakeLists.txt index d90d393537..6553837bf2 100644 --- a/src/applications/CMakeLists.txt +++ b/src/applications/CMakeLists.txt @@ -1,5 +1,9 @@ if(NOT OSGEARTH_BUILD_PLATFORM_IPHONE) + if(NOT OSGEARTH_BUILD_SHARED_LIBS) + add_definitions(-DOSGEARTH_LIBRARY_STATIC) + endif() + # Tools: if(OSGEARTH_BUILD_TOOLS) set(TARGET_DEFAULT_LABEL_PREFIX "Tool") diff --git a/src/osgEarth/CMakeLists.txt b/src/osgEarth/CMakeLists.txt index d4598bee30..346bff4f0f 100644 --- a/src/osgEarth/CMakeLists.txt +++ b/src/osgEarth/CMakeLists.txt @@ -2,8 +2,6 @@ if(OSGEARTH_BUILD_SHARED_LIBS) add_definitions(-DOSGEARTH_LIBRARY) -else() - add_definitions(-DOSGEARTH_LIBRARY_STATIC) endif() # Dependencies ................................................... @@ -16,10 +14,13 @@ find_package(SQLite3 REQUIRED) # optional find_package(geos QUIET) find_package(blend2d QUIET) -find_package(blosc QUIET) find_package(spdlog QUIET) find_package(meshoptimizer QUIET) +if(OSGEARTH_BUILD_SHARED_LIBS) + find_package(blosc QUIET) +endif() + if(OSGEARTH_BUILD_ZIP_PLUGIN) find_package(LibZip QUIET) endif() diff --git a/src/osgEarthImGui/Common b/src/osgEarthImGui/Common index 13de3e6e80..8a17d19f34 100644 --- a/src/osgEarthImGui/Common +++ b/src/osgEarthImGui/Common @@ -12,7 +12,7 @@ #pragma warning( disable : 4996 ) #endif -// note: No Windows declspec's here because we are using CMAKE_EXINDOWS_EXPORT_ALL_SYMBOLS +// note: No Windows declspec's here because we are using CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS #ifndef IMGUI_VERSION #include diff --git a/src/osgEarthProcedural/CMakeLists.txt b/src/osgEarthProcedural/CMakeLists.txt index 0bd05503bd..216b7c7e94 100644 --- a/src/osgEarthProcedural/CMakeLists.txt +++ b/src/osgEarthProcedural/CMakeLists.txt @@ -3,8 +3,6 @@ # if(OSGEARTH_BUILD_SHARED_LIBS) add_definitions(-DOSGEARTHPROCEDURAL_LIBRARY) -else() - add_definitions(-DOSGEARTHPROCEDURAL_LIBRARY_STATIC) endif() SET(LIB_NAME osgEarthProcedural) diff --git a/src/osgEarthProcedural/Export b/src/osgEarthProcedural/Export index 5ceec3cd53..dcd648c351 100644 --- a/src/osgEarthProcedural/Export +++ b/src/osgEarthProcedural/Export @@ -16,13 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see */ - -/* -*-c++-*- - * Derived from osg/Export - */ - -#ifndef OSGEARTH_PROCEDURAL_EXPORT_H -#define OSGEARTH_PROCEDURAL_EXPORT_H 1 +#pragma once #if defined(_MSC_VER) #pragma warning( disable : 4244 ) @@ -36,7 +30,7 @@ #endif #if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__) - # if defined( OSGEARTHPROCEDURAL_LIBRARY_STATIC ) + # if defined( OSGEARTH_LIBRARY_STATIC ) # define OSGEARTHPROCEDURAL_EXPORT # elif defined( OSGEARTHPROCEDURAL_LIBRARY ) # define OSGEARTHPROCEDURAL_EXPORT __declspec(dllexport) @@ -54,5 +48,3 @@ # endif #endif -#endif - diff --git a/src/osgEarthSilverLining/CMakeLists.txt b/src/osgEarthSilverLining/CMakeLists.txt index fea340ce6d..0041a3fde8 100644 --- a/src/osgEarthSilverLining/CMakeLists.txt +++ b/src/osgEarthSilverLining/CMakeLists.txt @@ -6,8 +6,6 @@ set(OSGEARTH_HAVE_SILVERLINING_NODEKIT ON PARENT_SCOPE) # for BuildConfig if(OSGEARTH_BUILD_SHARED_LIBS) add_definitions(-DOSGEARTHSILVERLINING_LIBRARY) -else() - add_definitions(-DOSGEARTHSILVERLINING_LIBRARY_STATIC) endif() option(SILVERLINING_USE_PRE_5_079_API "Whether to use the pre-5.079 API due to an API change" OFF) diff --git a/src/osgEarthSilverLining/Export b/src/osgEarthSilverLining/Export index 9044e76fa2..bcdbf76064 100644 --- a/src/osgEarthSilverLining/Export +++ b/src/osgEarthSilverLining/Export @@ -16,13 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see */ - -/* -*-c++-*- - * Derived from osg/Export - */ - -#ifndef OSGEARTH_SILVERLINING_EXPORT_H -#define OSGEARTH_SILVERLINING_EXPORT_H 1 +#pragma #if defined(_MSC_VER) #pragma warning( disable : 4244 ) @@ -36,7 +30,7 @@ #endif #if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__) - # if defined( OSGEARTHSILVERLINING_LIBRARY_STATIC ) + # if defined( OSGEARTH_LIBRARY_STATIC ) # define OSGEARTHSILVERLINING_EXPORT # elif defined( OSGEARTHSILVERLINING_LIBRARY ) # define OSGEARTHSILVERLINING_EXPORT __declspec(dllexport) @@ -63,7 +57,3 @@ #define NULL ((void *)0) #endif #endif - - -#endif // OSGEARTH_SILVERLINING_EXPORT_H - diff --git a/src/osgEarthSplat/CMakeLists.txt b/src/osgEarthSplat/CMakeLists.txt index 066d266207..d8284c5051 100644 --- a/src/osgEarthSplat/CMakeLists.txt +++ b/src/osgEarthSplat/CMakeLists.txt @@ -7,8 +7,6 @@ set(OSGEARTH_HAVE_LEGACY_SPLAT_NODEKIT ON PARENT_SCOPE) # for BuildConfig if(OSGEARTH_BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DOSGEARTHSPLAT_LIBRARY) -else() - ADD_DEFINITIONS(-DOSGEARTHSPLAT_LIBRARY_STATIC) endif() set(TARGET_GLSL diff --git a/src/osgEarthSplat/Export b/src/osgEarthSplat/Export index 1b976ce24b..f1550e1b07 100644 --- a/src/osgEarthSplat/Export +++ b/src/osgEarthSplat/Export @@ -16,13 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see */ - -/* -*-c++-*- - * Derived from osg/Export - */ - -#ifndef OSGEARTH_SPLAT_EXPORT_H -#define OSGEARTH_SPLAT_EXPORT_H 1 +#pragma once #if defined(_MSC_VER) #pragma warning( disable : 4244 ) @@ -36,7 +30,7 @@ #endif #if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__) - # if defined( OSGEARTHSPLAT_LIBRARY_STATIC ) + # if defined( OSGEARTH_LIBRARY_STATIC ) # define OSGEARTHSPLAT_EXPORT # elif defined( OSGEARTHSPLAT_LIBRARY ) # define OSGEARTHSPLAT_EXPORT __declspec(dllexport) @@ -53,6 +47,3 @@ # define __STL_MEMBER_TEMPLATES # endif #endif - -#endif - diff --git a/src/osgEarthTriton/CMakeLists.txt b/src/osgEarthTriton/CMakeLists.txt index 649b60cd31..d39f3add09 100644 --- a/src/osgEarthTriton/CMakeLists.txt +++ b/src/osgEarthTriton/CMakeLists.txt @@ -6,8 +6,6 @@ set(OSGEARTH_HAVE_TRITON_NODEKIT ON PARENT_SCOPE) # BuildConfig if(OSGEARTH_BUILD_SHARED_LIBS) add_definitions(-DOSGEARTHTRITON_LIBRARY) -else() - add_definitions(-DOSGEARTHTRITON_LIBRARY_STATIC) endif() SET(TARGET_H diff --git a/src/osgEarthTriton/Export b/src/osgEarthTriton/Export index 550810c7e1..cdaf21b201 100644 --- a/src/osgEarthTriton/Export +++ b/src/osgEarthTriton/Export @@ -16,13 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see */ - -/* -*-c++-*- - * Derived from osg/Export - */ - -#ifndef OSGEARTH_TRITON_EXPORT_H -#define OSGEARTH_TRITON_EXPORT_H 1 +#pragma once #if defined(_MSC_VER) #pragma warning( disable : 4244 ) @@ -36,7 +30,7 @@ #endif #if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__) - # if defined( OSGEARTHTRITON_LIBRARY_STATIC ) + # if defined( OSGEARTH_LIBRARY_STATIC ) # define OSGEARTHTRITON_EXPORT # elif defined( OSGEARTHTRITON_LIBRARY ) # define OSGEARTHTRITON_EXPORT __declspec(dllexport) @@ -63,7 +57,3 @@ #define NULL ((void *)0) #endif #endif - - -#endif // OSGEARTH_TRITON_EXPORT_H -