[osmium-tool] 21/97: Improved cmake setup.
Sebastiaan Couwenberg
sebastic at moszumanska.debian.org
Tue Jul 21 20:15:30 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 fa3b5f8443dee4faee180b4a674ff2406fcaac55
Author: Jochen Topf <jochen at topf.org>
Date: Tue Jul 22 11:09:39 2014 +0200
Improved cmake setup.
---
CMakeLists.txt | 103 ++++++++++++++++++++++++++++++++++++++++++-----
src/CMakeLists.txt | 17 +-------
src/command_fileinfo.hpp | 2 +-
src/command_help.cpp | 2 +-
src/command_help.hpp | 2 +-
src/config.hpp.in | 5 +++
src/main.cpp | 2 +-
src/osmc.hpp | 4 +-
8 files changed, 106 insertions(+), 31 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 747e422..860e4b4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,45 +1,73 @@
+#----------------------------------------------------------------------
+#
+# Osmium Tool CMakeLists.txt
+#
+#----------------------------------------------------------------------
+
+cmake_minimum_required(VERSION 2.8.5)
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
+
+
+#----------------------------------------------------------------------
+#
+# Projection version
+#
+#----------------------------------------------------------------------
project(osmium)
-set(OSMIUM_VERSION 0.0.1)
+set(OSMIUM_VERSION_MAJOR 0)
+set(OSMIUM_VERSION_MINOR 0)
+set(OSMIUM_VERSION_PATCH 1)
-cmake_minimum_required(VERSION 2.8.5)
+set(OSMIUM_VERSION ${OSMIUM_VERSION_MAJOR}.${OSMIUM_VERSION_MINOR}.${OSMIUM_VERSION_PATCH})
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
#----------------------------------------------------------------------
+#
+# Find external dependencies
+#
+#----------------------------------------------------------------------
find_package(Threads REQUIRED)
+list(APPEND LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIRS})
+list(APPEND LIBRARIES ${ZLIB_LIBRARIES})
find_package(BZip2 REQUIRED)
include_directories(${BZIP2_INCLUDE_DIRS})
+list(APPEND LIBRARIES ${BZIP2_LIBRARIES})
find_package(EXPAT REQUIRED)
include_directories(${EXPAT_INCLUDE_DIRS})
+list(APPEND LIBRARIES ${EXPAT_LIBRARIES})
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIRS})
+list(APPEND LIBRARIES ${PROTOBUF_LITE_LIBRARIES})
find_package(Boost COMPONENTS program_options REQUIRED)
include_directories(${BOOST_INCLUDE_DIRS})
+list(APPEND LIBRARIES ${Boost_LIBRARIES})
find_package(Cryptopp REQUIRED)
include_directories(${CRYPTOPP_INCLUDE_DIRS})
+list(APPEND LIBRARIES ${CRYPTOPP_LIBRARIES})
find_package(OSMPBF REQUIRED)
include_directories(${OSMPBF_INCLUDE_DIRS})
+list(APPEND LIBRARIES ${OSMPBF_LIBRARIES})
find_package(Osmium REQUIRED)
include_directories(${OSMIUM_INCLUDE_DIRS})
-#----------------------------------------------------------------------
-add_subdirectory(src)
-
-install(FILES README.md DESTINATION share/doc/osmium)
#----------------------------------------------------------------------
+#
+# Optional "cppcheck" target that checks C++ code
+#
+#----------------------------------------------------------------------
message(STATUS "Looking for cppcheck")
find_program(CPPCHECK cppcheck)
@@ -54,10 +82,14 @@ if(CPPCHECK)
else()
message(STATUS "Looking for cppcheck - not found")
message(STATUS " Make target cppcheck not available")
-endif()
+endif(CPPCHECK)
#----------------------------------------------------------------------
+#
+# Optional "man" target to generate man pages
+#
+#----------------------------------------------------------------------
message(STATUS "Looking for pandoc")
find_program(PANDOC pandoc)
@@ -89,6 +121,59 @@ if(PANDOC)
else()
message(STATUS "Looking for pandoc - not found")
message(STATUS " Manual pages will not be built")
-endif()
+endif(PANDOC)
+
+
+#----------------------------------------------------------------------
+#
+# Create src/config.hpp
+#
+#----------------------------------------------------------------------
+configure_file(
+ ${PROJECT_SOURCE_DIR}/src/config.hpp.in
+ ${PROJECT_BINARY_DIR}/src/config.hpp
+)
+
+include_directories(${PROJECT_BINARY_DIR}/src)
+
+
+#----------------------------------------------------------------------
+#
+# C++ compilation options
+#
+#----------------------------------------------------------------------
+add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64)
+
+add_compile_options(-std=c++11)
+
+add_compile_options(
+ -Wall
+ -Wextra
+ -pedantic
+ -Wredundant-decls
+ -Wdisabled-optimization
+ -Wctor-dtor-privacy
+ -Wnon-virtual-dtor
+ -Woverloaded-virtual
+ -Wsign-promo
+ -Wold-style-cast
+)
+
+# always compile with optimization, even in debug mode
+set(CMAKE_CXX_FLAGS_DEBUG -O3)
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g")
+
+if(APPLE)
+ add_compile_options(-stdlib=libc++)
+ set(LDFLAGS ${LDFLAGS} -stdlib=libc++)
+endif(APPLE)
+
+
+#----------------------------------------------------------------------
+
+add_subdirectory(src)
+
+install(FILES README.md DESTINATION share/doc/osmium)
+
#----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 96b5431..742795f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,24 +1,9 @@
-add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64)
-
-if(USE_CRYPTOPP)
- add_definitions(-DUSE_CRYPTOPP=${USE_CRYPTOPP})
-endif()
-
-add_compile_options(-O3)
-add_compile_options(-std=c++11)
-add_compile_options(-Wall -Wextra -pedantic -Wredundant-decls -Wdisabled-optimization -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wsign-promo -Wold-style-cast)
-
-if(APPLE)
- add_compile_options(-stdlib=libc++)
- set(LDFLAGS ${LDFLAGS} -stdlib=libc++)
-endif(APPLE)
-
file(GLOB OSMIUM_SOURCE_FILES *.cpp)
add_executable(osmium ${OSMIUM_SOURCE_FILES})
-target_link_libraries(osmium ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${EXPAT_LIBRARIES} ${PROTOBUF_LITE_LIBRARIES} ${Boost_LIBRARIES} ${CRYPTOPP_LIBRARIES} ${OSMPBF_LIBRARY})
+target_link_libraries(osmium ${LIBRARIES})
install(TARGETS osmium DESTINATION bin)
diff --git a/src/command_fileinfo.hpp b/src/command_fileinfo.hpp
index 2062cd4..2bd376b 100644
--- a/src/command_fileinfo.hpp
+++ b/src/command_fileinfo.hpp
@@ -6,7 +6,7 @@
Osmium -- OpenStreetMap data manipulation command line tool
http://osmcode.org/osmium
-Copyright (C) 2013 Jochen Topf <jochen at topf.org>
+Copyright (C) 2013, 2014 Jochen Topf <jochen at topf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/command_help.cpp b/src/command_help.cpp
index c6c578f..61035dd 100644
--- a/src/command_help.cpp
+++ b/src/command_help.cpp
@@ -3,7 +3,7 @@
Osmium -- OpenStreetMap data manipulation command line tool
http://osmcode.org/osmium
-Copyright (C) 2013 Jochen Topf <jochen at topf.org>
+Copyright (C) 2013, 2014 Jochen Topf <jochen at topf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/command_help.hpp b/src/command_help.hpp
index 7cccd02..f5830e3 100644
--- a/src/command_help.hpp
+++ b/src/command_help.hpp
@@ -6,7 +6,7 @@
Osmium -- OpenStreetMap data manipulation command line tool
http://osmcode.org/osmium
-Copyright (C) 2013 Jochen Topf <jochen at topf.org>
+Copyright (C) 2013, 2014 Jochen Topf <jochen at topf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/config.hpp.in b/src/config.hpp.in
new file mode 100644
index 0000000..2651580
--- /dev/null
+++ b/src/config.hpp.in
@@ -0,0 +1,5 @@
+
+#define OSMIUM_VERSION "@OSMIUM_VERSION@"
+
+#define USE_CRYPTOPP @USE_CRYPTOPP@
+
diff --git a/src/main.cpp b/src/main.cpp
index 11e1efa..f6a1580 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3,7 +3,7 @@
Osmium -- OpenStreetMap data manipulation command line tool
http://osmcode.org/osmium
-Copyright (C) 2013 Jochen Topf <jochen at topf.org>
+Copyright (C) 2013, 2014 Jochen Topf <jochen at topf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/osmc.hpp b/src/osmc.hpp
index 83378ac..a76cca9 100644
--- a/src/osmc.hpp
+++ b/src/osmc.hpp
@@ -6,7 +6,7 @@
Osmium -- OpenStreetMap data manipulation command line tool
http://osmcode.org/osmium
-Copyright (C) 2013 Jochen Topf <jochen at topf.org>
+Copyright (C) 2013, 2014 Jochen Topf <jochen at topf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <osmium/util/verbose_output.hpp>
-#define OSMIUM_VERSION "0.0.1"
+#include "config.hpp"
/**
* Virtual base class for commands that can be called from the command line.
--
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