[osmium-tool] 61/97: Simplified libcryptopp check and make use of lib optional.
Sebastiaan Couwenberg
sebastic at moszumanska.debian.org
Tue Jul 21 20:15:35 UTC 2015
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to tag v1.0.0
in repository osmium-tool.
commit 25fb567fd4b5e41c7b5cb5707122409094e3cdc0
Author: Jochen Topf <jochen at topf.org>
Date: Thu Jan 29 15:55:48 2015 +0100
Simplified libcryptopp check and make use of lib optional.
Libcryptopp is sometimes available under the name libcrypto++. On Debian both
names are available, so that simplifies the script. Lets hope the same is true
for other Linux distributions.
Because the functionality provided by cryptopp is not that important we make it
optional. Osmium will still build without it.
---
CMakeLists.txt | 36 ++++++++++++------------------------
cmake/FindCryptopp.cmake | 12 +++---------
src/command_fileinfo.cpp | 18 ++++++++++++------
src/config.hpp.in | 2 --
4 files changed, 27 insertions(+), 41 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7d475ed..a24e6f1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,34 +31,12 @@ set(OSMIUM_VERSION ${OSMIUM_VERSION_MAJOR}.${OSMIUM_VERSION_MINOR}.${OSMIUM_VERS
find_package(Boost REQUIRED COMPONENTS program_options)
include_directories(${Boost_INCLUDE_DIRS})
-if(NOT Boost_FOUND)
- message(WARNING "Boost program_options not found!\n")
- set(MISSING_LIB 1)
-endif()
-
-find_package(Cryptopp REQUIRED)
-include_directories(${CRYPTOPP_INCLUDE_DIRS})
-if(NOT CRYPTOPP_FOUND)
- message(WARNING "Crypto++/Cryptopp library not found!\n")
- set(MISSING_LIB 1)
-endif()
find_package(Osmium REQUIRED COMPONENTS io)
include_directories(${OSMIUM_INCLUDE_DIRS})
-if(NOT OSMIUM_FOUND)
- message(WARNING "Libosmium not found!\n")
- set(MISSING_LIB 1)
-endif()
-
-#----------------------------------------------------------------------
-#
-# Check that all required libraries are available
-#
-#----------------------------------------------------------------------
-if(MISSING_LIB)
- message(FATAL_ERROR "Required library or libraries missing. Aborting...")
-endif(MISSING_LIB)
+find_package(Cryptopp)
+include_directories(${CRYPTOPP_INCLUDE_DIRS})
#----------------------------------------------------------------------
@@ -206,3 +184,13 @@ add_subdirectory(src)
#----------------------------------------------------------------------
+if(NOT CRYPTOPP_FOUND)
+ message(WARNING "=========================================================================
+ Libcryptopp/crypto++ not found! - Some functionality will be missing.
+ Install the library/headers to fix this. You might have to set the
+ CRYPTOPP_INCLUDE_DIR and CRYPTOPP_LIBRARY CMake variables.
+=========================================================================")
+endif()
+
+
+#----------------------------------------------------------------------
diff --git a/cmake/FindCryptopp.cmake b/cmake/FindCryptopp.cmake
index a88124c..54d9a54 100644
--- a/cmake/FindCryptopp.cmake
+++ b/cmake/FindCryptopp.cmake
@@ -8,17 +8,10 @@
# The library is called 'crypto++' on Linux, on OS/X it is called 'cryptopp'.
# Look for the header file.
-find_path(CRYPTOPP_INCLUDE_DIR NAMES crypto++/sha.h)
-
-if(NOT CRYPTOPP_INCLUDE_DIR)
- find_path(CRYPTOPP_INCLUDE_DIR NAMES cryptopp/sha.h)
- if(CRYPTOPP_INCLUDE_DIR)
- set(USE_CRYPTOPP 1)
- endif()
-endif()
+find_path(CRYPTOPP_INCLUDE_DIR NAMES cryptopp/sha.h)
# Look for the library.
-find_library(CRYPTOPP_LIBRARY NAMES crypto++ libcrypto++ cryptopp libcryptopp)
+find_library(CRYPTOPP_LIBRARY NAMES cryptopp libcryptopp crypto++ libcrypto++)
# handle the QUIETLY and REQUIRED arguments and set CRYPTOPP_FOUND to TRUE if
# all listed variables are TRUE
@@ -30,5 +23,6 @@ find_package_handle_standard_args(CRYPTOPP
if(CRYPTOPP_FOUND)
set(CRYPTOPP_INCLUDE_DIRS ${CRYPTOPP_INCLUDE_DIR})
set(CRYPTOPP_LIBRARIES ${CRYPTOPP_LIBRARY})
+ add_definitions(-DOSMIUM_WITH_CRYPTOPP)
endif()
diff --git a/src/command_fileinfo.cpp b/src/command_fileinfo.cpp
index 5edc1df..12e4b2b 100644
--- a/src/command_fileinfo.cpp
+++ b/src/command_fileinfo.cpp
@@ -39,11 +39,10 @@ namespace po = boost::program_options;
#include "command_fileinfo.hpp"
-// this must be after the local includes..
-#ifdef USE_CRYPTOPP
+#ifdef OSMIUM_WITH_CRYPTOPP
# include <cryptopp/sha.h>
#else
-# include <crypto++/sha.h>
+# pragma message("Compiling without libcryptopp - fileinfo SHA will not be available")
#endif
bool CommandFileinfo::setup(const std::vector<std::string>& arguments) {
@@ -105,7 +104,9 @@ struct InfoHandler : public osmium::handler::Handler {
uint64_t relations = 0;
osmium::Timestamp first_timestamp = osmium::end_of_time();
osmium::Timestamp last_timestamp = osmium::start_of_time();
+#ifdef OSMIUM_WITH_CRYPTOPP
CryptoPP::SHA hash;
+#endif
bool ordered = true;
bool multiple_versions = false;
@@ -113,11 +114,16 @@ struct InfoHandler : public osmium::handler::Handler {
osmium::object_id_type last_id = 0;
void changeset(const osmium::Changeset& changeset) {
+#ifdef OSMIUM_WITH_CRYPTOPP
hash.Update(changeset.data(), changeset.byte_size());
+#endif
++changesets;
}
void osm_object(const osmium::OSMObject& object) {
+#ifdef OSMIUM_WITH_CRYPTOPP
+ hash.Update(object.data(), object.byte_size());
+#endif
if (object.timestamp() < first_timestamp) {
first_timestamp = object.timestamp();
}
@@ -141,18 +147,15 @@ struct InfoHandler : public osmium::handler::Handler {
}
void node(const osmium::Node& node) {
- hash.Update(node.data(), node.byte_size());
bounds.extend(node.location());
++nodes;
}
void way(const osmium::Way& way) {
- hash.Update(way.data(), way.byte_size());
++ways;
}
void relation(const osmium::Relation& relation) {
- hash.Update(relation.data(), relation.byte_size());
++relations;
}
@@ -213,12 +216,15 @@ bool CommandFileinfo::run() {
std::cout << " WARNING! This is different from the setting in the header.\n";
}
+#ifdef OSMIUM_WITH_CRYPTOPP
unsigned char digest[CryptoPP::SHA::DIGESTSIZE];
info_handler.hash.Final(digest);
std::cout << " SHA: " << std::hex;
for (int i=0; i < CryptoPP::SHA::DIGESTSIZE; ++i) {
std::cout << static_cast<int>(digest[i]);
}
+#endif
+
std::cout << std::dec << "\n";
std::cout << " Number of changesets: " << info_handler.changesets << "\n";
std::cout << " Number of nodes: " << info_handler.nodes << "\n";
diff --git a/src/config.hpp.in b/src/config.hpp.in
index 2651580..a69e07b 100644
--- a/src/config.hpp.in
+++ b/src/config.hpp.in
@@ -1,5 +1,3 @@
#define OSMIUM_VERSION "@OSMIUM_VERSION@"
-#define USE_CRYPTOPP @USE_CRYPTOPP@
-
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/osmium-tool.git
More information about the Pkg-grass-devel
mailing list