2016-06-02 10:07:29 -04:00
|
|
|
cmake_minimum_required(VERSION 2.8.11)
|
|
|
|
# we depend on 2.8.11 introducing target_include_directories
|
2014-07-14 10:21:16 -04:00
|
|
|
|
2015-02-25 12:25:03 -05:00
|
|
|
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR AND NOT MSVC_IDE)
|
2014-07-14 10:21:16 -04:00
|
|
|
message(FATAL_ERROR "In-source builds are not allowed.
|
|
|
|
Please create a directory and run cmake from there, passing the path to this source directory as the last argument.
|
|
|
|
This process created the file `CMakeCache.txt' and the directory `CMakeFiles'. Please delete them.")
|
|
|
|
endif()
|
|
|
|
|
2016-11-27 09:45:55 -05:00
|
|
|
# detect if this is included as subproject and if so expose
|
|
|
|
# some variables to its parent scope
|
|
|
|
get_directory_property(BUILD_AS_SUBPROJECT PARENT_DIRECTORY)
|
|
|
|
if(BUILD_AS_SUBPROJECT)
|
|
|
|
message(STATUS "Building libosrm as subproject.")
|
|
|
|
endif()
|
|
|
|
|
2016-10-28 15:18:13 -04:00
|
|
|
option(ENABLE_MASON "Use mason for dependencies" OFF)
|
|
|
|
option(ENABLE_CCACHE "Speed up incremental rebuilds via ccache" ON)
|
|
|
|
option(BUILD_TOOLS "Build OSRM tools" OFF)
|
2017-01-09 15:58:02 -05:00
|
|
|
option(BUILD_PACKAGE "Build OSRM package" OFF)
|
2016-10-28 15:18:13 -04:00
|
|
|
option(ENABLE_ASSERTIONS "Use assertions in release mode" OFF)
|
|
|
|
option(ENABLE_COVERAGE "Build with coverage instrumentalisation" OFF)
|
|
|
|
option(ENABLE_SANITIZER "Use memory sanitizer for Debug build" OFF)
|
2017-01-05 06:04:46 -05:00
|
|
|
option(ENABLE_LTO "Use LTO if available" OFF)
|
2016-10-28 15:18:13 -04:00
|
|
|
option(ENABLE_FUZZING "Fuzz testing using LLVM's libFuzzer" OFF)
|
|
|
|
option(ENABLE_GOLD_LINKER "Use GNU gold linker if available" ON)
|
|
|
|
|
2017-02-10 10:53:34 -05:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
|
|
|
2016-10-20 20:03:55 -04:00
|
|
|
if(ENABLE_MASON)
|
2016-10-20 20:03:55 -04:00
|
|
|
# versions in use
|
2017-01-23 11:59:29 -05:00
|
|
|
set(MASON_BOOST_VERSION "1.63.0")
|
2017-02-16 05:25:59 -05:00
|
|
|
set(MASON_STXXL_VERSION "1.4.1-1")
|
2016-11-08 18:29:49 -05:00
|
|
|
set(MASON_EXPAT_VERSION "2.2.0")
|
2016-10-20 20:03:55 -04:00
|
|
|
set(MASON_LUA_VERSION "5.2.4")
|
|
|
|
set(MASON_BZIP2_VERSION "1.0.6")
|
2017-02-20 06:42:09 -05:00
|
|
|
set(MASON_TBB_VERSION "2017_20161128")
|
2017-02-27 06:03:57 -05:00
|
|
|
set(MASON_LIBSHP_VERSION "1.3.0")
|
2016-10-20 20:03:55 -04:00
|
|
|
|
2016-10-20 20:03:55 -04:00
|
|
|
message(STATUS "Enabling mason")
|
2016-11-08 18:29:49 -05:00
|
|
|
|
|
|
|
find_program(CURL_FOUND curl)
|
|
|
|
if(NOT CURL_FOUND)
|
|
|
|
message(FATAL_ERROR "curl command required with -DENABLE_MASON")
|
|
|
|
endif()
|
|
|
|
|
2017-02-10 10:53:34 -05:00
|
|
|
include(mason)
|
2016-10-20 20:03:55 -04:00
|
|
|
endif()
|
|
|
|
|
2016-11-27 09:45:55 -05:00
|
|
|
# be compatible with version handling before cmake 3.x
|
|
|
|
if (POLICY CMP0048)
|
|
|
|
cmake_policy(SET CMP0048 OLD)
|
|
|
|
endif()
|
2015-03-30 07:26:06 -04:00
|
|
|
project(OSRM C CXX)
|
2016-04-02 19:08:08 -04:00
|
|
|
set(OSRM_VERSION_MAJOR 5)
|
2017-03-09 09:23:08 -05:00
|
|
|
set(OSRM_VERSION_MINOR 7)
|
2016-06-28 04:35:45 -04:00
|
|
|
set(OSRM_VERSION_PATCH 0)
|
2016-11-27 09:45:55 -05:00
|
|
|
set(OSRM_VERSION "${OSRM_VERSION_MAJOR}.${OSRM_VERSION_MINOR}.${OSRM_VERSION_PATCH}")
|
2015-09-11 05:37:02 -04:00
|
|
|
|
2016-12-06 15:30:46 -05:00
|
|
|
add_definitions(-DOSRM_PROJECT_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
|
2016-05-27 11:53:51 -04:00
|
|
|
# these two functions build up custom variables:
|
2016-11-27 09:45:55 -05:00
|
|
|
# DEPENDENCIES_INCLUDE_DIRS and OSRM_DEFINES
|
2016-05-27 11:53:51 -04:00
|
|
|
# These variables we want to pass to
|
|
|
|
# include_directories and add_definitions for both
|
|
|
|
# this build and for sharing externally via pkg-config
|
|
|
|
|
2017-03-06 03:42:42 -05:00
|
|
|
function(add_dependency_includes)
|
|
|
|
if(${ARGC} GREATER 0)
|
|
|
|
list(APPEND DEPENDENCIES_INCLUDE_DIRS "${ARGV}")
|
|
|
|
set(DEPENDENCIES_INCLUDE_DIRS "${DEPENDENCIES_INCLUDE_DIRS}" PARENT_SCOPE)
|
|
|
|
endif()
|
2016-05-27 11:53:51 -04:00
|
|
|
endfunction(add_dependency_includes)
|
|
|
|
|
|
|
|
function(add_dependency_defines defines)
|
|
|
|
list(APPEND OSRM_DEFINES "${defines}")
|
|
|
|
set(OSRM_DEFINES "${OSRM_DEFINES}" PARENT_SCOPE)
|
|
|
|
endfunction(add_dependency_defines)
|
|
|
|
|
2013-11-13 11:08:27 -05:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
2014-04-01 11:54:41 -04:00
|
|
|
include(CheckCXXCompilerFlag)
|
2013-05-12 18:49:14 -04:00
|
|
|
include(FindPackageHandleStandardArgs)
|
2016-12-30 19:27:21 -05:00
|
|
|
include(GNUInstallDirs)
|
2013-07-03 07:32:31 -04:00
|
|
|
|
2013-12-16 05:21:30 -05:00
|
|
|
set(bitness 32)
|
|
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
|
|
set(bitness 64)
|
|
|
|
message(STATUS "Building on a 64 bit system")
|
|
|
|
else()
|
2016-06-05 17:42:21 -04:00
|
|
|
message(STATUS "Building on a 32 bit system")
|
2013-12-16 05:21:30 -05:00
|
|
|
endif()
|
|
|
|
|
2016-05-02 09:32:25 -04:00
|
|
|
if(WIN32 AND MSVC_VERSION LESS 1900)
|
|
|
|
message(FATAL_ERROR "Building with Microsoft compiler needs Latest Visual Studio 2015 (Community or better)")
|
2014-05-23 13:15:51 -04:00
|
|
|
endif()
|
|
|
|
|
2016-12-14 05:00:27 -05:00
|
|
|
# Strictly require GCC>=4.9 and Clang>=3.4 - GCC 4.8 is already too old for C++14.
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
|
|
|
|
message(FATAL_ERROR "GCC>=4.9 required. In case you are on Ubuntu upgrade via ppa:ubuntu-toolchain-r/test")
|
|
|
|
endif()
|
|
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
|
|
|
|
message(FATAL_ERROR "Clang>=3.4 required. In case you are on Ubuntu upgrade via http://apt.llvm.org")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-01-03 11:03:20 -05:00
|
|
|
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include/)
|
|
|
|
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include/)
|
2016-10-19 23:02:41 -04:00
|
|
|
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/third_party/sol2/)
|
2016-12-01 19:59:29 -05:00
|
|
|
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/third_party/variant/include)
|
2013-12-17 11:59:44 -05:00
|
|
|
|
2016-10-21 13:58:06 -04:00
|
|
|
set(BOOST_COMPONENTS date_time chrono filesystem iostreams program_options regex system thread unit_test_framework)
|
2013-07-17 08:47:22 -04:00
|
|
|
|
2013-12-17 15:42:00 -05:00
|
|
|
configure_file(
|
2016-01-02 10:11:49 -05:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include/util/version.hpp.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/include/util/version.hpp
|
2013-12-17 15:42:00 -05:00
|
|
|
)
|
2016-04-26 07:27:40 -04:00
|
|
|
file(GLOB UtilGlob src/util/*.cpp src/util/*/*.cpp)
|
2016-03-01 16:30:31 -05:00
|
|
|
file(GLOB ExtractorGlob src/extractor/*.cpp src/extractor/*/*.cpp)
|
2017-01-23 05:50:03 -05:00
|
|
|
file(GLOB PartitionerGlob src/partition/*.cpp)
|
2017-03-06 09:50:04 -05:00
|
|
|
file(GLOB CustomizerGlob src/customize/*.cpp)
|
2016-01-02 10:11:49 -05:00
|
|
|
file(GLOB ContractorGlob src/contractor/*.cpp)
|
2017-03-07 18:30:49 -05:00
|
|
|
file(GLOB UpdaterGlob src/updater/*.cpp)
|
2016-01-07 13:19:55 -05:00
|
|
|
file(GLOB StorageGlob src/storage/*.cpp)
|
2016-01-02 10:11:49 -05:00
|
|
|
file(GLOB ServerGlob src/server/*.cpp src/server/**/*.cpp)
|
|
|
|
file(GLOB EngineGlob src/engine/*.cpp src/engine/**/*.cpp)
|
2013-06-26 19:48:22 -04:00
|
|
|
|
2016-01-02 10:11:49 -05:00
|
|
|
add_library(UTIL OBJECT ${UtilGlob})
|
|
|
|
add_library(EXTRACTOR OBJECT ${ExtractorGlob})
|
2017-01-23 05:50:03 -05:00
|
|
|
add_library(PARTITIONER OBJECT ${PartitionerGlob})
|
2017-03-06 09:50:04 -05:00
|
|
|
add_library(CUSTOMIZER OBJECT ${CustomizerGlob})
|
2016-01-02 10:11:49 -05:00
|
|
|
add_library(CONTRACTOR OBJECT ${ContractorGlob})
|
2017-03-07 18:30:49 -05:00
|
|
|
add_library(UPDATER OBJECT ${UpdaterGlob})
|
2016-01-07 13:19:55 -05:00
|
|
|
add_library(STORAGE OBJECT ${StorageGlob})
|
2016-01-02 10:11:49 -05:00
|
|
|
add_library(ENGINE OBJECT ${EngineGlob})
|
|
|
|
add_library(SERVER OBJECT ${ServerGlob})
|
2015-01-13 09:52:24 -05:00
|
|
|
|
2016-01-02 10:11:49 -05:00
|
|
|
set_target_properties(UTIL PROPERTIES LINKER_LANGUAGE CXX)
|
2015-03-31 04:45:35 -04:00
|
|
|
|
2016-01-07 13:19:55 -05:00
|
|
|
add_executable(osrm-extract src/tools/extract.cpp)
|
2017-01-23 05:50:03 -05:00
|
|
|
add_executable(osrm-partition src/tools/partition.cpp)
|
2017-03-06 09:50:04 -05:00
|
|
|
add_executable(osrm-customize src/tools/customize.cpp)
|
2016-02-14 13:35:37 -05:00
|
|
|
add_executable(osrm-contract src/tools/contract.cpp)
|
2016-01-07 13:19:55 -05:00
|
|
|
add_executable(osrm-routed src/tools/routed.cpp $<TARGET_OBJECTS:SERVER> $<TARGET_OBJECTS:UTIL>)
|
|
|
|
add_executable(osrm-datastore src/tools/store.cpp $<TARGET_OBJECTS:UTIL>)
|
2016-03-22 14:30:18 -04:00
|
|
|
add_library(osrm src/osrm/osrm.cpp $<TARGET_OBJECTS:ENGINE> $<TARGET_OBJECTS:UTIL> $<TARGET_OBJECTS:STORAGE>)
|
2017-03-08 05:27:38 -05:00
|
|
|
add_library(osrm_contract src/osrm/contractor.cpp $<TARGET_OBJECTS:CONTRACTOR> $<TARGET_OBJECTS:UTIL>)
|
|
|
|
add_library(osrm_extract src/osrm/extractor.cpp $<TARGET_OBJECTS:EXTRACTOR> $<TARGET_OBJECTS:UTIL>)
|
2017-01-23 05:50:03 -05:00
|
|
|
add_library(osrm_partition $<TARGET_OBJECTS:PARTITIONER> $<TARGET_OBJECTS:UTIL>)
|
2017-03-06 09:50:04 -05:00
|
|
|
add_library(osrm_customize $<TARGET_OBJECTS:CUSTOMIZER> $<TARGET_OBJECTS:UTIL>)
|
2017-03-07 18:30:49 -05:00
|
|
|
add_library(osrm_update $<TARGET_OBJECTS:UPDATER> $<TARGET_OBJECTS:UTIL>)
|
2016-01-07 13:19:55 -05:00
|
|
|
add_library(osrm_store $<TARGET_OBJECTS:STORAGE> $<TARGET_OBJECTS:UTIL>)
|
2013-11-14 12:29:56 -05:00
|
|
|
|
2016-07-01 10:05:26 -04:00
|
|
|
if(ENABLE_GOLD_LINKER)
|
|
|
|
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
|
|
|
|
if("${LD_VERSION}" MATCHES "GNU gold")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
|
2016-11-29 18:15:05 -05:00
|
|
|
set(OSRM_LDFLAGS "${OSRM_LDFLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
|
2016-07-01 10:05:26 -04:00
|
|
|
message(STATUS "Using GNU gold as linker.")
|
2016-08-22 18:03:14 -04:00
|
|
|
|
|
|
|
# Issue 2785: check gold binutils version and don't use gc-sections for versions prior 2.25
|
|
|
|
string(REGEX REPLACE ".*\\(GNU Binutils[^\\)0-9]+([0-9]+\\.[0-9]+)[^\\)]*\\).*" "\\1" GOLD_BINUTILS_VERSION "${LD_VERSION}")
|
2016-10-03 09:41:23 -04:00
|
|
|
if ("${GOLD_BINUTILS_VERSION}" VERSION_LESS "2.26")
|
|
|
|
message(STATUS "Disabling gc-sections on gold binutils < 2.26, see: https://sourceware.org/bugzilla/show_bug.cgi?id=17639")
|
2016-08-22 18:03:14 -04:00
|
|
|
set(LD_AVOID_GC_SECTIONS TRUE)
|
|
|
|
endif()
|
2016-07-01 10:05:26 -04:00
|
|
|
else()
|
|
|
|
message(WARNING "GNU gold linker isn't available.")
|
|
|
|
set(ENABLE_GOLD_LINKER OFF)
|
|
|
|
endif()
|
2016-06-28 10:38:46 -04:00
|
|
|
endif()
|
|
|
|
|
2017-03-01 06:02:15 -05:00
|
|
|
# Disable LTO when mason+gcc is detected before testing for / setting any flags.
|
|
|
|
# Mason builds libraries with Clang, mixing does not work in the context of lto.
|
2017-03-06 03:42:42 -05:00
|
|
|
if(ENABLE_MASON AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND ENABLE_LTO)
|
|
|
|
set(ENABLE_LTO OFF)
|
2017-03-01 06:02:15 -05:00
|
|
|
message(WARNING "Mason and GCC's LTO not work together. Disabling LTO.")
|
|
|
|
endif()
|
|
|
|
|
2016-10-10 13:10:38 -04:00
|
|
|
# Explicitly set the build type to Release if no other type is specified
|
|
|
|
# on the command line. Without this, cmake defaults to an unoptimized,
|
|
|
|
# non-debug build, which almost nobody wants.
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
message(STATUS "No build type specified, defaulting to Release")
|
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
|
|
|
message(STATUS "Configuring OSRM in debug mode")
|
|
|
|
elseif(CMAKE_BUILD_TYPE MATCHES Release)
|
2014-05-16 09:00:31 -04:00
|
|
|
message(STATUS "Configuring OSRM in release mode")
|
2016-10-10 13:10:38 -04:00
|
|
|
elseif(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
|
|
|
|
message(STATUS "Configuring OSRM in release mode with debug flags")
|
|
|
|
elseif(CMAKE_BUILD_TYPE MATCHES MinRelSize)
|
|
|
|
message(STATUS "Configuring OSRM in release mode with minimized size")
|
|
|
|
else()
|
|
|
|
message(STATUS "Unrecognized build type - will use cmake defaults")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Additional logic for the different build types
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
|
|
|
|
message(STATUS "Configuring debug mode flags")
|
|
|
|
set(ENABLE_ASSERTIONS ON)
|
|
|
|
if(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-inline -fno-omit-frame-pointer")
|
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
|
|
if (CMAKE_BUILD_TYPE MATCHES Debug)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og -ggdb")
|
|
|
|
else()
|
|
|
|
# Don't override the -O parameter for RelWithDebInfo, we want an optimized build
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Release OR CMAKE_BUILD_TYPE MATCHES MinRelSize OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
|
|
|
|
message(STATUS "Configuring release mode optimizations")
|
2014-05-16 09:00:31 -04:00
|
|
|
# Check if LTO is available
|
2016-12-01 12:57:34 -05:00
|
|
|
check_cxx_compiler_flag("-Wl,-flto" LTO_AVAILABLE)
|
2016-11-29 18:15:05 -05:00
|
|
|
|
2016-06-22 13:03:00 -04:00
|
|
|
if(ENABLE_LTO AND LTO_AVAILABLE)
|
2015-09-04 14:59:53 -04:00
|
|
|
set(OLD_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
|
|
|
# GCC in addition allows parallelizing LTO
|
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
|
|
include(ProcessorCount)
|
|
|
|
ProcessorCount(NPROC)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=${NPROC}")
|
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
|
|
|
|
endif()
|
2015-01-29 10:23:04 -05:00
|
|
|
set(CHECK_LTO_SRC "int main(){return 0;}")
|
2015-02-16 08:18:04 -05:00
|
|
|
check_cxx_source_compiles("${CHECK_LTO_SRC}" LTO_WORKS)
|
2015-01-29 10:23:04 -05:00
|
|
|
if(LTO_WORKS)
|
2015-09-04 14:59:53 -04:00
|
|
|
message(STATUS "LTO working")
|
2016-11-29 18:15:05 -05:00
|
|
|
set(OSRM_CXXFLAGS "${OSRM_CXXFLAGS} -flto")
|
2016-12-01 12:57:34 -05:00
|
|
|
set(OSRM_LDFLAGS "${OSRM_LDFLAGS} -flto")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto")
|
|
|
|
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -flto")
|
2015-01-29 10:23:04 -05:00
|
|
|
else()
|
|
|
|
message(STATUS "LTO broken")
|
|
|
|
set(CMAKE_CXX_FLAGS "${OLD_CXX_FLAGS}")
|
2016-12-01 12:57:34 -05:00
|
|
|
set(ENABLE_LTO Off)
|
2015-01-29 10:23:04 -05:00
|
|
|
endif()
|
2014-05-16 09:00:31 -04:00
|
|
|
|
2014-12-23 05:46:25 -05:00
|
|
|
# Since gcc 4.9 the LTO format is non-standart ('slim'), so we need to use the build-in tools
|
2015-02-16 08:18:04 -05:00
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND
|
2014-10-18 09:13:46 -04:00
|
|
|
NOT "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.9.0" AND NOT MINGW)
|
2016-12-01 12:57:34 -05:00
|
|
|
find_program(GCC_AR gcc-ar)
|
|
|
|
find_program(GCC_RANLIB gcc-ranlib)
|
|
|
|
if ("${GCC_AR}" STREQUAL "GCC_AR-NOTFOUND" OR "${GCC_RANLIB}" STREQUAL "GCC_RANLIB-NOTFOUND")
|
2016-12-14 05:56:22 -05:00
|
|
|
message(WARNING "GCC specific binutils not found. In case of linker issues export env vars: AR=gcc-ar, NM=gcc-nm, RANLIB=gcc-ranlib")
|
2016-12-01 12:57:34 -05:00
|
|
|
else()
|
|
|
|
message(STATUS "Using GCC specific binutils for LTO:")
|
|
|
|
message(STATUS " ${GCC_AR}")
|
|
|
|
message(STATUS " ${GCC_RANLIB}")
|
|
|
|
set(CMAKE_AR ${GCC_AR})
|
|
|
|
set(CMAKE_RANLIB ${GCC_RANLIB})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Same for clang LTO requires their own toolchain
|
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|
|
|
find_program(LLVM_AR llvm-ar)
|
|
|
|
find_program(LLVM_RANLIB llvm-ranlib)
|
|
|
|
if ("${LLVM_AR}" STREQUAL "LLVM_AR-NOTFOUND" OR "${LLVM_RANLIB}" STREQUAL "LLVM_RANLIB-NOTFOUND")
|
|
|
|
message(WARNING "LLVM specific binutils not found.")
|
|
|
|
else()
|
|
|
|
message(STATUS "Using LLVM specific binutils for LTO:")
|
|
|
|
message(STATUS " ${LLVM_AR}")
|
|
|
|
message(STATUS " ${LLVM_RANLIB}")
|
|
|
|
set(CMAKE_AR ${LLVM_AR})
|
|
|
|
set(CMAKE_RANLIB ${LLVM_RANLIB})
|
|
|
|
endif()
|
2014-05-16 09:00:31 -04:00
|
|
|
endif()
|
2015-09-16 12:56:29 -04:00
|
|
|
|
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.9.0")
|
|
|
|
message(STATUS "Disabling LTO on GCC < 4.9.0 since it is broken, see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57038")
|
|
|
|
set(CMAKE_CXX_FLAGS "${OLD_CXX_FLAGS}")
|
2016-12-01 12:57:34 -05:00
|
|
|
set(ENABLE_LTO Off)
|
2015-09-16 12:56:29 -04:00
|
|
|
endif()
|
2015-02-16 08:18:04 -05:00
|
|
|
endif()
|
2013-12-17 15:42:00 -05:00
|
|
|
endif()
|
2013-04-22 16:23:53 -04:00
|
|
|
|
2016-11-29 18:15:05 -05:00
|
|
|
if(UNIX AND NOT APPLE AND ENABLE_MASON AND (LTO_WORKS OR ENABLE_GOLD_LINKER))
|
2016-10-28 15:18:13 -04:00
|
|
|
message(WARNING "ENABLE_MASON and ENABLE_LTO/ENABLE_GOLD_LINKER may not work on all linux systems currently")
|
|
|
|
message(WARNING "For more details see: https://github.com/Project-OSRM/osrm-backend/issues/3202")
|
|
|
|
endif()
|
|
|
|
|
2016-04-07 18:49:53 -04:00
|
|
|
set(MAYBE_COVERAGE_LIBRARIES "")
|
2016-10-10 12:04:43 -04:00
|
|
|
if (ENABLE_COVERAGE)
|
2016-04-12 09:43:29 -04:00
|
|
|
if (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
|
2016-10-10 12:04:43 -04:00
|
|
|
message(ERROR "ENABLE_COVERAGE=ON only make sense with a Debug build")
|
2016-04-07 18:49:53 -04:00
|
|
|
endif()
|
2016-04-24 18:19:48 -04:00
|
|
|
message(INFO "Enabling coverage")
|
2016-10-24 20:09:03 -04:00
|
|
|
set(MAYBE_COVERAGE_LIBRARIES "-lgcov")
|
2016-04-07 18:49:53 -04:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftest-coverage -fprofile-arcs")
|
|
|
|
endif()
|
2016-10-10 12:04:43 -04:00
|
|
|
if (ENABLE_SANITIZER)
|
2016-04-12 09:43:29 -04:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
|
2016-11-27 09:45:55 -05:00
|
|
|
set(OSRM_CXXFLAGS "${OSRM_CXXFLAGS} -fsanitize=address")
|
2016-04-12 09:43:29 -04:00
|
|
|
endif()
|
2016-04-07 18:49:53 -04:00
|
|
|
|
2013-10-28 09:51:20 -04:00
|
|
|
# Configuring compilers
|
2015-03-31 06:35:20 -04:00
|
|
|
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
2017-03-13 18:25:44 -04:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wuninitialized -Wunreachable-code -Wstrict-overflow=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -fcolor-diagnostics -ftemplate-depth=1024 -Wno-unused-command-line-argument")
|
2015-03-31 06:35:20 -04:00
|
|
|
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
|
2015-01-04 17:13:15 -05:00
|
|
|
set(COLOR_FLAG "-fdiagnostics-color=auto")
|
2015-02-16 08:18:04 -05:00
|
|
|
check_cxx_compiler_flag("-fdiagnostics-color=auto" HAS_COLOR_FLAG)
|
2015-01-04 17:13:15 -05:00
|
|
|
if(NOT HAS_COLOR_FLAG)
|
|
|
|
set(COLOR_FLAG "")
|
|
|
|
endif()
|
2013-12-17 15:42:00 -05:00
|
|
|
# using GCC
|
2016-12-06 09:13:11 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wuninitialized -Wunreachable-code -Wstrict-overflow=1 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 ${COLOR_FLAG} -fPIC -ftemplate-depth=1024")
|
2015-02-16 08:18:04 -05:00
|
|
|
if(WIN32) # using mingw
|
2016-05-27 11:53:51 -04:00
|
|
|
add_dependency_defines(-DWIN32)
|
2015-02-16 08:18:04 -05:00
|
|
|
set(OPTIONAL_SOCKET_LIBS ws2_32 wsock32)
|
2014-06-11 09:53:37 -04:00
|
|
|
endif()
|
2017-02-06 11:53:23 -05:00
|
|
|
|
|
|
|
# -fpermissive is required for parallel_do Intel TBB internal issue with GCC < 5
|
|
|
|
# https://github.com/Project-OSRM/osrm-backend/pull/3603#issuecomment-277688589
|
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
|
|
|
|
message(STATUS "Adding -fpermissive for GCC version < 5 bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51048). See #3603.")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
|
|
|
|
endif()
|
|
|
|
|
2015-03-31 06:35:20 -04:00
|
|
|
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
|
2013-12-17 15:42:00 -05:00
|
|
|
# using Intel C++
|
2014-05-22 11:00:05 -04:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-intel -wd10237 -Wall -ipo -fPIC")
|
2015-03-31 06:35:20 -04:00
|
|
|
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
2013-12-17 15:42:00 -05:00
|
|
|
# using Visual Studio C++
|
2016-10-21 13:58:06 -04:00
|
|
|
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} zlib)
|
2017-03-07 13:28:53 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") # avoid compiler error C1128 from scripting_environment_lua.cpp
|
2016-05-27 11:53:51 -04:00
|
|
|
add_dependency_defines(-DBOOST_LIB_DIAGNOSTIC)
|
|
|
|
add_dependency_defines(-D_CRT_SECURE_NO_WARNINGS)
|
|
|
|
add_dependency_defines(-DNOMINMAX) # avoid min and max macros that can break compilation
|
|
|
|
add_dependency_defines(-D_USE_MATH_DEFINES) #needed for M_PI with cmath.h
|
|
|
|
add_dependency_defines(-D_WIN32_WINNT=0x0501)
|
|
|
|
add_dependency_defines(-DXML_STATIC)
|
2014-08-28 06:47:57 -04:00
|
|
|
find_library(ws2_32_LIBRARY_PATH ws2_32)
|
|
|
|
target_link_libraries(osrm-extract wsock32 ws2_32)
|
2013-04-22 16:23:53 -04:00
|
|
|
endif()
|
|
|
|
|
2015-09-04 18:12:13 -04:00
|
|
|
# Configuring linker
|
|
|
|
execute_process(COMMAND ${CMAKE_CXX_COMPILER} "-Wl,--version" ERROR_QUIET OUTPUT_VARIABLE LINKER_VERSION)
|
|
|
|
# For ld.gold and ld.bfs (the GNU linkers) we optimize hard
|
|
|
|
if("${LINKER_VERSION}" MATCHES "GNU gold" OR "${LINKER_VERSION}" MATCHES "GNU ld")
|
|
|
|
message(STATUS "Setting linker optimizations")
|
2016-08-22 18:03:14 -04:00
|
|
|
if(NOT (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC" OR "${LD_AVOID_GC_SECTIONS}"))
|
2015-09-04 18:12:13 -04:00
|
|
|
# Tell compiler to put every function in separate section, linker can then match sections and functions
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections")
|
|
|
|
# Tell linker to do dead code and data eminination during link time discarding sections
|
|
|
|
set(LINKER_FLAGS "${LINKER_FLAGS} -Wl,--gc-sections")
|
|
|
|
endif()
|
|
|
|
# Default linker optimization flags
|
|
|
|
set(LINKER_FLAGS "${LINKER_FLAGS} -Wl,-O1 -Wl,--hash-style=gnu -Wl,--sort-common")
|
2016-11-29 18:15:05 -05:00
|
|
|
|
2015-09-04 18:12:13 -04:00
|
|
|
else()
|
|
|
|
message(STATUS "Using unknown linker, not setting linker optimizations")
|
|
|
|
endif ()
|
2016-11-29 18:15:05 -05:00
|
|
|
set(OSRM_LDFLAGS "${OSRM_LDFLAGS} ${LINKER_FLAGS}")
|
2015-09-04 18:12:13 -04:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAGS}")
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINKER_FLAGS}")
|
|
|
|
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${LINKER_FLAGS}")
|
|
|
|
|
2016-08-23 07:01:07 -04:00
|
|
|
# Activate C++1y
|
2015-03-31 06:35:20 -04:00
|
|
|
if(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
2016-08-23 07:01:07 -04:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y")
|
2016-11-27 09:45:55 -05:00
|
|
|
set(OSRM_CXXFLAGS "${OSRM_CXXFLAGS} -std=c++1y")
|
2014-05-23 13:15:51 -04:00
|
|
|
endif()
|
2014-05-02 04:08:07 -04:00
|
|
|
|
2013-10-28 09:51:20 -04:00
|
|
|
# Configuring other platform dependencies
|
2013-04-22 16:23:53 -04:00
|
|
|
if(APPLE)
|
2016-10-27 18:29:27 -04:00
|
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.10")
|
|
|
|
execute_process(COMMAND xcrun --sdk macosx --show-sdk-path OUTPUT_VARIABLE CMAKE_OSX_SYSROOT OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2013-12-17 15:42:00 -05:00
|
|
|
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
|
|
|
message(STATUS "Set Architecture to x64 on OS X")
|
2014-03-13 08:28:58 -04:00
|
|
|
exec_program(uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION)
|
|
|
|
string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
|
|
|
|
if(OSXLIBSTD)
|
|
|
|
message(STATUS "linking against ${OSXLIBSTD}")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=${OSXLIBSTD}")
|
|
|
|
elseif(DARWIN_VERSION GREATER 12)
|
|
|
|
message(STATUS "linking against libc++")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
|
|
|
endif()
|
2013-04-22 16:23:53 -04:00
|
|
|
endif()
|
|
|
|
|
2013-10-28 09:51:20 -04:00
|
|
|
if(UNIX AND NOT APPLE)
|
2016-10-24 20:09:03 -04:00
|
|
|
set(MAYBE_RT_LIBRARY -lrt)
|
2013-12-17 15:42:00 -05:00
|
|
|
endif()
|
2013-10-28 09:51:20 -04:00
|
|
|
|
2016-09-30 05:44:19 -04:00
|
|
|
# Disallow deprecated protozero APIs
|
|
|
|
add_definitions(-DPROTOZERO_STRICT_API)
|
|
|
|
|
2016-10-20 20:03:55 -04:00
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
|
|
|
# if mason is enabled no find_package calls are made
|
|
|
|
# to ensure that we are only compiling and linking against
|
|
|
|
# fully portable mason packages
|
|
|
|
if(ENABLE_MASON)
|
|
|
|
message(STATUS "Installing dependencies via mason")
|
|
|
|
|
|
|
|
set(Boost_USE_STATIC_LIBS ON)
|
2016-10-20 20:03:55 -04:00
|
|
|
mason_use(boost VERSION ${MASON_BOOST_VERSION} HEADER_ONLY)
|
2016-10-20 20:03:55 -04:00
|
|
|
add_dependency_includes(${MASON_PACKAGE_boost_INCLUDE_DIRS})
|
2016-10-20 20:03:55 -04:00
|
|
|
mason_use(boost_libfilesystem VERSION ${MASON_BOOST_VERSION})
|
2016-10-20 20:03:55 -04:00
|
|
|
set(Boost_FILESYSTEM_LIBRARY ${MASON_PACKAGE_boost_libfilesystem_STATIC_LIBS})
|
2016-10-20 20:03:55 -04:00
|
|
|
mason_use(boost_libiostreams VERSION ${MASON_BOOST_VERSION})
|
2016-10-20 20:03:55 -04:00
|
|
|
set(Boost_IOSTREAMS_LIBRARY ${MASON_PACKAGE_boost_libiostreams_STATIC_LIBS})
|
2016-10-20 20:03:55 -04:00
|
|
|
mason_use(boost_libprogram_options VERSION ${MASON_BOOST_VERSION})
|
2016-10-20 20:03:55 -04:00
|
|
|
set(Boost_PROGRAM_OPTIONS_LIBRARY ${MASON_PACKAGE_boost_libprogram_options_STATIC_LIBS})
|
2016-10-20 20:03:55 -04:00
|
|
|
mason_use(boost_libregex VERSION ${MASON_BOOST_VERSION})
|
2016-10-20 20:03:55 -04:00
|
|
|
set(Boost_REGEX_LIBRARY ${MASON_PACKAGE_boost_libregex_STATIC_LIBS})
|
2016-10-20 20:03:55 -04:00
|
|
|
mason_use(boost_libtest VERSION ${MASON_BOOST_VERSION})
|
2016-10-20 20:03:55 -04:00
|
|
|
set(Boost_UNIT_TEST_FRAMEWORK_LIBRARY ${MASON_PACKAGE_boost_libtest_STATIC_LIBS})
|
2016-10-20 20:03:55 -04:00
|
|
|
mason_use(boost_libdate_time VERSION ${MASON_BOOST_VERSION})
|
2016-10-20 20:03:55 -04:00
|
|
|
set(Boost_DATE_TIME_LIBRARY ${MASON_PACKAGE_boost_libdate_time_STATIC_LIBS})
|
2016-10-20 20:03:55 -04:00
|
|
|
mason_use(boost_libthread VERSION ${MASON_BOOST_VERSION})
|
2016-10-20 20:03:55 -04:00
|
|
|
set(Boost_THREAD_LIBRARY ${MASON_PACKAGE_boost_libthread_STATIC_LIBS})
|
2016-10-20 20:03:55 -04:00
|
|
|
mason_use(boost_libsystem VERSION ${MASON_BOOST_VERSION})
|
2016-10-20 20:03:55 -04:00
|
|
|
set(Boost_SYSTEM_LIBRARY ${MASON_PACKAGE_boost_libsystem_STATIC_LIBS})
|
|
|
|
|
2016-10-20 20:03:55 -04:00
|
|
|
mason_use(stxxl VERSION ${MASON_STXXL_VERSION})
|
2016-10-20 20:03:55 -04:00
|
|
|
add_dependency_includes(${MASON_PACKAGE_stxxl_INCLUDE_DIRS})
|
|
|
|
set(STXXL_LIBRARY ${MASON_PACKAGE_stxxl_STATIC_LIBS})
|
|
|
|
|
2016-10-20 20:03:55 -04:00
|
|
|
mason_use(expat VERSION ${MASON_EXPAT_VERSION})
|
2016-10-20 20:03:55 -04:00
|
|
|
add_dependency_includes(${MASON_PACKAGE_expat_INCLUDE_DIRS})
|
|
|
|
set(EXPAT_LIBRARIES ${MASON_PACKAGE_expat_STATIC_LIBS})
|
|
|
|
|
2016-10-20 20:03:55 -04:00
|
|
|
mason_use(lua VERSION ${MASON_LUA_VERSION})
|
2016-10-20 20:03:55 -04:00
|
|
|
add_dependency_includes(${MASON_PACKAGE_lua_INCLUDE_DIRS})
|
|
|
|
set(USED_LUA_LIBRARIES ${MASON_PACKAGE_lua_STATIC_LIBS})
|
|
|
|
|
2016-10-20 20:03:55 -04:00
|
|
|
mason_use(bzip2 VERSION ${MASON_BZIP2_VERSION})
|
2016-10-20 20:03:55 -04:00
|
|
|
add_dependency_includes(${MASON_PACKAGE_bzip2_INCLUDE_DIRS})
|
|
|
|
set(BZIP2_LIBRARIES ${MASON_PACKAGE_bzip2_STATIC_LIBS})
|
|
|
|
|
2016-10-20 20:03:55 -04:00
|
|
|
mason_use(tbb VERSION ${MASON_TBB_VERSION})
|
2016-10-20 20:03:55 -04:00
|
|
|
add_dependency_includes(${MASON_PACKAGE_tbb_INCLUDE_DIRS})
|
|
|
|
set(TBB_LIBRARIES ${MASON_PACKAGE_tbb_LDFLAGS})
|
|
|
|
|
2017-02-27 06:03:57 -05:00
|
|
|
mason_use(libshp2 VERSION ${MASON_LIBSHP_VERSION})
|
|
|
|
set(LIBSHAPEFILE_INCLUDE_DIR ${MASON_PACKAGE_libshp2_INCLUDE_DIRS})
|
|
|
|
set(LIBSHAPEFILE_LIBRARY ${MASON_PACKAGE_libshp2_LDFLAGS})
|
|
|
|
|
2016-10-20 20:03:55 -04:00
|
|
|
if(NOT MASON_PACKAGE_tbb_LIBRARY_DIRS)
|
2016-10-20 20:03:55 -04:00
|
|
|
message(FATAL_ERROR "MASON_PACKAGE_tbb_LIBRARY_DIRS is empty, rpath will not work")
|
2016-10-20 20:03:55 -04:00
|
|
|
endif()
|
2016-11-26 18:16:39 -05:00
|
|
|
set(TBB_LINKER_RPATHS "")
|
2016-10-20 20:03:55 -04:00
|
|
|
foreach(libpath ${MASON_PACKAGE_tbb_LIBRARY_DIRS})
|
2016-11-26 18:16:39 -05:00
|
|
|
set(TBB_LINKER_RPATHS "${TBB_LINKER_RPATHS} -Wl,-rpath -Wl,${libpath}")
|
2016-10-20 20:03:55 -04:00
|
|
|
file(GLOB TBBGlob ${libpath}/*.*)
|
|
|
|
install(FILES ${TBBGlob} DESTINATION lib)
|
|
|
|
endforeach()
|
2016-11-26 18:16:39 -05:00
|
|
|
if(APPLE)
|
|
|
|
set(LINKER_FLAGS "${TBB_LINKER_RPATHS} -Wl,-rpath -Wl,@executable_path")
|
|
|
|
elseif(UNIX)
|
|
|
|
set(LINKER_FLAGS "${TBB_LINKER_RPATHS} '-Wl,-rpath,$ORIGIN' -Wl,-z,origin")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAGS}")
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINKER_FLAGS}")
|
|
|
|
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${LINKER_FLAGS}")
|
2016-10-20 20:03:55 -04:00
|
|
|
|
|
|
|
# current mason packages target -D_GLIBCXX_USE_CXX11_ABI=0
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
|
|
|
|
|
2016-11-08 18:29:49 -05:00
|
|
|
# note: we avoid calling find_package(Osmium ...) here to ensure that the
|
|
|
|
# expat and bzip2 are used from mason rather than the system
|
|
|
|
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/third_party/libosmium/include)
|
|
|
|
|
2016-10-20 20:03:55 -04:00
|
|
|
else()
|
|
|
|
|
2016-12-14 05:00:56 -05:00
|
|
|
find_package(Boost 1.54 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
2016-10-20 20:03:55 -04:00
|
|
|
add_dependency_includes(${Boost_INCLUDE_DIRS})
|
2016-12-15 06:07:07 -05:00
|
|
|
if(WIN32 AND Boost_VERSION VERSION_LESS 106200)
|
|
|
|
message(FATAL_ERROR "Building with MSVC needs Boost 1.62 with CXX11_CONSTEXPR support")
|
|
|
|
endif()
|
2016-10-20 20:03:55 -04:00
|
|
|
|
|
|
|
find_package(TBB REQUIRED)
|
|
|
|
add_dependency_includes(${TBB_INCLUDE_DIR})
|
|
|
|
if(WIN32 AND CMAKE_BUILD_TYPE MATCHES Debug)
|
|
|
|
set(TBB_LIBRARIES ${TBB_DEBUG_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
find_package(EXPAT REQUIRED)
|
|
|
|
add_dependency_includes(${EXPAT_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
find_package(STXXL REQUIRED)
|
|
|
|
add_dependency_includes(${STXXL_INCLUDE_DIR})
|
|
|
|
|
|
|
|
find_package(BZip2 REQUIRED)
|
|
|
|
add_dependency_includes(${BZIP2_INCLUDE_DIR})
|
|
|
|
|
2016-12-06 09:13:11 -05:00
|
|
|
FIND_PACKAGE(Lua 5.2 EXACT)
|
|
|
|
IF (LUA_FOUND)
|
|
|
|
MESSAGE(STATUS "Using Lua ${LUA_VERSION_STRING}")
|
|
|
|
ELSE()
|
|
|
|
FIND_PACKAGE(Lua 5.1 EXACT)
|
|
|
|
IF (LUA_FOUND)
|
|
|
|
MESSAGE(STATUS "Using Lua ${LUA_VERSION_STRING}")
|
|
|
|
ELSE()
|
|
|
|
# Now fall back to a lua verison without exact
|
|
|
|
# in case this cmake version also forces patch versions
|
|
|
|
FIND_PACKAGE(Lua 5.2)
|
|
|
|
IF (LUA_FOUND)
|
|
|
|
MESSAGE(STATUS "Using Lua ${LUA_VERSION_STRING}")
|
|
|
|
ELSE()
|
|
|
|
FIND_PACKAGE(Lua 5.1)
|
|
|
|
IF (LUA_FOUND)
|
|
|
|
MESSAGE(STATUS "Using Lua ${LUA_VERSION_STRING}")
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(FATAL_ERROR "Lua 5.1 or 5.2 was not found.")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
2017-01-18 07:15:30 -05:00
|
|
|
set(USED_LUA_LIBRARIES ${LUA_LIBRARIES})
|
2016-12-06 09:13:11 -05:00
|
|
|
add_dependency_includes(${LUA_INCLUDE_DIR})
|
|
|
|
|
2016-10-20 20:03:55 -04:00
|
|
|
# add a target to generate API documentation with Doxygen
|
|
|
|
find_package(Doxygen)
|
|
|
|
if(DOXYGEN_FOUND)
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
|
|
|
add_custom_target(doc
|
|
|
|
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
COMMENT "Generating API documentation with Doxygen" VERBATIM
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2016-11-08 18:29:49 -05:00
|
|
|
# note libosmium depends on expat and bzip2
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/libosmium/cmake")
|
2017-03-08 03:54:59 -05:00
|
|
|
if(NOT OSMIUM_INCLUDE_DIR)
|
|
|
|
set(OSMIUM_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/libosmium/include")
|
|
|
|
endif()
|
2016-11-08 18:29:49 -05:00
|
|
|
find_package(Osmium REQUIRED COMPONENTS io)
|
|
|
|
include_directories(SYSTEM ${OSMIUM_INCLUDE_DIR})
|
|
|
|
|
2016-03-31 05:29:54 -04:00
|
|
|
endif()
|
2013-06-26 19:48:22 -04:00
|
|
|
|
2016-12-01 12:37:04 -05:00
|
|
|
# prefix compilation with ccache by default if available and on clang or gcc
|
|
|
|
if(ENABLE_CCACHE AND (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU"))
|
|
|
|
find_program(CCACHE_FOUND ccache)
|
|
|
|
if(CCACHE_FOUND)
|
|
|
|
message(STATUS "Using ccache to speed up incremental builds")
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
|
|
|
set(ENV{CCACHE_CPP2} "true")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-10-28 15:18:13 -04:00
|
|
|
# even with mason builds we want to link to system zlib
|
|
|
|
# to ensure that osrm binaries play well with other binaries like nodejs
|
|
|
|
find_package(ZLIB REQUIRED)
|
|
|
|
add_dependency_includes(${ZLIB_INCLUDE_DIRS})
|
|
|
|
|
2016-05-20 00:03:37 -04:00
|
|
|
if(NOT WIN32 AND NOT Boost_USE_STATIC_LIBS)
|
2016-05-27 11:53:51 -04:00
|
|
|
add_dependency_defines(-DBOOST_TEST_DYN_LINK)
|
2014-05-23 13:15:51 -04:00
|
|
|
endif()
|
2014-05-16 07:26:42 -04:00
|
|
|
|
2016-10-20 20:03:55 -04:00
|
|
|
if(NOT WIN32 AND NOT Boost_USE_STATIC_LIBS)
|
|
|
|
add_dependency_defines(-DBOOST_TEST_DYN_LINK)
|
2014-05-23 13:15:51 -04:00
|
|
|
endif()
|
2013-04-22 16:23:53 -04:00
|
|
|
|
2016-10-20 20:03:55 -04:00
|
|
|
add_dependency_defines(-DBOOST_SPIRIT_USE_PHOENIX_V3)
|
|
|
|
add_dependency_defines(-DBOOST_RESULT_OF_USE_DECLTYPE)
|
|
|
|
add_dependency_defines(-DBOOST_FILESYSTEM_NO_DEPRECATED)
|
2013-04-22 16:23:53 -04:00
|
|
|
|
2015-02-05 05:37:55 -05:00
|
|
|
set(OpenMP_FIND_QUIETLY ON)
|
2015-01-29 11:29:03 -05:00
|
|
|
find_package(OpenMP)
|
|
|
|
if(OPENMP_FOUND)
|
2015-02-16 08:18:04 -05:00
|
|
|
message(STATUS "OpenMP support found. Linking just in case for stxxl")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
2015-01-29 11:01:08 -05:00
|
|
|
endif()
|
2014-11-16 11:33:41 -05:00
|
|
|
|
2016-05-27 11:53:51 -04:00
|
|
|
add_definitions(${OSRM_DEFINES})
|
2016-11-27 09:45:55 -05:00
|
|
|
include_directories(SYSTEM ${DEPENDENCIES_INCLUDE_DIRS})
|
2016-05-27 11:53:51 -04:00
|
|
|
|
2016-10-20 12:59:37 -04:00
|
|
|
set(BOOST_BASE_LIBRARIES
|
|
|
|
${Boost_DATE_TIME_LIBRARY}
|
2016-10-21 13:58:06 -04:00
|
|
|
${Boost_CHRONO_LIBRARY}
|
2016-10-20 12:59:37 -04:00
|
|
|
${Boost_FILESYSTEM_LIBRARY}
|
|
|
|
${Boost_IOSTREAMS_LIBRARY}
|
|
|
|
${Boost_THREAD_LIBRARY}
|
|
|
|
${Boost_SYSTEM_LIBRARY})
|
|
|
|
|
|
|
|
set(BOOST_ENGINE_LIBRARIES
|
2016-10-21 13:58:06 -04:00
|
|
|
${Boost_ZLIB_LIBRARY}
|
|
|
|
${Boost_REGEX_LIBRARY}
|
|
|
|
${BOOST_BASE_LIBRARIES})
|
2016-10-20 12:59:37 -04:00
|
|
|
|
2016-01-07 13:19:55 -05:00
|
|
|
# Binaries
|
2016-11-08 20:09:18 -05:00
|
|
|
target_link_libraries(osrm-datastore osrm_store ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
|
|
|
target_link_libraries(osrm-extract osrm_extract ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
2017-01-23 05:50:03 -05:00
|
|
|
target_link_libraries(osrm-partition osrm_partition ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
2017-03-06 09:50:04 -05:00
|
|
|
target_link_libraries(osrm-customize osrm_customize ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
2016-11-08 20:09:18 -05:00
|
|
|
target_link_libraries(osrm-contract osrm_contract ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
|
|
|
target_link_libraries(osrm-routed osrm ${Boost_PROGRAM_OPTIONS_LIBRARY} ${OPTIONAL_SOCKET_LIBS} ${ZLIB_LIBRARY})
|
2016-01-07 13:19:55 -05:00
|
|
|
|
|
|
|
set(EXTRACTOR_LIBRARIES
|
|
|
|
${BZIP2_LIBRARIES}
|
2016-10-20 12:59:37 -04:00
|
|
|
${Boost_REGEX_LIBRARY}
|
|
|
|
${BOOST_BASE_LIBRARIES}
|
2016-01-07 13:19:55 -05:00
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
|
|
${EXPAT_LIBRARIES}
|
|
|
|
${USED_LUA_LIBRARIES}
|
|
|
|
${OSMIUM_LIBRARIES}
|
|
|
|
${STXXL_LIBRARY}
|
|
|
|
${TBB_LIBRARIES}
|
2016-04-07 18:49:53 -04:00
|
|
|
${ZLIB_LIBRARY}
|
|
|
|
${MAYBE_COVERAGE_LIBRARIES})
|
2017-01-23 05:50:03 -05:00
|
|
|
set(PARTITIONER_LIBRARIES
|
|
|
|
${BOOST_ENGINE_LIBRARIES}
|
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
|
|
${TBB_LIBRARIES}
|
|
|
|
${MAYBE_RT_LIBRARY}
|
|
|
|
${MAYBE_COVERAGE_LIBRARIES}
|
|
|
|
${ZLIB_LIBRARY})
|
2017-03-07 18:30:49 -05:00
|
|
|
set(CUSTOMIZER_LIBRARIES
|
2017-03-06 09:50:04 -05:00
|
|
|
${BOOST_ENGINE_LIBRARIES}
|
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
|
|
${TBB_LIBRARIES}
|
|
|
|
${MAYBE_RT_LIBRARY}
|
|
|
|
${MAYBE_COVERAGE_LIBRARIES})
|
2017-03-07 18:30:49 -05:00
|
|
|
set(UPDATER_LIBRARIES
|
|
|
|
${BOOST_BASE_LIBRARIES}
|
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
|
|
${TBB_LIBRARIES}
|
|
|
|
${MAYBE_RT_LIBRARY}
|
|
|
|
${MAYBE_COVERAGE_LIBRARIES})
|
2016-01-07 13:19:55 -05:00
|
|
|
set(CONTRACTOR_LIBRARIES
|
2016-10-20 12:59:37 -04:00
|
|
|
${BOOST_BASE_LIBRARIES}
|
2016-01-07 13:19:55 -05:00
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
|
|
${USED_LUA_LIBRARIES}
|
|
|
|
${STXXL_LIBRARY}
|
|
|
|
${TBB_LIBRARIES}
|
2016-04-07 18:49:53 -04:00
|
|
|
${MAYBE_RT_LIBRARY}
|
|
|
|
${MAYBE_COVERAGE_LIBRARIES})
|
2016-01-07 13:19:55 -05:00
|
|
|
set(ENGINE_LIBRARIES
|
2016-05-27 11:53:51 -04:00
|
|
|
${BOOST_ENGINE_LIBRARIES}
|
2016-01-07 13:19:55 -05:00
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
|
|
${TBB_LIBRARIES}
|
2016-04-07 18:49:53 -04:00
|
|
|
${MAYBE_RT_LIBRARY}
|
2016-05-25 09:32:27 -04:00
|
|
|
${MAYBE_COVERAGE_LIBRARIES}
|
|
|
|
${ZLIB_LIBRARY})
|
2016-01-07 13:19:55 -05:00
|
|
|
set(STORAGE_LIBRARIES
|
2016-10-20 12:59:37 -04:00
|
|
|
${BOOST_BASE_LIBRARIES}
|
2016-01-07 13:19:55 -05:00
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
|
|
${TBB_LIBRARIES}
|
2016-04-07 18:49:53 -04:00
|
|
|
${MAYBE_RT_LIBRARY}
|
|
|
|
${MAYBE_COVERAGE_LIBRARIES})
|
2016-01-07 13:19:55 -05:00
|
|
|
set(UTIL_LIBRARIES
|
2016-10-20 12:59:37 -04:00
|
|
|
${BOOST_BASE_LIBRARIES}
|
2016-01-07 13:19:55 -05:00
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
|
|
${STXXL_LIBRARY}
|
2016-04-07 18:49:53 -04:00
|
|
|
${TBB_LIBRARIES}
|
|
|
|
${MAYBE_COVERAGE_LIBRARIES})
|
2016-01-07 13:19:55 -05:00
|
|
|
# Libraries
|
|
|
|
target_link_libraries(osrm ${ENGINE_LIBRARIES})
|
2017-03-07 18:30:49 -05:00
|
|
|
target_link_libraries(osrm_update ${UPDATER_LIBRARIES})
|
|
|
|
target_link_libraries(osrm_contract ${CONTRACTOR_LIBRARIES} osrm_update)
|
2016-01-07 13:19:55 -05:00
|
|
|
target_link_libraries(osrm_extract ${EXTRACTOR_LIBRARIES})
|
2017-01-23 05:50:03 -05:00
|
|
|
target_link_libraries(osrm_partition ${PARTITIONER_LIBRARIES})
|
2017-03-10 17:35:46 -05:00
|
|
|
target_link_libraries(osrm_customize ${CUSTOMIZER_LIBRARIES} osrm_update)
|
2016-01-07 13:19:55 -05:00
|
|
|
target_link_libraries(osrm_store ${STORAGE_LIBRARIES})
|
|
|
|
|
2017-01-23 04:55:49 -05:00
|
|
|
# BUILD_COMPONENTS
|
|
|
|
add_executable(osrm-components src/tools/components.cpp $<TARGET_OBJECTS:UTIL>)
|
|
|
|
target_link_libraries(osrm-components ${TBB_LIBRARIES} ${BOOST_BASE_LIBRARIES})
|
|
|
|
install(TARGETS osrm-components DESTINATION bin)
|
2016-03-30 16:50:32 -04:00
|
|
|
|
|
|
|
if(BUILD_TOOLS)
|
|
|
|
message(STATUS "Activating OSRM internal tools")
|
2016-01-02 10:11:49 -05:00
|
|
|
add_executable(osrm-io-benchmark src/tools/io-benchmark.cpp $<TARGET_OBJECTS:UTIL>)
|
2016-10-20 12:59:37 -04:00
|
|
|
target_link_libraries(osrm-io-benchmark ${BOOST_BASE_LIBRARIES})
|
2014-07-11 09:25:26 -04:00
|
|
|
|
|
|
|
install(TARGETS osrm-io-benchmark DESTINATION bin)
|
2016-12-20 05:16:05 -05:00
|
|
|
|
|
|
|
find_package(Shapefile) # package libshp-dev
|
2017-02-27 06:03:57 -05:00
|
|
|
if(SHAPEFILE_FOUND AND (Boost_VERSION VERSION_GREATER 106000 OR ENABLE_MASON))
|
2016-12-20 05:16:05 -05:00
|
|
|
add_executable(osrm-extract-conditionals src/tools/extract-conditionals.cpp $<TARGET_OBJECTS:UTIL>)
|
|
|
|
target_include_directories(osrm-extract-conditionals PRIVATE ${LIBSHAPEFILE_INCLUDE_DIR})
|
2017-02-27 06:03:57 -05:00
|
|
|
target_link_libraries(osrm-extract-conditionals ${OSMIUM_LIBRARIES} ${BOOST_BASE_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY}
|
|
|
|
${LIBSHAPEFILE_LIBRARY} ${BZIP2_LIBRARIES} ${ZLIB_LIBRARY} ${EXPAT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
2016-12-20 05:16:05 -05:00
|
|
|
install(TARGETS osrm-extract-conditionals DESTINATION bin)
|
|
|
|
endif()
|
2013-12-17 15:42:00 -05:00
|
|
|
endif()
|
2013-12-13 17:26:57 -05:00
|
|
|
|
2016-01-20 06:41:33 -05:00
|
|
|
if (ENABLE_ASSERTIONS)
|
|
|
|
message(STATUS "Enabling assertions")
|
|
|
|
add_definitions(-DBOOST_ENABLE_ASSERT_HANDLER)
|
|
|
|
endif()
|
|
|
|
|
2014-03-22 11:44:51 -04:00
|
|
|
# Add RPATH info to executables so that when they are run after being installed
|
|
|
|
# (i.e., from /usr/local/bin/) the linker can find library dependencies. For
|
|
|
|
# more info see http://www.cmake.org/Wiki/CMake_RPATH_handling
|
|
|
|
set_property(TARGET osrm-extract PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
2017-01-23 05:50:03 -05:00
|
|
|
set_property(TARGET osrm-partition PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
2016-02-14 13:35:37 -05:00
|
|
|
set_property(TARGET osrm-contract PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
2014-03-22 11:44:51 -04:00
|
|
|
set_property(TARGET osrm-datastore PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
set_property(TARGET osrm-routed PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
|
2016-12-01 19:59:29 -05:00
|
|
|
file(GLOB VariantGlob third_party/variant/include/mapbox/*.hpp)
|
2016-01-07 13:19:55 -05:00
|
|
|
file(GLOB LibraryGlob include/osrm/*.hpp)
|
2016-03-10 14:52:27 -05:00
|
|
|
file(GLOB ParametersGlob include/engine/api/*_parameters.hpp)
|
2016-03-08 17:46:14 -05:00
|
|
|
set(EngineHeader include/engine/status.hpp include/engine/engine_config.hpp include/engine/hint.hpp include/engine/bearing.hpp include/engine/phantom_node.hpp)
|
2016-08-31 04:19:25 -04:00
|
|
|
set(UtilHeader include/util/coordinate.hpp include/util/json_container.hpp include/util/typedefs.hpp include/util/strong_typedef.hpp include/util/exception.hpp)
|
2016-02-18 19:00:55 -05:00
|
|
|
set(ExtractorHeader include/extractor/extractor.hpp include/extractor/extractor_config.hpp include/extractor/travel_mode.hpp)
|
2017-02-10 09:01:55 -05:00
|
|
|
set(PartitionerHeader include/partition/partitioner.hpp include/partition/partition_config.hpp)
|
2016-01-07 13:19:55 -05:00
|
|
|
set(ContractorHeader include/contractor/contractor.hpp include/contractor/contractor_config.hpp)
|
2016-03-23 14:19:00 -04:00
|
|
|
set(StorageHeader include/storage/storage.hpp include/storage/storage_config.hpp)
|
2016-01-07 13:19:55 -05:00
|
|
|
install(FILES ${EngineHeader} DESTINATION include/osrm/engine)
|
|
|
|
install(FILES ${UtilHeader} DESTINATION include/osrm/util)
|
2016-03-23 14:19:00 -04:00
|
|
|
install(FILES ${StorageHeader} DESTINATION include/osrm/storage)
|
2016-01-07 13:19:55 -05:00
|
|
|
install(FILES ${ExtractorHeader} DESTINATION include/osrm/extractor)
|
2017-02-10 09:01:55 -05:00
|
|
|
install(FILES ${PartitionerHeader} DESTINATION include/osrm/partition)
|
2016-01-07 13:19:55 -05:00
|
|
|
install(FILES ${ContractorHeader} DESTINATION include/osrm/contractor)
|
|
|
|
install(FILES ${LibraryGlob} DESTINATION include/osrm)
|
2016-02-18 16:42:49 -05:00
|
|
|
install(FILES ${ParametersGlob} DESTINATION include/osrm/engine/api)
|
2016-12-01 19:59:29 -05:00
|
|
|
install(FILES ${VariantGlob} DESTINATION include/mapbox)
|
2013-12-17 11:59:44 -05:00
|
|
|
install(TARGETS osrm-extract DESTINATION bin)
|
2017-02-10 09:01:55 -05:00
|
|
|
install(TARGETS osrm-partition DESTINATION bin)
|
2016-02-14 13:35:37 -05:00
|
|
|
install(TARGETS osrm-contract DESTINATION bin)
|
2013-12-17 11:59:44 -05:00
|
|
|
install(TARGETS osrm-datastore DESTINATION bin)
|
|
|
|
install(TARGETS osrm-routed DESTINATION bin)
|
2016-01-07 13:19:55 -05:00
|
|
|
install(TARGETS osrm DESTINATION lib)
|
|
|
|
install(TARGETS osrm_extract DESTINATION lib)
|
2017-02-10 09:01:55 -05:00
|
|
|
install(TARGETS osrm_partition DESTINATION lib)
|
2017-03-07 18:30:49 -05:00
|
|
|
install(TARGETS osrm_update DESTINATION lib)
|
2016-01-07 13:19:55 -05:00
|
|
|
install(TARGETS osrm_contract DESTINATION lib)
|
|
|
|
install(TARGETS osrm_store DESTINATION lib)
|
|
|
|
|
2017-02-07 11:55:20 -05:00
|
|
|
|
|
|
|
# Install profiles and support library to /usr/local/share/osrm/profiles by default
|
|
|
|
set(DefaultProfilesDir profiles)
|
|
|
|
install(DIRECTORY ${DefaultProfilesDir} DESTINATION share/osrm)
|
|
|
|
|
2016-11-27 09:45:55 -05:00
|
|
|
# Setup exporting variables for pkgconfig and subproject
|
|
|
|
#
|
2013-12-20 14:00:30 -05:00
|
|
|
|
2016-12-30 19:27:21 -05:00
|
|
|
if(BUILD_PACKAGE)
|
|
|
|
include(CPackConfig)
|
2014-08-11 10:16:13 -04:00
|
|
|
include(CPack)
|
|
|
|
endif()
|
2015-09-09 20:18:47 -04:00
|
|
|
|
2016-05-27 11:53:51 -04:00
|
|
|
function(JOIN VALUES GLUE OUTPUT)
|
|
|
|
string (REPLACE ";" "${GLUE}" _TMP_STR "${VALUES}")
|
|
|
|
set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2016-11-27 09:45:55 -05:00
|
|
|
JOIN("${OSRM_DEFINES}" " " TMP_OSRM_DEFINES)
|
|
|
|
set(LibOSRM_CXXFLAGS "${OSRM_CXXFLAGS} ${TMP_OSRM_DEFINES}")
|
2016-11-29 18:15:05 -05:00
|
|
|
set(LibOSRM_LDFLAGS "${OSRM_LDFLAGS}")
|
2016-11-27 09:45:55 -05:00
|
|
|
|
|
|
|
if(BUILD_AS_SUBPROJECT)
|
|
|
|
set(LibOSRM_CXXFLAGS "${LibOSRM_CXXFLAGS}" PARENT_SCOPE)
|
|
|
|
set(LibOSRM_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE)
|
|
|
|
set(LibOSRM_LIBRARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE)
|
|
|
|
set(LibOSRM_LIBRARIES "osrm" PARENT_SCOPE)
|
|
|
|
set(LibOSRM_DEPENDENT_LIBRARIES "${ENGINE_LIBRARIES}" PARENT_SCOPE)
|
|
|
|
set(LibOSRM_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/include/osrm"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/third_party"
|
|
|
|
"${DEPENDENCIES_INCLUDE_DIRS}" PARENT_SCOPE)
|
|
|
|
set(LibOSRM_LIBRARY_DIRS "${LibOSRM_LIBRARY_DIR}" PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# pkgconfig defines
|
|
|
|
set(PKGCONFIG_OSRM_CXXFLAGS "${LibOSRM_CXXFLAGS}")
|
2016-11-29 18:15:05 -05:00
|
|
|
set(PKGCONFIG_OSRM_LDFLAGS "${LibOSRM_LDFLAGS}")
|
2016-11-27 09:45:55 -05:00
|
|
|
set(PKGCONFIG_LIBRARY_DIR "${CMAKE_INSTALL_PREFIX}/lib")
|
|
|
|
set(PKGCONFIG_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include")
|
|
|
|
|
|
|
|
list(APPEND DEPENDENCIES_INCLUDE_DIRS "${PKGCONFIG_INCLUDE_DIR}")
|
|
|
|
list(APPEND DEPENDENCIES_INCLUDE_DIRS "${PKGCONFIG_INCLUDE_DIR}/osrm")
|
|
|
|
JOIN("-I${DEPENDENCIES_INCLUDE_DIRS}" " -I" PKGCONFIG_OSRM_INCLUDE_FLAGS)
|
|
|
|
JOIN("${ENGINE_LIBRARIES}" " " PKGCONFIG_OSRM_DEPENDENT_LIBRARIES)
|
2016-05-27 11:53:51 -04:00
|
|
|
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkgconfig.in libosrm.pc @ONLY)
|
2016-12-30 19:27:21 -05:00
|
|
|
install(FILES ${PROJECT_BINARY_DIR}/libosrm.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
2016-05-27 11:53:51 -04:00
|
|
|
|
2016-03-10 05:53:44 -05:00
|
|
|
# uninstall target
|
|
|
|
configure_file(
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
|
|
|
|
IMMEDIATE @ONLY)
|
|
|
|
|
|
|
|
add_custom_target(uninstall
|
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake)
|
2016-04-06 06:44:46 -04:00
|
|
|
|
|
|
|
|
|
|
|
# Modular build system: each directory registered here provides its own CMakeLists.txt
|
|
|
|
add_subdirectory(unit_tests)
|
2016-04-06 08:29:46 -04:00
|
|
|
add_subdirectory(src/benchmarks)
|
2016-04-12 05:58:43 -04:00
|
|
|
|
|
|
|
if (ENABLE_FUZZING)
|
2016-04-13 03:43:03 -04:00
|
|
|
# Requires libosrm being built with sanitizers; make configurable and default to ubsan
|
|
|
|
set(FUZZ_SANITIZER "undefined" CACHE STRING "Sanitizer to be used for Fuzz testing")
|
|
|
|
set_property(CACHE FUZZ_SANITIZER PROPERTY STRINGS "undefined" "integer" "address" "memory" "thread" "leak")
|
|
|
|
|
2016-04-12 05:58:43 -04:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-coverage=edge,indirect-calls,8bit-counters -fsanitize=address")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
|
2016-11-29 18:15:05 -05:00
|
|
|
set(OSRM_LDFLAGS "${OSRM_LDFLAGS} -fsanitize=address")
|
2016-04-13 03:43:03 -04:00
|
|
|
|
|
|
|
message(STATUS "Using -fsanitize=${FUZZ_SANITIZER} for Fuzz testing")
|
|
|
|
|
2016-04-12 05:58:43 -04:00
|
|
|
add_subdirectory(fuzz)
|
|
|
|
endif ()
|
2016-12-06 10:14:25 -05:00
|
|
|
|
|
|
|
|
|
|
|
## add headers sanity check target that includes all headers independently
|
|
|
|
set(check_headers_dir "${PROJECT_BINARY_DIR}/check-headers")
|
|
|
|
file(GLOB_RECURSE headers_to_check
|
|
|
|
${PROJECT_BINARY_DIR}/*.hpp
|
|
|
|
${PROJECT_SOURCE_DIR}/include/*.hpp)
|
|
|
|
foreach(header ${headers_to_check})
|
|
|
|
get_filename_component(filename ${header} NAME_WE)
|
|
|
|
set(filename "${check_headers_dir}/${filename}.cpp")
|
|
|
|
if (NOT EXISTS ${filename})
|
|
|
|
file(WRITE ${filename} "#include \"${header}\"\n")
|
|
|
|
endif()
|
|
|
|
list(APPEND sources ${filename})
|
|
|
|
endforeach()
|
|
|
|
add_library(check-headers STATIC EXCLUDE_FROM_ALL ${sources})
|
|
|
|
set_target_properties(check-headers PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${check_headers_dir})
|