2015-09-30 08:51:45 -04:00
|
|
|
cmake_minimum_required(VERSION 2.8.8)
|
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()
|
|
|
|
|
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)
|
|
|
|
set(OSRM_VERSION_MINOR 0)
|
|
|
|
set(OSRM_VERSION_PATCH 0)
|
2015-09-11 05:37:02 -04:00
|
|
|
|
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)
|
2013-07-03 07:32:31 -04:00
|
|
|
|
2015-02-25 12:25:03 -05:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
2013-08-10 07:29:24 -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()
|
|
|
|
message(WARNING "Building on a 32 bit system is unsupported")
|
|
|
|
endif()
|
|
|
|
|
2015-02-16 08:18:04 -05:00
|
|
|
if(WIN32 AND MSVC_VERSION LESS 1800)
|
2014-05-23 13:15:51 -04:00
|
|
|
message(FATAL_ERROR "Building with Microsoft compiler needs Visual Studio 2013 or later (Express version works too)")
|
|
|
|
endif()
|
|
|
|
|
2016-02-26 01:34:18 -05:00
|
|
|
option(ENABLE_CCACHE "Speed up incremental rebuilds via ccache" ON)
|
2015-03-22 19:28:38 -04:00
|
|
|
option(ENABLE_JSON_LOGGING "Adds additional JSON debug logging to the response" OFF)
|
2015-02-16 08:18:04 -05:00
|
|
|
option(BUILD_TOOLS "Build OSRM tools" OFF)
|
2016-03-30 16:50:32 -04:00
|
|
|
option(BUILD_COMPONENTS "Build OSRM tools" ON)
|
2016-01-20 06:41:33 -05:00
|
|
|
option(ENABLE_ASSERTIONS OFF)
|
2014-06-03 08:38:33 -04:00
|
|
|
|
2016-01-03 11:03:20 -05:00
|
|
|
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include/)
|
|
|
|
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include/)
|
2015-09-04 11:40:51 -04:00
|
|
|
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/third_party/)
|
2013-12-17 11:59:44 -05:00
|
|
|
|
2015-10-19 04:00:58 -04:00
|
|
|
add_custom_target(FingerPrintConfigure ALL ${CMAKE_COMMAND}
|
|
|
|
"-DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}"
|
|
|
|
"-DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FingerPrint-Config.cmake"
|
2015-03-23 11:14:24 -04:00
|
|
|
COMMENT "Configuring revision fingerprint"
|
2013-07-19 08:38:12 -04:00
|
|
|
VERBATIM)
|
2013-07-03 07:32:31 -04:00
|
|
|
|
2014-07-04 05:44:41 -04:00
|
|
|
add_custom_target(benchmarks DEPENDS rtree-bench)
|
2013-04-22 16:23:53 -04:00
|
|
|
|
2016-04-06 06:44:46 -04:00
|
|
|
set(BOOST_COMPONENTS date_time filesystem iostreams program_options regex system thread)
|
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-01-02 10:11:49 -05:00
|
|
|
file(GLOB UtilGlob src/util/*.cpp)
|
2016-03-01 16:30:31 -05:00
|
|
|
file(GLOB ExtractorGlob src/extractor/*.cpp src/extractor/*/*.cpp)
|
2016-01-02 10:11:49 -05:00
|
|
|
file(GLOB ContractorGlob src/contractor/*.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})
|
|
|
|
add_library(CONTRACTOR OBJECT ${ContractorGlob})
|
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
|
|
|
add_dependencies(UTIL FingerPrintConfigure)
|
|
|
|
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)
|
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>)
|
2016-03-01 16:30:31 -05:00
|
|
|
add_library(osrm_extract $<TARGET_OBJECTS:EXTRACTOR> $<TARGET_OBJECTS:UTIL>)
|
2016-01-07 13:19:55 -05:00
|
|
|
add_library(osrm_contract $<TARGET_OBJECTS:CONTRACTOR> $<TARGET_OBJECTS:UTIL>)
|
|
|
|
add_library(osrm_store $<TARGET_OBJECTS:STORAGE> $<TARGET_OBJECTS:UTIL>)
|
2013-11-14 12:29:56 -05:00
|
|
|
|
2014-07-04 05:44:41 -04:00
|
|
|
# Benchmarks
|
2016-01-07 13:19:55 -05:00
|
|
|
add_executable(rtree-bench EXCLUDE_FROM_ALL src/benchmarks/static_rtree.cpp $<TARGET_OBJECTS:UTIL>)
|
2014-07-04 05:44:41 -04:00
|
|
|
|
2013-04-22 16:23:53 -04:00
|
|
|
# Check the release mode
|
|
|
|
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
|
2013-12-17 15:42:00 -05:00
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
|
|
endif()
|
2013-04-22 16:23:53 -04:00
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
2014-03-13 08:28:58 -04:00
|
|
|
message(STATUS "Configuring OSRM in debug mode")
|
2016-01-20 06:41:33 -05:00
|
|
|
set(ENABLE_ASSERTIONS ON)
|
2015-03-31 06:59:56 -04:00
|
|
|
if(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
2015-09-10 11:04:53 -04:00
|
|
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-inline -fno-omit-frame-pointer")
|
|
|
|
|
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og -ggdb")
|
|
|
|
endif()
|
|
|
|
|
2014-03-13 08:28:58 -04:00
|
|
|
endif()
|
2013-12-17 15:42:00 -05:00
|
|
|
endif()
|
2013-04-22 16:23:53 -04:00
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Release)
|
2014-05-16 09:00:31 -04:00
|
|
|
message(STATUS "Configuring OSRM in release mode")
|
|
|
|
# Check if LTO is available
|
2015-09-04 14:59:53 -04:00
|
|
|
check_cxx_compiler_flag("-flto" LTO_AVAILABLE)
|
2015-02-16 08:18:04 -05:00
|
|
|
if(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")
|
2015-01-29 10:23:04 -05:00
|
|
|
else()
|
|
|
|
message(STATUS "LTO broken")
|
|
|
|
set(CMAKE_CXX_FLAGS "${OLD_CXX_FLAGS}")
|
|
|
|
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)
|
2014-05-16 09:00:31 -04:00
|
|
|
message(STATUS "Using gcc specific binutils for LTO.")
|
|
|
|
set(CMAKE_AR "/usr/bin/gcc-ar")
|
|
|
|
set(CMAKE_RANLIB "/usr/bin/gcc-ranlib")
|
|
|
|
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}")
|
|
|
|
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
|
|
|
|
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")
|
2016-01-29 18:57:17 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wuninitialized -Wunreachable-code -Wstrict-overflow=2 -D_FORTIFY_SOURCE=2 -fPIC -fcolor-diagnostics")
|
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
|
2015-09-30 09:07:19 -04:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wuninitialized -Wunreachable-code -Wstrict-overflow=1 -D_FORTIFY_SOURCE=2 ${COLOR_FLAG} -fPIC")
|
2015-02-16 08:18:04 -05:00
|
|
|
if(WIN32) # using mingw
|
2014-06-11 09:53:37 -04:00
|
|
|
add_definitions(-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()
|
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++
|
2014-05-23 13:15:51 -04:00
|
|
|
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} date_time chrono zlib)
|
2016-03-31 05:29:54 -04:00
|
|
|
add_definitions(-DBOOST_LIB_DIAGNOSTIC)
|
2014-05-23 11:34:15 -04:00
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
|
|
|
add_definitions(-DNOMINMAX) # avoid min and max macros that can break compilation
|
2016-03-31 05:29:54 -04:00
|
|
|
add_definitions(-D_USE_MATH_DEFINES) #needed for M_PI with cmath.h
|
2014-05-23 11:34:15 -04:00
|
|
|
add_definitions(-D_WIN32_WINNT=0x0501)
|
2014-08-28 06:47:57 -04:00
|
|
|
add_definitions(-DXML_STATIC)
|
|
|
|
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")
|
|
|
|
if(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
|
|
|
# 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")
|
|
|
|
else()
|
|
|
|
message(STATUS "Using unknown linker, not setting linker optimizations")
|
|
|
|
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}")
|
|
|
|
|
2014-05-02 04:08:07 -04:00
|
|
|
# Activate C++11
|
2015-03-31 06:35:20 -04:00
|
|
|
if(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
2015-01-29 05:38:03 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ")
|
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)
|
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-01-07 13:19:55 -05:00
|
|
|
set(MAYBE_RT_LIBRARY rt)
|
2013-12-17 15:42:00 -05:00
|
|
|
endif()
|
2013-10-28 09:51:20 -04:00
|
|
|
|
2016-01-06 06:32:19 -05:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/libosmium/cmake")
|
|
|
|
set(OSMIUM_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/libosmium/include")
|
|
|
|
find_package(Osmium REQUIRED COMPONENTS io)
|
|
|
|
include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
|
2016-04-06 06:44:46 -04:00
|
|
|
find_package(Boost 1.49.0 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
2016-03-31 05:29:54 -04:00
|
|
|
if(NOT WIN32)
|
|
|
|
add_definitions(-DBOOST_TEST_DYN_LINK)
|
|
|
|
endif()
|
2016-04-06 06:44:46 -04:00
|
|
|
add_definitions(-DBOOST_SPIRIT_USE_PHOENIX_V3)
|
|
|
|
add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE)
|
|
|
|
# XXX: activate when we're clean of deprecated Boost.FS features
|
|
|
|
# add_definitions(-DBOOST_FILESYSTEM_NO_DEPRECATED)
|
2015-09-04 11:40:51 -04:00
|
|
|
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
|
2013-06-26 19:48:22 -04:00
|
|
|
|
2013-12-17 15:42:00 -05:00
|
|
|
find_package(Threads REQUIRED)
|
2014-06-24 18:22:10 -04:00
|
|
|
|
2014-05-16 07:26:42 -04:00
|
|
|
find_package(TBB REQUIRED)
|
2016-01-07 13:19:55 -05:00
|
|
|
include_directories(SYSTEM ${TBB_INCLUDE_DIR})
|
2014-05-23 13:15:51 -04:00
|
|
|
if(WIN32 AND CMAKE_BUILD_TYPE MATCHES Debug)
|
|
|
|
set(TBB_LIBRARIES ${TBB_DEBUG_LIBRARIES})
|
|
|
|
endif()
|
2014-05-16 07:26:42 -04:00
|
|
|
|
2016-04-06 06:44:46 -04:00
|
|
|
find_package(Luabind REQUIRED)
|
2014-09-18 13:23:40 -04:00
|
|
|
include(check_luabind)
|
2015-09-04 11:40:51 -04:00
|
|
|
include_directories(SYSTEM ${LUABIND_INCLUDE_DIR})
|
2014-06-11 09:53:37 -04:00
|
|
|
|
2016-01-07 13:19:55 -05:00
|
|
|
set(USED_LUA_LIBRARIES ${LUA_LIBRARY})
|
2015-01-29 10:23:04 -05:00
|
|
|
if(LUAJIT_FOUND)
|
2016-01-07 13:19:55 -05:00
|
|
|
set(USED_LUA_LIBRARIES, LUAJIT_LIBRARIES)
|
2013-12-16 11:58:57 -05:00
|
|
|
endif()
|
2015-09-04 11:40:51 -04:00
|
|
|
include_directories(SYSTEM ${LUA_INCLUDE_DIR})
|
2013-11-20 10:22:39 -05:00
|
|
|
|
2014-08-26 11:59:09 -04:00
|
|
|
find_package(EXPAT REQUIRED)
|
2015-09-04 11:40:51 -04:00
|
|
|
include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
|
2013-04-22 16:23:53 -04:00
|
|
|
|
2015-01-29 10:23:04 -05:00
|
|
|
find_package(STXXL REQUIRED)
|
2015-09-04 11:40:51 -04:00
|
|
|
include_directories(SYSTEM ${STXXL_INCLUDE_DIR})
|
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
|
|
|
|
2013-12-17 15:42:00 -05:00
|
|
|
find_package(BZip2 REQUIRED)
|
2015-09-04 11:40:51 -04:00
|
|
|
include_directories(SYSTEM ${BZIP_INCLUDE_DIRS})
|
2013-12-16 17:03:17 -05:00
|
|
|
|
2013-12-17 15:42:00 -05:00
|
|
|
find_package(ZLIB REQUIRED)
|
2015-09-04 11:40:51 -04:00
|
|
|
include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
|
2013-12-16 17:03:17 -05:00
|
|
|
|
2015-03-22 19:28:38 -04:00
|
|
|
if (ENABLE_JSON_LOGGING)
|
|
|
|
message(STATUS "Enabling json logging")
|
|
|
|
add_definitions(-DENABLE_JSON_LOGGING)
|
|
|
|
endif()
|
|
|
|
|
2016-01-07 13:19:55 -05:00
|
|
|
# Binaries
|
|
|
|
target_link_libraries(osrm-datastore osrm_store ${Boost_LIBRARIES})
|
|
|
|
target_link_libraries(osrm-extract osrm_extract ${Boost_LIBRARIES})
|
2016-02-14 13:35:37 -05:00
|
|
|
target_link_libraries(osrm-contract osrm_contract ${Boost_LIBRARIES})
|
2016-01-07 13:19:55 -05:00
|
|
|
target_link_libraries(osrm-routed osrm ${Boost_LIBRARIES} ${OPTIONAL_SOCKET_LIBS} ${ZLIB_LIBRARY})
|
|
|
|
|
|
|
|
set(EXTRACTOR_LIBRARIES
|
|
|
|
${BZIP2_LIBRARIES}
|
|
|
|
${Boost_LIBRARIES}
|
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
|
|
${EXPAT_LIBRARIES}
|
|
|
|
${LUABIND_LIBRARY}
|
|
|
|
${USED_LUA_LIBRARIES}
|
|
|
|
${OSMIUM_LIBRARIES}
|
|
|
|
${STXXL_LIBRARY}
|
|
|
|
${TBB_LIBRARIES}
|
|
|
|
${ZLIB_LIBRARY})
|
|
|
|
set(CONTRACTOR_LIBRARIES
|
|
|
|
${Boost_LIBRARIES}
|
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
|
|
${LUABIND_LIBRARY}
|
|
|
|
${USED_LUA_LIBRARIES}
|
|
|
|
${STXXL_LIBRARY}
|
|
|
|
${TBB_LIBRARIES}
|
|
|
|
${MAYBE_RT_LIBRARY})
|
|
|
|
set(ENGINE_LIBRARIES
|
|
|
|
${Boost_LIBRARIES}
|
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
|
|
${STXXL_LIBRARY}
|
|
|
|
${TBB_LIBRARIES}
|
|
|
|
${MAYBE_RT_LIBRARY})
|
|
|
|
set(STORAGE_LIBRARIES
|
|
|
|
${Boost_LIBRARIES}
|
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
|
|
${TBB_LIBRARIES}
|
|
|
|
${MAYBE_RT_LIBRARY})
|
|
|
|
set(UTIL_LIBRARIES
|
|
|
|
${Boost_LIBRARIES}
|
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
|
|
${STXXL_LIBRARY}
|
|
|
|
${TBB_LIBRARIES})
|
|
|
|
# Libraries
|
|
|
|
target_link_libraries(osrm ${ENGINE_LIBRARIES})
|
|
|
|
target_link_libraries(osrm_contract ${CONTRACTOR_LIBRARIES})
|
|
|
|
target_link_libraries(osrm_extract ${EXTRACTOR_LIBRARIES})
|
|
|
|
target_link_libraries(osrm_store ${STORAGE_LIBRARIES})
|
2016-04-06 06:44:46 -04:00
|
|
|
# Benchmarks
|
2016-01-07 13:19:55 -05:00
|
|
|
target_link_libraries(rtree-bench ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${TBB_LIBRARIES})
|
|
|
|
|
2016-03-30 16:50:32 -04:00
|
|
|
if(BUILD_COMPONENTS)
|
2013-12-17 15:42:00 -05:00
|
|
|
find_package(GDAL)
|
|
|
|
if(GDAL_FOUND)
|
2016-01-07 13:19:55 -05:00
|
|
|
add_executable(osrm-components src/tools/components.cpp $<TARGET_OBJECTS:UTIL>)
|
2014-09-15 05:34:55 -04:00
|
|
|
target_link_libraries(osrm-components ${TBB_LIBRARIES})
|
2015-09-04 11:40:51 -04:00
|
|
|
include_directories(SYSTEM ${GDAL_INCLUDE_DIR})
|
2015-09-10 11:04:53 -04:00
|
|
|
target_link_libraries(osrm-components ${GDAL_LIBRARIES} ${Boost_LIBRARIES})
|
2014-07-11 09:25:26 -04:00
|
|
|
install(TARGETS osrm-components DESTINATION bin)
|
2014-06-25 04:53:03 -04:00
|
|
|
else()
|
2016-01-07 13:19:55 -05:00
|
|
|
message(WARNING "libgdal and/or development headers not found")
|
2013-12-17 15:42:00 -05:00
|
|
|
endif()
|
2016-03-30 16:50:32 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
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>)
|
2014-09-15 05:34:55 -04:00
|
|
|
target_link_libraries(osrm-io-benchmark ${Boost_LIBRARIES})
|
2016-01-02 10:11:49 -05:00
|
|
|
add_executable(osrm-unlock-all src/tools/unlock_all_mutexes.cpp $<TARGET_OBJECTS:UTIL>)
|
2014-09-29 10:59:09 -04:00
|
|
|
target_link_libraries(osrm-unlock-all ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
2014-05-23 08:32:28 -04:00
|
|
|
if(UNIX AND NOT APPLE)
|
2014-05-26 12:36:11 -04:00
|
|
|
target_link_libraries(osrm-unlock-all rt)
|
2014-05-23 08:32:28 -04:00
|
|
|
endif()
|
2016-01-07 13:19:55 -05:00
|
|
|
add_executable(osrm-springclean src/tools/springclean.cpp $<TARGET_OBJECTS:UTIL>)
|
2014-10-10 10:55:24 -04:00
|
|
|
target_link_libraries(osrm-springclean ${Boost_LIBRARIES})
|
2014-07-11 09:25:26 -04:00
|
|
|
|
|
|
|
install(TARGETS osrm-io-benchmark DESTINATION bin)
|
|
|
|
install(TARGETS osrm-unlock-all DESTINATION bin)
|
2014-10-10 10:55:24 -04:00
|
|
|
install(TARGETS osrm-springclean DESTINATION bin)
|
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)
|
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-01-07 13:19:55 -05:00
|
|
|
file(GLOB VariantGlob third_party/variant/*.hpp)
|
|
|
|
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-02-18 19:00:55 -05:00
|
|
|
set(UtilHeader include/util/coordinate.hpp include/util/json_container.hpp include/util/typedefs.hpp include/util/strong_typedef.hpp)
|
|
|
|
set(ExtractorHeader include/extractor/extractor.hpp include/extractor/extractor_config.hpp include/extractor/travel_mode.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)
|
|
|
|
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)
|
2014-11-25 11:06:10 -05:00
|
|
|
install(FILES ${VariantGlob} DESTINATION include/variant)
|
2013-12-17 11:59:44 -05:00
|
|
|
install(TARGETS osrm-extract 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)
|
|
|
|
install(TARGETS osrm_contract DESTINATION lib)
|
|
|
|
install(TARGETS osrm_store DESTINATION lib)
|
|
|
|
|
|
|
|
list(GET ENGINE_LIBRARIES 1 ENGINE_LIBRARY_FIRST)
|
|
|
|
foreach(lib ${ENGINE_LIBRARIES})
|
|
|
|
get_filename_component(ENGINE_LIBRARY_PATH "${ENGINE_LIBRARY_FIRST}" PATH)
|
|
|
|
get_filename_component(ENGINE_LIBRARY_NAME "${lib}" NAME_WE)
|
|
|
|
string(REPLACE "lib" "" ENGINE_LIBRARY_NAME ${ENGINE_LIBRARY_NAME})
|
|
|
|
string(REPLACE "-l" "" ENGINE_LIBRARY_NAME ${ENGINE_LIBRARY_NAME})
|
|
|
|
set(ENGINE_LIBRARY_LISTING "${ENGINE_LIBRARY_LISTING} -L${ENGINE_LIBRARY_PATH} -l${ENGINE_LIBRARY_NAME}")
|
2015-12-15 15:42:32 -05:00
|
|
|
endforeach()
|
2013-12-20 14:00:30 -05:00
|
|
|
|
2015-02-25 12:25:03 -05:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkgconfig.in libosrm.pc @ONLY)
|
2013-12-20 07:13:35 -05:00
|
|
|
install(FILES ${PROJECT_BINARY_DIR}/libosrm.pc DESTINATION lib/pkgconfig)
|
2014-08-11 10:16:13 -04:00
|
|
|
|
|
|
|
if(BUILD_DEBIAN_PACKAGE)
|
|
|
|
include(CPackDebianConfig)
|
|
|
|
include(CPack)
|
|
|
|
endif()
|
2015-09-09 20:18:47 -04:00
|
|
|
|
|
|
|
# add a target to generate API documentation with Doxygen
|
|
|
|
find_package(Doxygen)
|
2015-09-16 11:13:57 -04:00
|
|
|
if(DOXYGEN_FOUND)
|
2015-09-09 20:18:47 -04:00
|
|
|
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
|
|
|
|
)
|
2015-09-10 13:02:05 -04:00
|
|
|
endif()
|
2015-09-30 13:13:46 -04:00
|
|
|
|
|
|
|
# prefix compilation with ccache by default if available and on clang or gcc
|
2016-02-26 01:34:18 -05:00
|
|
|
if(ENABLE_CCACHE AND (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU"))
|
2015-09-30 13:13:46 -04:00
|
|
|
find_program(CCACHE_FOUND ccache)
|
|
|
|
if(CCACHE_FOUND)
|
2016-01-07 09:20:32 -05:00
|
|
|
message(STATUS "Using ccache to speed up incremental builds")
|
2015-09-30 13:13:46 -04:00
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
|
|
|
set(ENV{CCACHE_CPP2} "true")
|
|
|
|
endif()
|
|
|
|
endif()
|
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)
|