Skip to content

Commit 474603e

Browse files
committed
add osgearth/3.2
1 parent 94f7d4a commit 474603e

File tree

8 files changed

+562
-0
lines changed

8 files changed

+562
-0
lines changed

recipes/osgearth/all/CMakeLists.txt

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
project(cmake_wrapper)
3+
4+
include(conanbuildinfo.cmake)
5+
conan_basic_setup()
6+
7+
# find_package and set the expected variables
8+
9+
# OSG
10+
find_package(OpenSceneGraph REQUIRED)
11+
12+
set(OSG_PLUGINS "osgPlugins-${OPENSCENEGRAPH_VERSION}" CACHE STRING "" FORCE)
13+
set(OSG_LIBRARY ${OPENSCENEGRAPH_LIBRARIES})
14+
set(OSG_FOUND ${OPENSCENEGRAPH_FOUND})
15+
set(OSG_INCLUDE_DIRS ${OPENSCENEGRAPH_INCLUDE_DIRS})
16+
set(OSG_INCLUDE_DIR "${OPENSCENEGRAPH_INCLUDE_DIRS}/osg")
17+
set(OSG_GEN_INCLUDE_DIR "${OPENSCENEGRAPH_INCLUDE_DIRS}/osg")
18+
19+
# GEOS
20+
if (OSGEARTH_WITH_GEOS)
21+
find_package(geos)
22+
endif ()
23+
set(GEOS_FOUND ${GEOS_LIBRARY})
24+
set(GEOS_LIBRARY ${GEOS_LIBS})
25+
26+
# SQLite3
27+
if (OSGEARTH_WITH_SQLITE3)
28+
find_package(SQLite3)
29+
endif ()
30+
set(SQLITE3_FOUND ${SQLite3_FOUND})
31+
set(SQLITE3_LIBRARY ${SQLite_LIBRARIES})
32+
set(SQLITE3_INCLUDE_DIR ${SQLite_INCLUDE_DIR})
33+
34+
# WebP
35+
if (OSGEARTH_WITH_WEBP)
36+
find_package(WebP)
37+
endif ()
38+
set(WEBP_FOUND ${WebP_FOUND})
39+
set(WEBP_LIBRARY ${WebP_LIBRARIES})
40+
set(WEBP_INCLUDE_DIR ${WebP_INCLUDE_DIR}})
41+
42+
# libzip
43+
if (OSGEARTH_BUILD_ZIP_PLUGIN)
44+
find_package(LIBZIP)
45+
endif ()
46+
set(LIBZIP_FOUND ${libzip_FOUND})
47+
set(LIBZIP_LIBRARY ${libzip_LIBRARIES})
48+
set(LIBZIP_INCLUDE_DIR ${libzip_INCLUDE_DIR}})
49+
50+
find_package(leveldb)
51+
set(LEVELDB_FOUND ${leveldb_FOUND})
52+
set(LEVELDB_LIBRARY ${leveldb_LIBRARIES})
53+
set(LEVELDB_INCLUDE_DIR ${leveldb_INCLUDE_DIR}})
54+
55+
add_subdirectory(source_subfolder)

recipes/osgearth/all/conandata.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
sources:
2+
'3.2':
3+
sha256: 7e1dd643b1f3b8d1ba9561b899c18176af988342b86c42d89a70be924cb747f6
4+
url: https://github.com/gwaldron/osgearth/archive/refs/tags/osgearth-3.2.tar.gz
5+
patches:
6+
'3.2':
7+
- patch_file: patches/3.2-osgearth.patch
8+
base_path: source_subfolder

recipes/osgearth/all/conanfile.py

