-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #792 from SpaceIm/add-libkml-1.3.0
add libkml/1.3.0
- Loading branch information
Showing
10 changed files
with
471 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.4.3) | ||
project(cmake_wrapper) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
if(WIN32 AND BUILD_SHARED_LIBS) | ||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
endif() | ||
|
||
add_subdirectory("source_subfolder") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
sources: | ||
"1.3.0": | ||
url: "https://github.com/libkml/libkml/archive/1.3.0.zip" | ||
sha256: "ac2a61b4bca105cbed9ad8d0d6d5536dc7c2a11abcecf86431d023e2f3ae96db" | ||
patches: | ||
"1.3.0": | ||
- patch_file: "patches/conanize-cmakelists.patch" | ||
base_path: "source_subfolder" | ||
- patch_file: "patches/fix-for-mingw-and-empty-literal-for-vc.patch" | ||
base_path: "source_subfolder" | ||
- patch_file: "patches/export-extern-symbols-for-msvc.patch" | ||
base_path: "source_subfolder" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import os | ||
|
||
from conans import ConanFile, CMake, tools | ||
|
||
class LibkmlConan(ConanFile): | ||
name = "libkml" | ||
description = "Reference implementation of OGC KML 2.2" | ||
license = "BSD-3-Clause" | ||
topics = ("conan", "libkml", "kml", "ogc", "geospatial") | ||
homepage = "https://github.com/libkml/libkml" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
exports_sources = ["CMakeLists.txt", "patches/**"] | ||
generators = "cmake" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = {"shared": [True, False], "fPIC": [True, False]} | ||
default_options = {"shared": False, "fPIC": True} | ||
|
||
_cmake = None | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
@property | ||
def _build_subfolder(self): | ||
return "build_subfolder" | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def requirements(self): | ||
self.requires.add("boost/1.72.0") | ||
self.requires.add("expat/2.2.9") | ||
self.requires.add("minizip/1.2.11") | ||
self.requires.add("uriparser/0.9.3") | ||
self.requires.add("zlib/1.2.11") | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version]) | ||
os.rename(self.name + "-" + self.version, self._source_subfolder) | ||
|
||
def build(self): | ||
for patch in self.conan_data["patches"][self.version]: | ||
tools.patch(**patch) | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
|
||
def _configure_cmake(self): | ||
if self._cmake: | ||
return self._cmake | ||
self._cmake = CMake(self) | ||
self._cmake.configure(build_folder=self._build_subfolder) | ||
return self._cmake | ||
|
||
def package(self): | ||
self.copy("COPYING", dst="licenses", src=self._source_subfolder) | ||
cmake = self._configure_cmake() | ||
cmake.install() | ||
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) | ||
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
tools.rmdir(os.path.join(self.package_folder, "cmake")) | ||
|
||
def package_info(self): | ||
# Libs ordered following linkage order: | ||
# - kmlconvenience is a dependency of kmlregionator | ||
# - kmlengine is a dependency of kmlregionator and kmlconvenience | ||
# - kmldom is a dependency of kmlregionator, kmlconvenience and kmlengine | ||
# - kmlbase is a dependency of kmlregionator, kmlconvenience, kmlengine, kmldom and kmlxsd | ||
self.cpp_info.libs = ["kmlregionator", "kmlconvenience", "kmlengine", "kmldom", "kmlxsd", "kmlbase"] | ||
if self.settings.os == "Linux": | ||
self.cpp_info.system_libs.append("m") | ||
if self.settings.os == "Windows" and self.options.shared: | ||
self.cpp_info.defines.append("LIBKML_DLL") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -19,7 +19,7 @@ option(WITH_SWIG "Build all swig bindings" OFF) | ||
option(WITH_PYTHON "Build python bindings" OFF) | ||
option(WITH_JAVA "Build java bindings" OFF) | ||
|
||
-set(LIBKML_DATA_DIR ${CMAKE_SOURCE_DIR}/testdata CACHE "Directory containing test data" PATH) | ||
+set(LIBKML_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/testdata CACHE "Directory containing test data" PATH) | ||
|
||
#AM_CXXFLAGS = -Wall -Wextra -Wno-unused-parameter -pedantic -fno-rtti | ||
#AM_TEST_CXXFLAGS = -Wall -Wextra -Wno-unused-parameter -Werror -fno-rtti -DGTEST_HAS_RTTI=0 | ||
@@ -30,7 +30,6 @@ set(TEST_FLAGS "-Wall -Wextra -Wno-unused-parameter -fno-rtti -DGTEST_HAS_RTTI=0 | ||
else() | ||
if(MSVC) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DUNICODE /D_UNICODE") | ||
- set(BUILD_SHARED_LIBS OFF) | ||
endif() | ||
endif() | ||
|
||
@@ -80,7 +79,7 @@ set(INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE "install directory " PATH) | ||
|
||
# Path to additional CMake modules | ||
set(CMAKE_MODULE_PATH | ||
- ${CMAKE_SOURCE_DIR}/cmake | ||
+ ${CMAKE_CURRENT_SOURCE_DIR}/cmake | ||
${CMAKE_MODULE_PATH}) | ||
|
||
include(LibKMLHelper) | ||
@@ -93,49 +92,7 @@ set(MINIZIP_DEPENDS "" CACHE INTERNAL "MINIZIP_DEPENDS") | ||
|
||
set(LIBKML_TARGETS) | ||
|
||
-find_package(EXPAT) | ||
-if(EXPAT_FOUND) | ||
- include_directories(${EXPAT_INCLUDE_DIR}) | ||
-else() | ||
- include(External_expat) | ||
- list(APPEND KMLBASE_DEPENDS EXPAT) | ||
-endif() | ||
- | ||
-find_package(ZLIB 1.2.8) | ||
-if(ZLIB_FOUND) | ||
- include_directories(${ZLIB_INCLUDE_DIR}) | ||
-else() | ||
- include(External_zlib) | ||
- list(APPEND KMLBASE_DEPENDS ZLIB) | ||
- list(APPEND MINIZIP_DEPENDS ZLIB) | ||
-endif() | ||
- | ||
-find_package(MiniZip) | ||
-if(MINIZIP_FOUND) | ||
- include_directories(${MINIZIP_INCLUDE_DIR}) | ||
-else() | ||
- include(External_minizip) | ||
- list(APPEND KMLBASE_DEPENDS MINIZIP) | ||
-endif() | ||
- | ||
-find_package(UriParser) | ||
-if(URIPARSER_FOUND) | ||
- include_directories(${URIPARSER_INCLUDE_DIR}) | ||
-else() | ||
- include(External_uriparser) | ||
- list(APPEND KMLBASE_DEPENDS URIPARSER) | ||
-endif() | ||
- | ||
-find_package(Boost) | ||
-if(Boost_FOUND) | ||
- message(STATUS "Found Boost: ${Boost_VERSION}") | ||
-else() | ||
- include(External_boost) | ||
- list(APPEND KMLBASE_DEPENDS BOOST) | ||
- message(STATUS "Found Boost includes: ${Boost_INCLUDE_DIRS}") | ||
-endif() | ||
- | ||
-include_directories(${Boost_INCLUDE_DIRS}) | ||
+include_directories(${CONAN_INCLUDE_DIRS_BOOST}) | ||
|
||
if(WITH_SWIG) | ||
find_package(SWIG) | ||
@@ -149,16 +106,16 @@ if(WITH_SWIG) | ||
endif() | ||
endif() | ||
|
||
-list(APPEND KMLBASE_LINK_LIBS ${EXPAT_LIBRARY}) | ||
-list(APPEND KMLBASE_LINK_LIBS ${ZLIB_LIBRARY}) | ||
-list(APPEND KMLBASE_LINK_LIBS ${MINIZIP_LIBRARY}) | ||
-list(APPEND KMLBASE_LINK_LIBS ${URIPARSER_LIBRARY}) | ||
+list(APPEND KMLBASE_LINK_LIBS "CONAN_PKG::expat") | ||
+list(APPEND KMLBASE_LINK_LIBS "CONAN_PKG::zlib") | ||
+list(APPEND KMLBASE_LINK_LIBS "CONAN_PKG::minizip") | ||
+list(APPEND KMLBASE_LINK_LIBS "CONAN_PKG::uriparser") | ||
|
||
-include_directories(${CMAKE_SOURCE_DIR}/src) | ||
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) | ||
|
||
add_subdirectory(src) | ||
|
||
-configure_file("${CMAKE_SOURCE_DIR}/cmake/libkml.pc.in" | ||
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/libkml.pc.in" | ||
"${CMAKE_BINARY_DIR}/libkml.pc" @ONLY) | ||
|
||
install(FILES ${CMAKE_BINARY_DIR}/libkml.pc | ||
@@ -168,7 +125,7 @@ if(BUILD_TESTING) | ||
enable_testing() | ||
find_package(GoogleTest REQUIRED) | ||
include_directories(${GTEST_INCLUDE_DIR}) | ||
- include_directories(${CMAKE_SOURCE_DIR}/tests) | ||
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/tests) | ||
add_definitions("-DDATADIR=\"${LIBKML_DATA_DIR}\"") | ||
add_subdirectory(tests) | ||
endif() | ||
@@ -195,7 +152,7 @@ file(RELATIVE_PATH REL_INCLUDE_DIR "${CMAKE_INSTALL_DIR}" | ||
"${INCLUDE_INSTALL_DIR}") | ||
|
||
# ... for the build tree | ||
-set(CONF_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/src") | ||
+set(CONF_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") | ||
configure_file(cmake/LibKMLConfig.cmake.in | ||
"${PROJECT_BINARY_DIR}/LibKMLConfig.cmake" @ONLY) | ||
|
61 changes: 61 additions & 0 deletions
61
recipes/libkml/all/patches/export-extern-symbols-for-msvc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- a/src/kml/base/CMakeLists.txt | ||
+++ b/src/kml/base/CMakeLists.txt | ||
@@ -49,3 +49,7 @@ build_target( | ||
INCS ${INCS} | ||
DEPENDS ${KMLBASE_DEPENDS} | ||
LINKS ${KMLBASE_LINK_LIBS} ) | ||
+ | ||
+if(BUILD_SHARED_LIBS) | ||
+ target_compile_definitions(kmlbase PUBLIC "LIBKML_DLL") | ||
+endif() | ||
--- a/src/kml/base/mimetypes.cc | ||
+++ b/src/kml/base/mimetypes.cc | ||
@@ -25,14 +25,15 @@ | ||
|
||
// This defines some common KML-related mimetype strings. | ||
|
||
+#define KML_BASE_MIMETYPE_EXPORTS | ||
#include "kml/base/mimetypes.h" | ||
|
||
namespace kmlbase { | ||
|
||
-const char* kAtomMimeType = "application/atom+xml"; | ||
-const char* kCsvMimeType = "text/csv"; | ||
-const char* kKmlMimeType = "application/vnd.google-earth.kml+xml"; | ||
-const char* kKmzMimeType = "application/vnd.google-earth.kmz"; | ||
+KML_BASE_MIMETYPE_API const char* kAtomMimeType = "application/atom+xml"; | ||
+KML_BASE_MIMETYPE_API const char* kCsvMimeType = "text/csv"; | ||
+KML_BASE_MIMETYPE_API const char* kKmlMimeType = "application/vnd.google-earth.kml+xml"; | ||
+KML_BASE_MIMETYPE_API const char* kKmzMimeType = "application/vnd.google-earth.kmz"; | ||
|
||
} | ||
|
||
--- a/src/kml/base/mimetypes.h | ||
+++ b/src/kml/base/mimetypes.h | ||
@@ -28,12 +28,22 @@ | ||
#ifndef KML_BASE_MIMETYPES_H__ | ||
#define KML_BASE_MIMETYPES_H__ | ||
|
||
+#if defined(_MSC_VER) && defined(LIBKML_DLL) | ||
+ #ifdef KML_BASE_MIMETYPE_EXPORTS | ||
+ #define KML_BASE_MIMETYPE_API __declspec(dllexport) | ||
+ #else | ||
+ #define KML_BASE_MIMETYPE_API __declspec(dllimport) | ||
+ #endif | ||
+#else | ||
+ #define KML_BASE_MIMETYPE_API | ||
+#endif | ||
+ | ||
namespace kmlbase { | ||
|
||
-extern const char* kAtomMimeType; | ||
-extern const char* kCsvMimeType; | ||
-extern const char* kKmlMimeType; | ||
-extern const char* kKmzMimeType; | ||
+KML_BASE_MIMETYPE_API extern const char* kAtomMimeType; | ||
+KML_BASE_MIMETYPE_API extern const char* kCsvMimeType; | ||
+KML_BASE_MIMETYPE_API extern const char* kKmlMimeType; | ||
+KML_BASE_MIMETYPE_API extern const char* kKmzMimeType; | ||
|
||
} // end namespace kmlbase | ||
|
67 changes: 67 additions & 0 deletions
67
recipes/libkml/all/patches/fix-for-mingw-and-empty-literal-for-vc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- a/src/kml/base/file_win32.cc | ||
+++ b/src/kml/base/file_win32.cc | ||
@@ -34,15 +34,18 @@ | ||
#include "kml/base/file.h" | ||
#include <windows.h> | ||
#include <tchar.h> | ||
+#ifndef __MINGW32__ | ||
#include <xstring> | ||
+#endif | ||
#include <algorithm> | ||
|
||
namespace kmlbase { | ||
|
||
+#ifndef __MINGW32__ | ||
// Internal to the win32 file class. We need a conversion from string to | ||
// LPCWSTR. | ||
static std::wstring Str2Wstr(const string& str) { | ||
- std::wstring wstr(str.length(), L''); | ||
+ std::wstring wstr(str.length(), L' '); // fix for msvc: empty literal | ||
std::copy(str.begin(), str.end(), wstr.begin()); | ||
return wstr; | ||
} | ||
@@ -56,13 +59,18 @@ string Wstr2Str(const std::wstring& wstr) { | ||
static_cast<int>(s), NULL, NULL); | ||
return str; | ||
} | ||
+#endif | ||
|
||
bool File::Exists(const string& full_path) { | ||
if (full_path.empty()) { | ||
return false; | ||
} | ||
+#ifndef __MINGW32__ | ||
std::wstring wstr = Str2Wstr(full_path); | ||
DWORD attrs = ::GetFileAttributes(wstr.c_str()); | ||
+#else | ||
+ DWORD attrs = ::GetFileAttributes(full_path.c_str()); | ||
+#endif | ||
return (attrs != INVALID_FILE_ATTRIBUTES) && | ||
((attrs & FILE_ATTRIBUTE_DIRECTORY) == 0); | ||
} | ||
@@ -71,8 +79,12 @@ bool File::Delete(const string& filepath) { | ||
if (filepath.empty()) { | ||
return false; | ||
} | ||
+#ifndef __MINGW32__ | ||
std::wstring wstr = Str2Wstr(filepath); | ||
return ::DeleteFile(wstr.c_str()) ? true : false; | ||
+#else | ||
+ return ::DeleteFile(filepath.c_str()) ? true : false; | ||
+#endif | ||
} | ||
|
||
static const unsigned int BUFSIZE = 1024; | ||
@@ -97,8 +109,12 @@ bool File::CreateNewTempFile(string* path) { | ||
if (uRetVal == 0) { | ||
return false; | ||
} | ||
+#ifndef __MINGW32__ | ||
string str = Wstr2Str(szTempName); | ||
path->assign(str.c_str(), strlen(str.c_str())); | ||
+#else | ||
+ path->assign(szTempName, strlen(szTempName)); | ||
+#endif | ||
return true; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 2.8.11) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
|
||
from conans import ConanFile, CMake, tools | ||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self.settings): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
Oops, something went wrong.