Skip to content

Commit 83ce8b6

Browse files
maspriSSE4
andauthored
(#7535) add osgearth/3.2
* add osgearth/3.2 * set cpp standard in test_package * fix not linking against gdal/protobuf in windows build * disallow apple-clang if cppstd is not set define flag in case of msvc static lib dont build procedural nodekit on windows * remove default ninja again * delete fPIC on windows * fix osg include del draco option for gcc11 * fix getting compiler version * Update recipes/osgearth/all/conanfile.py * Update recipes/osgearth/all/conanfile.py * incorporate suggestions * Apply suggested changes - change license to "LGPL-3.0" - remove version range from draco dependency - better comment in CMakeLists.txt wrapper * add version to draco requirement Co-authored-by: SSE4 <tomskside@gmail.com>
1 parent 6d509ad commit 83ce8b6

File tree

8 files changed

+591
-0
lines changed

8 files changed

+591
-0
lines changed

recipes/osgearth/all/CMakeLists.txt

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
project(cmake_wrapper)
3+
4+
include(conanbuildinfo.cmake)
5+
conan_basic_setup()
6+
7+
if(WIN32)
8+
add_compile_definitions(NOGDI)
9+
endif()
10+
11+
# osgearth ships with custom cmake find modules. Unfortunately these set
12+
# different variables than the ones generated by conan (most notably *_LIBRARY
13+
# instead of *_LIBRARIES, but also different names). In the following
14+
# these different variables are set using the variables set by conan's
15+
# find modules.
16+
17+
# OSG
18+
find_package(OpenSceneGraph REQUIRED)
19+
20+
set(OSG_PLUGINS "osgPlugins-${OPENSCENEGRAPH_VERSION}" CACHE STRING "" FORCE)
21+
set(OSG_LIBRARY ${OPENSCENEGRAPH_LIBRARIES})
22+
set(OSG_FOUND ${OPENSCENEGRAPH_FOUND})
23+
set(OSG_INCLUDE_DIRS ${OPENSCENEGRAPH_INCLUDE_DIRS})
24+
set(OSG_INCLUDE_DIR "${OPENSCENEGRAPH_INCLUDE_DIRS}")
25+
set(OSG_GEN_INCLUDE_DIR "${OPENSCENEGRAPH_INCLUDE_DIRS}")
26+
27+
# gdal
28+
find_package(GDAL REQUIRED)
29+
set(GDAL_LIBRARY ${GDAL_LIBRARIES})
30+
31+
# curl
32+
find_package(CURL REQUIRED)
33+
set(CURL_LIBRARY ${CURL_LIBRARIES})
34+
35+
# protobuf
36+
find_package(Protobuf)
37+
set(Protobuf_INCLUDE_DIR ${protobuf_INCLUDE_DIR})
38+
set(Protobuf_LIBRARIES ${protobuf_LIBRARIES})
39+
40+
# GEOS
41+
if (OSGEARTH_WITH_GEOS)
42+
find_package(geos)
43+
endif ()
44+
set(GEOS_LIBRARY ${GEOS_LIBS})
45+
set(GEOS_FOUND ${GEOS_LIBRARY})
46+
47+
# SQLite3
48+
if (OSGEARTH_WITH_SQLITE3)
49+
find_package(SQLite3)
50+
endif ()
51+
set(SQLITE3_FOUND ${SQLite3_FOUND})
52+
set(SQLITE3_LIBRARY ${SQLite_LIBRARIES})
53+
set(SQLITE3_INCLUDE_DIR ${SQLite_INCLUDE_DIR})
54+
55+
# WebP
56+
if (OSGEARTH_WITH_WEBP)
57+
find_package(WebP)
58+
endif ()
59+
set(WEBP_FOUND ${WebP_FOUND})
60+
set(WEBP_LIBRARY ${WebP_LIBRARIES})
61+
set(WEBP_INCLUDE_DIR ${WebP_INCLUDE_DIR})
62+
63+
# libzip
64+
if (OSGEARTH_BUILD_ZIP_PLUGIN)
65+
find_package(LIBZIP)
66+
endif ()
67+
set(LIBZIP_FOUND ${libzip_FOUND})
68+
set(LIBZIP_LIBRARY ${libzip_LIBRARIES})
69+
set(LIBZIP_INCLUDE_DIR ${libzip_INCLUDE_DIR})
70+
71+
# leveldb
72+
find_package(leveldb)
73+
set(LEVELDB_FOUND ${leveldb_FOUND})
74+
set(LEVELDB_LIBRARY ${leveldb_LIBRARIES})
75+
set(LEVELDB_INCLUDE_DIR ${leveldb_INCLUDE_DIR})
76+
77+
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

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

0 commit comments

Comments
 (0)