+302
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
from conans import ConanFile, CMake, tools
2+
from conan.tools.files import rename
3+
from conans.tools import os_info
4+
import os
5+
6+
7+
class OsgearthConan(ConanFile):
8+
name = "osgearth"
9+
license = "OSGEARTH SOFTWARE LICENSE"
10+
url = "https://github.com/conan-io/conan-center-index"
11+
description = "osgEarth is a C++ geospatial SDK and terrain engine. \
12+
Just create a simple XML file, point it at your map data, \
13+
and go! osgEarth supports all kinds of data and comes with \
14+
lots of examples to help you get up and running quickly \
15+
and easily."
16+
topics = "openscenegraph", "graphics"
17+
settings = "os", "compiler", "build_type", "arch"
18+
homepage = "http://osgearth.org/"
19+
options = {
20+
"shared": [True, False],
21+
"fPIC": [True, False],
22+
"build_procedural_nodekit": [True, False],
23+
# "build_triton_nodekit": [True, False],
24+
# "build_silverlining_nodekit": [True, False],
25+
"build_leveldb_cache": [True, False],
26+
"build_rocksdb_cache": [True, False],
27+
"build_zip_plugin": [True, False],
28+
"enable_geocoder": [True, False],
29+
"with_geos": [True, False],
30+
"with_sqlite3": [True, False],
31+
"with_draco": [True, False],
32+
# "with_basisu": [True, False],
33+
# "with_glew": [True, False],
34+
"with_protobuf": [True, False],
35+
"with_webp": [True, False],
36+
"install_shaders": [True, False],
37+
"enable_nvtt_cpu_mipmaps": [True, False],
38+
"enable_wininet_for_http": [True, False],
39+
}
40+
41+
default_options = {
42+
"shared": False,
43+
"fPIC": True,
44+
"build_procedural_nodekit": True,
45+
# "build_triton_nodekit": False,
46+
# "build_silverlining_nodekit": False,
47+
"build_leveldb_cache": False,
48+
"build_rocksdb_cache": False,
49+
"build_zip_plugin": True,
50+
"enable_geocoder": False,
51+
"with_geos": True,
52+
"with_sqlite3": True,
53+
"with_draco": False,
54+
# "with_basisu": False,
55+
# "with_glew": True,
56+
"with_protobuf": True,
57+
"with_webp": True,
58+
"install_shaders": True,
59+
"enable_nvtt_cpu_mipmaps": False,
60+
"enable_wininet_for_http": False,
61+
}
62+
63+
short_paths = True
64+
exports_sources = "CMakeLists.txt", "patches/*.patch"
65+
generators = "cmake", "cmake_find_package"
66+
67+
@property
68+
def _source_subfolder(self):
69+
return "source_subfolder"
70+
71+
@property
72+
def _build_subfolder(self):
73+
return "build_subfolder"
74+
75+
def validate(self):
76+
if self.settings.compiler.get_safe("cppstd"):
77+
tools.check_min_cppstd(self, 11)
78+
79+
def configure(self):
80+
if self.options.shared:
81+
del self.options.fPIC
82+
83+
def config_options(self):
84+
if not os_info.is_windows:
85+
self.options.enable_wininet_for_http = False
86+
87+
def requirements(self):
88+
89+
self.requires("opengl/system")
90+
self.requires("gdal/3.3.1")
91+
self.requires("openscenegraph/3.6.5")
92+
self.requires("libcurl/7.79.1")
93+
94+
self.requires("libtiff/4.3.0", override=True)
95+
self.requires("openssl/1.1.1l", override=True)
96+
97+
# if self.options.build_triton_nodekit:
98+
# self.requires("triton_nodekit")
99+
# if self.options.build_silverlining_nodekit:
100+
# self.requires("silverlining_nodekit")
101+
if self.options.build_leveldb_cache:
102+
self.requires("leveldb/1.22")
103+
if self.options.build_rocksdb_cache:
104+
self.requires("rocksdb/6.20.3")
105+
if self.options.build_zip_plugin:
106+
self.requires("libzip/1.7.3")
107+
self.requires("zstd/1.4.9") # override
108+
if self.options.with_geos:
109+
self.requires("geos/3.9.1")
110+
if self.options.with_sqlite3:
111+
self.requires("sqlite3/3.36.0")
112+
if self.options.with_draco:
113+
if self.settings.compiler == "gcc" and self.compiler.version == "11":
114+
# need draco >= 1.4.0 for gcc11
115+
# https://github.com/google/draco/issues/635
116+
self.requires("draco/[>=1.4.0]")
117+
else:
118+
self.requires("draco/[>1.3.6]")
119+
# if self.options.with_basisu:
120+
# self.requires("basisu")
121+
# if self.options.with_glew:
122+
# self.requires("glew/2.2.0")
123+
if self.options.with_protobuf:
124+
self.requires("protobuf/3.17.1")
125+
if self.options.with_webp:
126+
self.requires("libwebp/1.2.0")
127+
128+
def _patch_sources(self):
129+
for patch in self.conan_data.get("patches", {}).get(self.version, []):
130+
tools.patch(**patch)
131+
132+
for package in ("Draco", "GEOS", "LevelDB", "OSG", "RocksDB", "Sqlite3", "WEBP"):
133+
# Prefer conan's find package scripts over osgEarth's
134+
os.unlink(os.path.join(self._source_subfolder, "CMakeModules", "Find{}.cmake".format(package)))
135+
136+
if os_info.is_windows:
137+
tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"),
138+
"PROJECT(OSGEARTH)",
139+
"PROJECT(OSGEARTH)\n add_compile_definitions(NOGDI)")
140+
141+
if os_info.detect_windows_subsystem() == "MSYS2":
142+
tools.replace_in_file(os.path.join(self._source_subfolder,
143+
"osgEarth", "src", "osgEarthDrivers", "fastdxt", "dxt.cpp"),
144+
"tmpBuf = (byte*)memalign(16, width*height*4);",
145+
"tmpBuf = (byte*)__mingw_aligned_malloc(width*height*4,16);")
146+
147+
def source(self):
148+
tools.get(**self.conan_data["sources"][self.version],
149+
destination=self._source_subfolder, strip_root=True)
150+
151+
self._patch_sources()
152+
153+
def _configured_cmake(self):
154+
if hasattr(self, "_cmake"):
155+
return self._cmake
156+
157+
generator_ = None
158+
if os_info.detect_windows_subsystem() == "MSYS2":
159+
generator_ = "MinGW Makefiles"
160+
161+
self._cmake = cmake = CMake(self, generator=generator_)
162+
cmake.definitions["OSGEARTH_BUILD_SHARED_LIBS"] = self.options.shared
163+
cmake.definitions["OSGEARTH_BUILD_TOOLS"] = False
164+
cmake.definitions["OSGEARTH_BUILD_EXAMPLES"] = False
165+
cmake.definitions["OSGEARTH_BUILD_TESTS"] = False
166+
167+
cmake.definitions["OSGEARTH_BUILD_PROCEDURAL_NODEKIT"] = self.options.build_procedural_nodekit
168+
# cmake.definitions["OSGEARTH_BUILD_TRITON_NODEKIT"] = self.options.build_triton_nodekit
169+
# cmake.definitions["OSGEARTH_BUILD_SILVERLINING_NODEKIT"] = self.options.build_silverlining_nodekit
170+
cmake.definitions["OSGEARTH_BUILD_LEVELDB_CACHE"] = self.options.build_leveldb_cache
171+
cmake.definitions["OSGEARTH_BUILD_ROCKSDB_CACHE"] = self.options.build_rocksdb_cache
172+
cmake.definitions["OSGEARTH_BUILD_ZIP_PLUGIN"] = self.options.build_zip_plugin
173+
cmake.definitions["OSGEARTH_ENABLE_GEOCODER"] = self.options.enable_geocoder
174+
175+
cmake.definitions["WITH_EXTERNAL_DUKTAPE"] = False
176+
cmake.definitions["WITH_EXTERNAL_TINYXML"] = False
177+
cmake.definitions["CURL_IS_STATIC"] = not self.options["libcurl"].shared
178+
cmake.definitions["CURL_INCLUDE_DIR"] = self.deps_cpp_info["libcurl"].include_paths[0]
179+
cmake.definitions["OSGEARTH_INSTALL_SHADERS"] = self.options.install_shaders
180+
cmake.definitions["OSGEARTH_ENABLE_NVTT_CPU_MIPMAPS"] = self.options.enable_nvtt_cpu_mipmaps
181+
cmake.definitions["OSGEARTH_ENABLE_WININET_FOR_HTTP"] = self.options.enable_wininet_for_http
182+
183+
# our own defines for using in our top-level CMakeLists.txt
184+
cmake.definitions["OSGEARTH_WITH_GEOS"] = self.options.with_geos
185+
cmake.definitions["OSGEARTH_WITH_SQLITE3"] = self.options.with_sqlite3
186+
cmake.definitions["OSGEARTH_WITH_WEBP"] = self.options.with_webp
187+
188+
cmake.configure()
189+
190+
return cmake
191+
192+
def build(self):
193+
self._configured_cmake().build()
194+
195+
def package(self):
196+
self._configured_cmake().install()
197+
self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder)
198+
199+
if self.options.install_shaders:
200+
rename(self, os.path.join(self.package_folder, "resources"), os.path.join(self.package_folder, "res"))
201+
202+
rename(self, os.path.join(self.package_folder, "lib64"), os.path.join(self.package_folder, "lib"))
203+
204+
def package_info(self):
205+
if self.settings.build_type == "Debug":
206+
postfix = "d"
207+
elif self.settings.build_type == "RelWithDebInfo":
208+
postfix = "rd"
209+
elif self.settings.build_type == "MinSizeRel":
210+
postfix = "s"
211+
else:
212+
postfix = ""
213+
214+
def setup_lib(library, required_components):
215+
lib = self.cpp_info.components[library]
216+
lib.libs = [library + postfix]
217+
218+
for source_lib, components in required_components.items():
219+
lib.requires += [source_lib + "::" + comp for comp in components]
220+
221+
return lib
222+
223+
# osgEarth the main lib
224+
required_libs = {"openscenegraph": ["osg", "osgUtil", "osgSim", "osgViewer", "osgText", "osgGA", "osgShadow",
225+
"OpenThreads", "osgManipulator"],
226+
"libcurl": ["libcurl"],
227+
"gdal": ["gdal"],
228+
"opengl": ["opengl"],
229+
}
230+
231+
osgearth = setup_lib("osgEarth", required_libs)
232+
233+
if self.options.build_zip_plugin:
234+
osgearth.requires += ["libzip::libzip"]
235+
osgearth.requires += ["zstd::zstd"]
236+
if self.options.with_geos:
237+
osgearth.requires += ["geos::geos"]
238+
if self.options.with_sqlite3:
239+
osgearth.requires += ["sqlite3::sqlite3"]
240+
if self.options.with_protobuf:
241+
osgearth.requires += ["protobuf::protobuf"]
242+
if self.options.with_webp:
243+
osgearth.requires += ["libwebp::libwebp"]
244+
245+
# osgEarthProcedural
246+
if self.options.build_procedural_nodekit:
247+
setup_lib("osgEarthProcedural", {}).requires.append("osgEarth")
248+
249+
# plugins
250+
def setup_plugin(plugin):
251+
libname = "osgdb_" + plugin
252+
plugin_library = self.cpp_info.components[libname]
253+
plugin_library.libs = [] if self.options.shared else [libname + postfix]
254+
plugin_library.requires = ["osgEarth"]
255+
if not self.options.shared:
256+
plugin_library.libdirs = [os.path.join("lib", "osgPlugins-{}"
257+
.format(self.deps_cpp_info["openscenegraph"].version))]
258+
return plugin_library
259+
260+
setup_plugin("osgearth_bumpmap")
261+
setup_plugin("osgearth_cache_filesystem")
262+
263+
if self.options.build_leveldb_cache:
264+
setup_plugin("osgearth_cache_leveldb").requires.append("leveldb::leveldb")
265+
266+
if self.options.build_rocksdb_cache:
267+
setup_plugin("osgearth_cache_rocksdb").requires.append("rocksdb::rocksdb")
268+
269+
setup_plugin("osgearth_bumpmap")
270+
setup_plugin("osgearth_cache_filesystem")
271+
setup_plugin("osgearth_colorramp")
272+
setup_plugin("osgearth_detail")
273+
setup_plugin("earth")
274+
setup_plugin("osgearth_engine_rex")
275+
setup_plugin("osgearth_featurefilter_intersect")
276+
setup_plugin("osgearth_featurefilter_join")
277+
setup_plugin("gltf")
278+
setup_plugin("kml")
279+
setup_plugin("osgearth_mapinspector")
280+
setup_plugin("osgearth_monitor")
281+
setup_plugin("osgearth_scriptengine_javascript")
282+
setup_plugin("osgearth_sky_gl")
283+
setup_plugin("osgearth_sky_simple")
284+
setup_plugin("template")
285+
setup_plugin("osgearth_terrainshader")
286+
287+
if self.options.with_webp:
288+
setup_plugin("webp").requires.append("libwebp::libwebp")
289+
290+
setup_plugin("lerc")
291+
setup_plugin("osgearth_vdatum_egm2008")
292+
setup_plugin("osgearth_vdatum_egm84")
293+
setup_plugin("osgearth_vdatum_egm96")
294+
setup_plugin("osgearth_viewpoints")
295+
setup_plugin("fastdxt")
296+
297+
if os_info.is_windows:
298+
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
299+
self.env_info.PATH.append(os.path.join(self.package_folder, "bin/osgPlugins-{}"
300+
.format(self.deps_cpp_info["openscenegraph"].version)))
301+
elif os_info.is_linux:
302+
self.env_info.LD_LIBRARY_PATH.append(os.path.join(self.package_folder, "lib"))

0 commit comments

Comments
 (0)