Commit 4de9fb38 authored by Bas Couwenberg's avatar Bas Couwenberg

Merge tag 'upstream/2.2.0'

Upstream version 2.2.0
parents 8e1be955 f11b1c0c
---
Checks: '*,-android-cloexec-*,-cert-err58-cpp,-cert-err60-cpp,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-vararg,-fuchsia-*,-google-runtime-references,-hicpp-no-array-decay,-hicpp-vararg,-modernize-make-unique,-readability-implicit-bool-cast,-readability-implicit-bool-conversion'
#
# For a list of check options, see:
# http://clang.llvm.org/extra/clang-tidy/checks/list.html
#
# Disabled checks:
#
# android-cloexec-*
# O_CLOEXEC isn't available on Windows making this non-portable.
#
# cert-err58-cpp
# Rather unlikely that this is a problem.
#
# cert-err60-cpp
# Reports exceptions from standard library as broken.
#
# cppcoreguidelines-pro-bounds-array-to-pointer-decay
# Limited use and many false positives including for all asserts.
#
# cppcoreguidelines-pro-bounds-pointer-arithmetic
# Difficult to get by without it...
#
# cppcoreguidelines-pro-type-static-cast-downcast
# This is needed and totally okay if we are sure about the types.
#
# cppcoreguidelines-pro-type-vararg
# We need some of these functions at least and for some functions it isn't
# even clear that those are vararg functions.
#
# fuchsia-*
# Much too strict.
#
# google-runtime-references
# This is just a matter of preference.
#
# hicpp-no-array-decay
# Alias for cppcoreguidelines-pro-bounds-array-to-pointer-decay.
#
# hicpp-vararg
# Too strict, sometimes calling vararg functions is necessary.
#
# modernize-make-unique
# This is a C++11 program and C++ doesn't have std::make_unique.
#
# readability-implicit-bool-cast
# Old name for readability-implicit-bool-conversion.
#
# readability-implicit-bool-conversion
# I don't think this makes the code more readable.
#
WarningsAsErrors: '*'
...
......@@ -8,45 +8,80 @@ language: generic
sudo: false
dist: trusty
#-----------------------------------------------------------------------------
matrix:
include:
# 1/ Linux Clang Builds
- os: linux
compiler: linux-clang38-release
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['clang-3.8', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: CXX='clang++-3.8' BUILD_TYPE='Release'
- os: linux
compiler: linux-clang38-dev
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['clang-3.8', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: CXX='clang++-3.8' BUILD_TYPE='Dev'
- os: linux
compiler: linux-clang36-release
compiler: linux-clang39-release
addons:
apt:
sources: ['llvm-toolchain-precise-3.6', 'ubuntu-toolchain-r-test', 'boost-latest']
packages: ['clang-3.6', 'libboost1.55-all-dev', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: COMPILER='clang++-3.6' BUILD_TYPE='Release'
sources: ['ubuntu-toolchain-r-test']
packages: ['clang-3.9', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: CXX='clang++-3.9' BUILD_TYPE='Release'
- os: linux
compiler: linux-clang37-dev
compiler: linux-clang39-dev
addons:
apt:
sources: ['llvm-toolchain-precise-3.6', 'ubuntu-toolchain-r-test', 'boost-latest']
packages: ['clang-3.6', 'libboost1.55-all-dev', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: COMPILER='clang++-3.6' BUILD_TYPE='Dev'
sources: ['ubuntu-toolchain-r-test']
packages: ['clang-3.9', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: CXX='clang++-3.9' BUILD_TYPE='Dev'
- os: linux
compiler: linux-clang38-release
compiler: linux-clang40-release
addons:
apt:
sources: ['llvm-toolchain-precise-3.8', 'ubuntu-toolchain-r-test', 'boost-latest']
packages: ['clang-3.8', 'libboost1.55-all-dev', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: COMPILER='clang++-3.8' BUILD_TYPE='Release'
sources: ['llvm-toolchain-trusty-4.0', 'ubuntu-toolchain-r-test']
packages: ['clang-4.0', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: CXX='clang++-4.0' BUILD_TYPE='Release'
- os: linux
compiler: linux-clang38-dev
compiler: linux-clang40-dev
addons:
apt:
sources: ['llvm-toolchain-trusty-4.0', 'ubuntu-toolchain-r-test']
packages: ['clang-4.0', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: CXX='clang++-4.0' BUILD_TYPE='Dev'
- os: linux
compiler: linux-clang50-release
addons:
apt:
sources: ['llvm-toolchain-precise-3.8', 'ubuntu-toolchain-r-test', 'boost-latest']
packages: ['clang-3.8', 'libboost1.55-all-dev', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: COMPILER='clang++-3.8' BUILD_TYPE='Dev'
sources: ['llvm-toolchain-trusty-5.0', 'ubuntu-toolchain-r-test']
packages: ['clang-5.0', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: CXX='clang++-5.0' BUILD_TYPE='Release'
- os: linux
compiler: linux-clang50-dev
addons:
apt:
sources: ['llvm-toolchain-trusty-5.0', 'ubuntu-toolchain-r-test']
packages: ['clang-5.0', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3', 'clang-tidy-5.0']
env: CXX='clang++-5.0' BUILD_TYPE='Dev' CLANG_TIDY=clang-tidy-5.0
# 2/ Linux GCC Builds
......@@ -54,91 +89,121 @@ matrix:
compiler: linux-gcc48-release
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'boost-latest']
packages: ['g++-4.8', 'libboost1.55-all-dev', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: COMPILER='g++-4.8' COMPILER_FLAGS='-Wno-return-type' BUILD_TYPE='Release'
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.8', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: CXX='g++-4.8' CXXFLAGS='-Wno-return-type' BUILD_TYPE='Release'
- os: linux
compiler: linux-gcc48-dev
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'boost-latest']
packages: ['g++-4.8', 'libboost1.55-all-dev', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: COMPILER='g++-4.8' COMPILER_FLAGS='-Wno-return-type' BUILD_TYPE='Dev'
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.8', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: CXX='g++-4.8' CXXFLAGS='-Wno-return-type' BUILD_TYPE='Dev'
- os: linux
compiler: linux-gcc49-release
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'boost-latest']
packages: ['g++-4.9', 'libboost1.55-all-dev', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: COMPILER='g++-4.9' BUILD_TYPE='Release'
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: CXX='g++-4.9' BUILD_TYPE='Release'
- os: linux
compiler: linux-gcc49-dev
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'boost-latest']
packages: ['g++-4.9', 'libboost1.55-all-dev', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: COMPILER='g++-4.9' BUILD_TYPE='Dev'
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: CXX='g++-4.9' BUILD_TYPE='Dev'
- os: linux
compiler: linux-gcc5-release
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'boost-latest']
packages: ['g++-5', 'libboost1.55-all-dev', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: COMPILER='g++-5' BUILD_TYPE='Release'
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-5', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: CXX='g++-5' BUILD_TYPE='Release'
- os: linux
compiler: linux-gcc5-dev
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'boost-latest']
packages: ['g++-5', 'libboost1.55-all-dev', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: COMPILER='g++-5' BUILD_TYPE='Dev'
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-5', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: CXX='g++-5' BUILD_TYPE='Dev'
- os: linux
compiler: linux-gcc6-release
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-6', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: CXX='g++-6' BUILD_TYPE='Release'
- os: linux
compiler: linux-gcc6-dev
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-6', 'pandoc', 'libgdal1-dev', 'libgeos-dev', 'sqlite3']
env: CXX='g++-6' BUILD_TYPE='Dev'
# 3/ OSX Clang Builds
- os: osx
osx_image: xcode6.4
compiler: xcode64-clang-release
env: COMPILER='clang++' BUILD_TYPE='Release'
env: CXX='clang++' BUILD_TYPE='Release'
- os: osx
osx_image: xcode6.4
compiler: xcode64-clang-dev
env: COMPILER='clang++' BUILD_TYPE='Dev'
env: CXX='clang++' BUILD_TYPE='Dev'
- os: osx
osx_image: xcode7
compiler: xcode7-clang-release
env: COMPILER='clang++' BUILD_TYPE='Release'
env: CXX='clang++' BUILD_TYPE='Release'
- os: osx
osx_image: xcode7
compiler: xcode7-clang-dev
env: COMPILER='clang++' BUILD_TYPE='Dev'
env: CXX='clang++' BUILD_TYPE='Dev'
- os: osx
osx_image: xcode8.3
compiler: xcode8-clang-release
env: CXX='clang++' BUILD_TYPE='Release'
- os: osx
osx_image: xcode8.3
compiler: xcode8-clang-dev
env: CXX='clang++' BUILD_TYPE='Dev'
#-----------------------------------------------------------------------------
install:
- git clone --quiet --depth 1 https://github.com/osmcode/libosmium.git ../libosmium
- git clone --quiet --depth 1 https://github.com/mapbox/protozero.git ../protozero
- |
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
brew install cmake boost || true
brew install cmake || true
fi
- cmake --version
before_script:
- cd ${TRAVIS_BUILD_DIR}
- mkdir build && cd build
- CXX=${COMPILER} CXXFLAGS=${COMPILER_FLAGS} cmake -LA .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
- cmake -LA .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCLANG_TIDY=$(which ${CLANG_TIDY})
script:
- make VERBOSE=1 && ctest --output-on-failure
- if [ -n "${CLANG_TIDY}" ]; then make clang-tidy; fi
#-----------------------------------------------------------------------------
......@@ -2,7 +2,7 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
This project adheres to [Semantic Versioning](https://semver.org/).
## [unreleased] -
......@@ -13,6 +13,35 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
## [2.2.0] - 2018-09-05
### Added
- Add spatialite scripts for creating grids for splitting.
- CMake config adds `clang-tidy` target.
### Changed
- Use `OGC_FID` instead of `ID` as id column in SQL scripts, that's how OGR
expects it.
- Update to newer Protozero and Libosmium.
- Various small code-cleanup changes.
- Output extended version information on `--verbose` and `--version`.
- Derive exception used from `std::runtime_error`.
- Update to newest gdalcpp.
### Fixed
- Initialize stats with 0.
- `osmcoastline_ways`: Delete the copy and move constructor/assignment because
we have a special destructor.
- Add `-pthread` compiler and linker options.
- Fix undefined behavior that resulted in more or less coastlines reported
as "questionable".
- Lower right corner of Antarctica was being cut off in EPSG:3857.
- Very narrow water polygons were output near the anti-meridian in Antarctica.
## [2.1.4] - 2016-09-16
### Changed
......@@ -88,7 +117,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Added man pages
[unreleased]: https://github.com/osmcode/osmium-tool/compare/v2.1.4...HEAD
[unreleased]: https://github.com/osmcode/osmium-tool/compare/v2.2.0...HEAD
[2.2.0]: https://github.com/osmcode/osmium-tool/compare/v2.1.4...v2.2.0
[2.1.4]: https://github.com/osmcode/osmium-tool/compare/v2.1.3...v2.1.4
[2.1.3]: https://github.com/osmcode/osmium-tool/compare/v2.1.2...v2.1.3
[2.1.2]: https://github.com/osmcode/osmium-tool/compare/v2.1.1...v2.1.2
......
......@@ -19,14 +19,12 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
project(osmcoastline)
set(OSMCOASTLINE_VERSION_MAJOR 2)
set(OSMCOASTLINE_VERSION_MINOR 1)
set(OSMCOASTLINE_VERSION_PATCH 4)
set(OSMCOASTLINE_VERSION_MINOR 2)
set(OSMCOASTLINE_VERSION_PATCH 0)
set(OSMCOASTLINE_VERSION
${OSMCOASTLINE_VERSION_MAJOR}.${OSMCOASTLINE_VERSION_MINOR}.${OSMCOASTLINE_VERSION_PATCH})
add_definitions(-DOSMCOASTLINE_VERSION="${OSMCOASTLINE_VERSION}")
set(AUTHOR "Jochen Topf <jochen@topf.org>")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
......@@ -40,7 +38,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include_directories(include)
find_package(Osmium COMPONENTS io gdal)
find_package(Osmium 2.13.1 COMPONENTS io gdal)
include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS})
if(MSVC)
......@@ -132,6 +130,30 @@ set(CMAKE_BUILD_TYPE ${build_type}
FORCE)
#-----------------------------------------------------------------------------
#
# Optional "clang-tidy" target
#
#-----------------------------------------------------------------------------
message(STATUS "Looking for clang-tidy")
find_program(CLANG_TIDY NAMES clang-tidy clang-tidy-6.0 clang-tidy-5.0)
if(CLANG_TIDY)
message(STATUS "Looking for clang-tidy - found ${CLANG_TIDY}")
file(GLOB _all_code src/*.cpp)
add_custom_target(clang-tidy
${CLANG_TIDY}
-p ${CMAKE_BINARY_DIR}
${_all_code}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/src"
)
else()
message(STATUS "Looking for clang-tidy - not found")
message(STATUS " Build target 'clang-tidy' will not be available.")
endif()
#-----------------------------------------------------------------------------
#
# Optional "cppcheck" target that checks C++ code
......@@ -165,10 +187,10 @@ endif(CPPCHECK)
#-----------------------------------------------------------------------------
#
# Optional "iwyu" target to check headers
# http://include-what-you-use.org/
# https://include-what-you-use.org/
#
#-----------------------------------------------------------------------------
find_program(IWYU_TOOL iwyu_tool.py)
find_program(IWYU_TOOL NAMES iwyu_tool iwyu_tool.py)
if(IWYU_TOOL)
message(STATUS "Looking for iwyu_tool.py - found")
......@@ -236,6 +258,30 @@ else()
endif(PANDOC)
#-----------------------------------------------------------------------------
#
# Version
#
#-----------------------------------------------------------------------------
find_package(Git)
if(GIT_FOUND)
execute_process(COMMAND "${GIT_EXECUTABLE}" describe --tags --dirty=-changed
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE VERSION_FROM_GIT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(VERSION_FROM_GIT)
set(VERSION_FROM_GIT " (${VERSION_FROM_GIT})")
endif()
endif()
configure_file(
${PROJECT_SOURCE_DIR}/src/version.cpp.in
${PROJECT_BINARY_DIR}/src/version.cpp
)
#-----------------------------------------------------------------------------
find_library(GEOS_C_LIBRARIES NAMES geos_c)
......
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
......@@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
......@@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<https://www.gnu.org/philosophy/why-not-lgpl.html>.
......@@ -4,40 +4,34 @@
OSMCoastline extracts the coastline data from an OSM planet file and assembles
all the pieces into polygons for use in map renderers etc.
http://wiki.openstreetmap.org/wiki/OSMCoastline
https://wiki.openstreetmap.org/wiki/OSMCoastline
https://github.com/osmcode/osmcoastline
[![Build Status](https://secure.travis-ci.org/osmcode/osmcoastline.svg)](http://travis-ci.org/osmcode/osmcoastline)
[![Build Status](https://secure.travis-ci.org/osmcode/osmcoastline.svg)](https://travis-ci.org/osmcode/osmcoastline)
## Prerequisites
### Libosmium
https://github.com/osmcode/libosmium
http://osmcode.org/libosmium
At least version 2.5.0 is needed.
https://osmcode.org/libosmium
At least version 2.13.1 is needed.
### Protozero
https://github.com/mapbox/protozero
Debian/Ubuntu: protozero
Also included in the libosmium repository.
### Utfcpp
http://utfcpp.sourceforge.net/
Debian/Ubuntu: libutfcpp-dev
Also included in the libosmium repository.
Debian/Ubuntu: libprotozero-dev
At least version 1.6.1 is needed.
### zlib (for PBF support)
http://www.zlib.net/
https://www.zlib.net/
Debian/Ubuntu: zlib1g-dev
### GDAL (for OGR support)
http://gdal.org/
https://gdal.org/
Debian/Ubuntu: libgdal1-dev
(Must be built with Spatialite and GEOS support which is true for
Debian/Ubuntu packages. You need GDAL 1.7.0 or greater, consider using
......@@ -46,17 +40,17 @@ https://github.com/osmcode/osmcoastline
### GEOS
http://trac.osgeo.org/geos/
https://trac.osgeo.org/geos/
Debian/Ubuntu: libgeos-dev
### Sqlite/Spatialite
http://www.gaia-gis.it/gaia-sins/
https://www.gaia-gis.it/fossil/libspatialite/index
Debian/Ubuntu: sqlite3
### Pandoc (optional, to build documentation)
http://johnmacfarlane.net/pandoc/
https://pandoc.org/
Debian/Ubuntu: pandoc
(If pandoc is found by CMake, the manpages will automatically be built.)
......@@ -139,7 +133,7 @@ might contain anything.
`--output-lines` has been given.
By default all output is in WGS84. You can use the option `--srs=3857` to
create output in "Google Mercator". (Other projections are currently not
create output in "Web Mercator". (Other projections are currently not
supported.)
OSMCoastline always creates only this one database. If you need shapefiles
......@@ -152,9 +146,10 @@ larger, but faster to use. You can use the option `--no-index` to suppress
this, for instance if you never use the data directly anyway but want to
transform it into something else.
Coastlines and polygons are never simplified, but contain the full detail.
See `simplify.sql` for a way to simplify polygons. See the `simplify_and_split`
directory for some more ways of doing this.
Coastlines and polygons are never simplified, but contain the full detail. See
the `simplify_and_split_spatialite` or the `simplify_and_split_postgis`
directories for scripts that help with simplifying and splitting geometries
using Spatialite or PostGIS, respectively.
The database tables `options` and `meta` contain the command line options
used to create the database and some metadata. You can use the script
......@@ -218,7 +213,7 @@ case. Default is 1000.
-s, --srs=EPSGCODE
Set spatial reference system/projection. Use 4326 for WGS84 or 3857 for "Google
Set spatial reference system/projection. Use 4326 for WGS84 or 3857 for "Web
Mercator". If you want to use the data for the usual tiled web maps, 3857 is
probably right. For other uses, especially if you want to re-project to some
other projection, 4326 is probably right. Other projections are currently not
......
......@@ -2,8 +2,8 @@
#
# FindOsmium.cmake
#
# Find the Libosmium headers and, optionally, several components needed for
# different Libosmium functions.
# Find the Libosmium headers and, optionally, several components needed
# for different Libosmium functions.
#
#----------------------------------------------------------------------
#
......@@ -18,9 +18,12 @@
#
# Then add the following in your CMakeLists.txt:
#
# find_package(Osmium REQUIRED COMPONENTS <XXX>)
# find_package(Osmium [version] REQUIRED COMPONENTS <XXX>)
# include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS})
#
# The version number is optional. If it is not set, any version of
# libosmium will do.
#
# For the <XXX> substitute a space separated list of one or more of the
# following components:
#
......@@ -51,10 +54,8 @@
#
#----------------------------------------------------------------------
# Look for the header file.
find_path(OSMIUM_INCLUDE_DIR osmium/osm.hpp
PATH_SUFFIXES include
PATHS
# This is the list of directories where we look for osmium includes.
set(_osmium_include_path
../libosmium
~/Library/Frameworks
/Library/Frameworks
......@@ -62,6 +63,22 @@ find_path(OSMIUM_INCLUDE_DIR osmium/osm.hpp
/opt
)
# Look for the header file.
find_path(OSMIUM_INCLUDE_DIR osmium/version.hpp
PATH_SUFFIXES include
PATHS ${_osmium_include_path}
)
# Check libosmium version number
if(Osmium_FIND_VERSION)
file(STRINGS "${OSMIUM_INCLUDE_DIR}/osmium/version.hpp" _libosmium_version_define REGEX "#define LIBOSMIUM_VERSION_STRING")
if("${_libosmium_version_define}" MATCHES "#define LIBOSMIUM_VERSION_STRING \"([0-9.]+)\"")
set(_libosmium_version "${CMAKE_MATCH_1}")
else()
set(_libosmium_version "unknown")
endif()
endif()
set(OSMIUM_INCLUDE_DIRS "${OSMIUM_INCLUDE_DIR}")
#----------------------------------------------------------------------
......@@ -94,18 +111,17 @@ endif()
if(Osmium_USE_PBF)
find_package(ZLIB)
find_package(Threads)
find_package(Protozero 1.6.3)
list(APPEND OSMIUM_EXTRA_FIND_VARS ZLIB_FOUND Threads_FOUND)
if(ZLIB_FOUND AND Threads_FOUND)
list(APPEND OSMIUM_EXTRA_FIND_VARS ZLIB_FOUND Threads_FOUND PROTOZERO_INCLUDE_DIR)
if(ZLIB_FOUND AND Threads_FOUND AND PROTOZERO_FOUND)
list(APPEND OSMIUM_PBF_LIBRARIES
${ZLIB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
if(WIN32)
list(APPEND OSMIUM_PBF_LIBRARIES ws2_32)
endif()
list(APPEND OSMIUM_INCLUDE_DIRS
${ZLIB_INCLUDE_DIR}
${PROTOZERO_INCLUDE_DIR}
)
else()
message(WARNING "Osmium: Can not find some libraries for PBF input/output, please install them or configure the paths.")
......@@ -203,7 +219,7 @@ if(Osmium_USE_SPARSEHASH)
if(SPARSEHASH_INCLUDE_DIR)
# Find size of sparsetable::size_type. This does not work on older
# CMake versions because they can do this check only in C, not in C++.
if (NOT CMAKE_VERSION VERSION_LESS 3.0)
if(NOT CMAKE_VERSION VERSION_LESS 3.0)
include(CheckTypeSize)
set(CMAKE_REQUIRED_INCLUDES ${SPARSEHASH_INCLUDE_DIR})
set(CMAKE_EXTRA_INCLUDE_FILES "google/sparsetable")
......@@ -253,15 +269,31 @@ endif()
# Check that all required libraries are available
#
#----------------------------------------------------------------------
if (OSMIUM_EXTRA_FIND_VARS)
if(OSMIUM_EXTRA_FIND_VARS)
list(REMOVE_DUPLICATES OSMIUM_EXTRA_FIND_VARS)
endif()
# Handle the QUIETLY and REQUIRED arguments and set OSMIUM_FOUND to TRUE if
# all listed variables are TRUE.
# Handle the QUIETLY and REQUIRED arguments and the optional version check
# and set OSMIUM_FOUND to TRUE if all listed variables are TRUE.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Osmium REQUIRED_VARS OSMIUM_INCLUDE_DIR ${OSMIUM_EXTRA_FIND_VARS})
find_package_handle_standard_args(Osmium
REQUIRED_VARS OSMIUM_INCLUDE_DIR ${OSMIUM_EXTRA_FIND_VARS}
VERSION_VAR _libosmium_version)
unset(OSMIUM_EXTRA_FIND_VARS)
#----------------------------------------------------------------------
#
# A function for setting the -pthread option in compilers/linkers
#
#----------------------------------------------------------------------
function(set_pthread_on_target _target)
if(NOT MSVC)
set_target_properties(${_target} PROPERTIES COMPILE_FLAGS "-pthread")
if(NOT APPLE)
set_target_properties(${_target} PROPERTIES LINK_FLAGS "-pthread")
endif()
endif()
endfunction()
#----------------------------------------------------------------------
#
# Add compiler flags
......@@ -285,10 +317,14 @@ if(MSVC)
# old compilers anyway.
add_definitions(-wd4351)
# Disable warning C4503: "decorated name length exceeded, name was truncated"
# there are more than 150 of generated names in libosmium longer than 4096 symbols supported in MSVC
add_definitions(-wd4503)
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS)
endif()
if(APPLE)
if(APPLE AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# following only available from cmake 2.8.12:
# add_compile_options(-stdlib=libc++)
# so using this instead:
......@@ -309,10 +345,10 @@ endif()
set(OSMIUM_DRACONIC_CLANG_OPTIONS "-Wdocumentation -Wunused-exception-parameter -Wmissing-declarations -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-unused-macros -Wno-exit-time-destructors -Wno-global-constructors -Wno-padded -Wno-switch-enum -Wno-missing-prototypes -Wno-weak-vtables -Wno-cast-align -Wno-float-equal")
if(Osmium_DEBUG)
message(STATUS "OSMIUM_XML_LIBRARIES=" ${OSMIUM_XML_LIBRARIES})
message(STATUS "OSMIUM_PBF_LIBRARIES=" ${OSMIUM_PBF_LIBRARIES})
message(STATUS "OSMIUM_IO_LIBRARIES=" ${OSMIUM_IO_LIBRARIES})
message(STATUS "OSMIUM_LIBRARIES=" ${OSMIUM_LIBRARIES})
message(STATUS "OSMIUM_INCLUDE_DIRS=" ${OSMIUM_INCLUDE_DIRS})
message(STATUS "OSMIUM_XML_LIBRARIES=${OSMIUM_XML_LIBRARIES}")
message(STATUS "OSMIUM_PBF_LIBRARIES=${OSMIUM_PBF_LIBRARIES}")
message(STATUS "OSMIUM_IO_LIBRARIES=${OSMIUM_IO_LIBRARIES}")
message(STATUS "OSMIUM_LIBRARIES=${OSMIUM_LIBRARIES}")
message(STATUS "OSMIUM_INCLUDE_DIRS=${OSMIUM_INCLUDE_DIRS}")
endif()
#----------------------------------------------------------------------