2013-07-18 08:11:45 -04:00
|
|
|
cmake_minimum_required(VERSION 2.6)
|
2013-04-22 16:23:53 -04:00
|
|
|
project(OSRM)
|
2013-11-13 11:08:27 -05:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
2013-05-12 18:49:14 -04:00
|
|
|
include(FindPackageHandleStandardArgs)
|
2013-07-03 07:32:31 -04:00
|
|
|
|
2013-08-10 07:29:24 -04:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
|
|
|
include(GetGitRevisionDescription)
|
|
|
|
git_describe(GIT_DESCRIPTION)
|
|
|
|
|
2013-07-19 08:38:12 -04:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
2013-07-18 08:11:45 -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()
|
|
|
|
|
2013-12-17 11:59:44 -05:00
|
|
|
include_directories(${CMAKE_SOURCE_DIR}/Library/include)
|
|
|
|
|
2013-07-19 10:58:13 -04:00
|
|
|
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/Util/UUID.cpp UUID.cpp.alwaysbuild
|
2013-08-20 07:17:19 -04:00
|
|
|
COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
|
|
|
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/UUID-Config.cmake
|
2013-07-19 08:38:12 -04:00
|
|
|
DEPENDS
|
2013-07-19 10:36:57 -04:00
|
|
|
${CMAKE_SOURCE_DIR}/Util/UUID.cpp.in
|
2013-07-19 10:58:13 -04:00
|
|
|
${CMAKE_SOURCE_DIR}/cmake/UUID-Config.cmake
|
2013-07-19 08:53:47 -04:00
|
|
|
COMMENT "Configuring UUID.cpp"
|
2013-07-19 08:38:12 -04:00
|
|
|
VERBATIM)
|
2013-07-03 07:32:31 -04:00
|
|
|
|
2013-07-19 10:58:13 -04:00
|
|
|
add_custom_target(UUIDConfigure DEPENDS ${CMAKE_SOURCE_DIR}/Util/UUID.cpp )
|
2013-04-22 16:23:53 -04:00
|
|
|
|
2013-11-14 17:16:26 -05:00
|
|
|
set(BOOST_COMPONENTS filesystem iostreams program_options regex system thread)
|
2013-07-17 08:47:22 -04:00
|
|
|
|
2013-08-10 07:29:24 -04:00
|
|
|
configure_file(Util/GitDescription.cpp.in ${CMAKE_SOURCE_DIR}/Util/GitDescription.cpp)
|
2013-04-22 16:23:53 -04:00
|
|
|
file(GLOB ExtractorGlob Extractor/*.cpp)
|
2013-10-15 12:28:14 -04:00
|
|
|
set(ExtractorSources extractor.cpp ${ExtractorGlob})
|
2013-12-17 11:59:44 -05:00
|
|
|
add_executable(osrm-extract ${ExtractorSources})
|
2013-04-22 16:23:53 -04:00
|
|
|
|
2013-12-17 11:59:44 -05:00
|
|
|
file(GLOB PrepareGlob Contractor/*.cpp DataStructures/HilbertValue.cpp)
|
|
|
|
set(PrepareSources prepare.cpp ${PrepareGlob})
|
|
|
|
add_executable(osrm-prepare ${PrepareSources})
|
2013-04-22 16:23:53 -04:00
|
|
|
|
2013-11-13 18:42:42 -05:00
|
|
|
file(GLOB ServerGlob Server/*.cpp)
|
2013-06-26 19:48:22 -04:00
|
|
|
file(GLOB DescriptorGlob Descriptors/*.cpp)
|
2013-11-22 12:05:41 -05:00
|
|
|
file(GLOB DatastructureGlob DataStructures/SearchEngineData.cpp)
|
2013-12-13 17:26:57 -05:00
|
|
|
file(GLOB CoordinateGlob DataStructures/Coordinate.cpp)
|
2013-11-13 17:32:44 -05:00
|
|
|
file(GLOB AlgorithmGlob Algorithms/*.cpp)
|
2013-11-14 12:29:56 -05:00
|
|
|
file(GLOB HttpGlob Server/Http/*.cpp)
|
2013-06-26 19:48:22 -04:00
|
|
|
file(GLOB LibOSRMGlob Library/*.cpp)
|
|
|
|
|
2013-12-17 11:59:44 -05:00
|
|
|
set(OSRMSources ${LibOSRMGlob} ${DescriptorGlob} ${DatastructureGlob} ${AlgorithmGlob} ${HttpGlob})
|
|
|
|
add_library( COORDLIB STATIC ${CoordinateGlob} )
|
2013-12-16 18:49:35 -05:00
|
|
|
add_library( OSRM SHARED ${OSRMSources} Util/GitDescription.cpp Util/UUID.cpp )
|
2013-10-15 12:28:14 -04:00
|
|
|
add_library( UUID STATIC Util/UUID.cpp )
|
|
|
|
add_library( GITDESCRIPTION STATIC Util/GitDescription.cpp )
|
2013-07-19 08:38:12 -04:00
|
|
|
add_dependencies( UUID UUIDConfigure )
|
2013-10-15 12:28:14 -04:00
|
|
|
add_dependencies( GITDESCRIPTION GIT_DESCRIPTION )
|
2013-06-26 19:48:22 -04:00
|
|
|
|
2013-11-14 12:29:56 -05:00
|
|
|
add_executable(osrm-routed routed.cpp ${ServerGlob})
|
|
|
|
set_target_properties(osrm-routed PROPERTIES COMPILE_FLAGS -DROUTED)
|
2013-12-17 11:59:44 -05:00
|
|
|
add_executable(osrm-datastore datastore.cpp)
|
2013-11-14 12:29:56 -05:00
|
|
|
|
2013-04-22 16:23:53 -04:00
|
|
|
# Check the release mode
|
|
|
|
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
|
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
2013-06-26 19:48:22 -04:00
|
|
|
endif(NOT CMAKE_BUILD_TYPE MATCHES Debug)
|
2013-04-22 16:23:53 -04:00
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
|
|
|
message(STATUS "Configuring OSRM in debug mode")
|
2013-06-26 19:48:22 -04:00
|
|
|
endif(CMAKE_BUILD_TYPE MATCHES Debug)
|
2013-04-22 16:23:53 -04:00
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Release)
|
|
|
|
message(STATUS "Configuring OSRM in release mode")
|
2013-06-26 19:48:22 -04:00
|
|
|
endif(CMAKE_BUILD_TYPE MATCHES Release)
|
2013-04-22 16:23:53 -04:00
|
|
|
|
2013-10-28 09:51:20 -04:00
|
|
|
# Configuring compilers
|
2013-12-16 11:58:57 -05:00
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
2013-04-22 16:23:53 -04:00
|
|
|
# using Clang
|
2013-12-16 06:52:41 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unknown-pragmas -Wno-unneeded-internal-declaration -pedantic -fPIC")
|
2013-04-22 16:23:53 -04:00
|
|
|
message(STATUS "OpenMP parallelization not available using clang++")
|
2013-12-16 11:58:57 -05:00
|
|
|
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
2013-04-22 16:23:53 -04:00
|
|
|
# using GCC
|
2013-12-16 06:52:41 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fopenmp -pedantic -fPIC")
|
2013-12-16 11:58:57 -05:00
|
|
|
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
|
2013-04-22 16:23:53 -04:00
|
|
|
# using Intel C++
|
2013-12-16 06:52:41 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-intel -wd10237 -Wall -openmp -ipo -fPIC")
|
2013-12-16 11:58:57 -05:00
|
|
|
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
2013-04-22 16:23:53 -04:00
|
|
|
# using Visual Studio C++
|
|
|
|
endif()
|
|
|
|
|
2013-10-28 09:51:20 -04:00
|
|
|
# Configuring other platform dependencies
|
2013-04-22 16:23:53 -04:00
|
|
|
if(APPLE)
|
|
|
|
SET(CMAKE_OSX_ARCHITECTURES "x86_64")
|
2013-10-16 05:58:29 -04:00
|
|
|
message(STATUS "Set Architecture to x64 on OS X")
|
2013-10-14 11:21:40 -04:00
|
|
|
EXEC_PROGRAM(uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION)
|
|
|
|
STRING(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
|
2013-12-16 11:58:57 -05:00
|
|
|
if(DARWIN_VERSION GREATER 12)
|
2013-11-04 17:37:25 -05:00
|
|
|
MESSAGE(STATUS "Activating -std=c++11 flag for >= OS X 10.9")
|
2013-11-13 11:08:27 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
|
2013-12-16 11:58:57 -05:00
|
|
|
endif(DARWIN_VERSION GREATER 12)
|
2013-04-22 16:23:53 -04:00
|
|
|
endif()
|
|
|
|
|
2013-10-28 09:51:20 -04:00
|
|
|
if(UNIX AND NOT APPLE)
|
2013-10-30 11:35:23 -04:00
|
|
|
target_link_libraries( osrm-datastore rt )
|
|
|
|
target_link_libraries( OSRM rt )
|
2013-10-28 09:51:20 -04:00
|
|
|
endif(UNIX AND NOT APPLE)
|
|
|
|
|
2013-04-22 16:23:53 -04:00
|
|
|
#Check Boost
|
2013-12-16 05:21:30 -05:00
|
|
|
set(BOOST_MIN_VERSION "1.46.0")
|
2013-04-22 16:23:53 -04:00
|
|
|
find_package( Boost ${BOOST_MIN_VERSION} COMPONENTS ${BOOST_COMPONENTS} REQUIRED )
|
2013-12-16 11:58:57 -05:00
|
|
|
if(NOT Boost_FOUND)
|
2013-12-16 05:21:30 -05:00
|
|
|
message(FATAL_ERROR "Fatal error: Boost (version >= 1.46.0) required.\n")
|
2013-12-16 11:58:57 -05:00
|
|
|
endif(NOT Boost_FOUND)
|
2013-05-14 23:09:18 -04:00
|
|
|
include_directories(${Boost_INCLUDE_DIRS})
|
2013-06-26 19:48:22 -04:00
|
|
|
|
2013-12-17 11:59:44 -05:00
|
|
|
target_link_libraries(OSRM ${Boost_LIBRARIES} COORDLIB)
|
|
|
|
target_link_libraries(osrm-extract ${Boost_LIBRARIES} UUID GITDESCRIPTION COORDLIB)
|
|
|
|
target_link_libraries(osrm-prepare ${Boost_LIBRARIES} UUID GITDESCRIPTION COORDLIB)
|
|
|
|
target_link_libraries(osrm-routed ${Boost_LIBRARIES} OSRM UUID GITDESCRIPTION)
|
|
|
|
target_link_libraries(osrm-datastore ${Boost_LIBRARIES} UUID GITDESCRIPTION COORDLIB)
|
2013-04-22 16:23:53 -04:00
|
|
|
|
|
|
|
find_package( Threads REQUIRED )
|
2013-12-16 11:25:17 -05:00
|
|
|
target_link_libraries (osrm-extract ${CMAKE_THREAD_LIBS_INIT})
|
2013-04-22 16:23:53 -04:00
|
|
|
|
2013-11-20 10:22:39 -05:00
|
|
|
find_package( Lua52 )
|
2013-12-16 11:58:57 -05:00
|
|
|
if( NOT LUA52_FOUND )
|
2013-11-20 10:22:39 -05:00
|
|
|
find_package( Lua51 REQUIRED )
|
2013-12-16 11:58:57 -05:00
|
|
|
if(NOT APPLE)
|
2013-11-20 10:22:39 -05:00
|
|
|
find_package( LuaJIT 5.1 )
|
2013-12-16 11:58:57 -05:00
|
|
|
endif( NOT APPLE )
|
|
|
|
else( NOT LUA52_FOUND )
|
|
|
|
if(NOT APPLE)
|
2013-11-20 10:22:39 -05:00
|
|
|
find_package( LuaJIT 5.2 )
|
2013-12-16 11:58:57 -05:00
|
|
|
endif(NOT APPLE)
|
|
|
|
endif( NOT LUA52_FOUND )
|
2013-11-20 10:22:39 -05:00
|
|
|
|
2013-12-16 11:58:57 -05:00
|
|
|
if( LUAJIT_FOUND )
|
2013-11-20 10:22:39 -05:00
|
|
|
target_link_libraries( osrm-extract ${LUAJIT_LIBRARIES} )
|
|
|
|
target_link_libraries( osrm-prepare ${LUAJIT_LIBRARIES} )
|
2013-12-16 11:58:57 -05:00
|
|
|
else()
|
2013-11-20 10:22:39 -05:00
|
|
|
target_link_libraries( osrm-extract ${LUA_LIBRARY} )
|
|
|
|
target_link_libraries( osrm-prepare ${LUA_LIBRARY} )
|
2013-12-16 11:58:57 -05:00
|
|
|
endif()
|
2013-11-20 10:22:39 -05:00
|
|
|
include_directories(${LUA_INCLUDE_DIR})
|
|
|
|
|
2013-04-22 16:23:53 -04:00
|
|
|
find_package( LibXml2 REQUIRED )
|
|
|
|
include_directories(${LIBXML2_INCLUDE_DIR})
|
|
|
|
target_link_libraries (osrm-extract ${LIBXML2_LIBRARIES})
|
|
|
|
|
|
|
|
find_package( Luabind REQUIRED )
|
|
|
|
include_directories(${LUABIND_INCLUDE_DIR})
|
|
|
|
target_link_libraries (osrm-extract ${LUABIND_LIBRARY})
|
|
|
|
target_link_libraries (osrm-prepare ${LUABIND_LIBRARY})
|
|
|
|
|
|
|
|
find_package( STXXL REQUIRED )
|
|
|
|
include_directories(${STXXL_INCLUDE_DIR})
|
2013-07-18 08:11:45 -04:00
|
|
|
target_link_libraries (OSRM ${STXXL_LIBRARY})
|
2013-04-22 16:23:53 -04:00
|
|
|
target_link_libraries (osrm-extract ${STXXL_LIBRARY})
|
|
|
|
target_link_libraries (osrm-prepare ${STXXL_LIBRARY})
|
|
|
|
|
|
|
|
find_package( OSMPBF REQUIRED )
|
|
|
|
include_directories(${OSMPBF_INCLUDE_DIR})
|
|
|
|
target_link_libraries (osrm-extract ${OSMPBF_LIBRARY})
|
|
|
|
target_link_libraries (osrm-prepare ${OSMPBF_LIBRARY})
|
|
|
|
|
2013-12-16 17:03:17 -05:00
|
|
|
find_package( Protobuf REQUIRED )
|
|
|
|
include_directories(${PROTOBUF_INCLUDE_DIRS})
|
|
|
|
target_link_libraries (osrm-extract ${PROTOBUF_LIBRARY})
|
|
|
|
target_link_libraries (osrm-prepare ${PROTOBUF_LIBRARY})
|
|
|
|
|
|
|
|
find_package ( BZip2 REQUIRED )
|
|
|
|
include_directories(${BZIP_INCLUDE_DIRS})
|
|
|
|
target_link_libraries (osrm-extract ${BZIP2_LIBRARIES})
|
|
|
|
|
|
|
|
find_package( ZLIB REQUIRED )
|
|
|
|
include_directories(${ZLIB_INCLUDE_DIRS})
|
|
|
|
target_link_libraries (osrm-extract ${ZLIB_LIBRARY})
|
|
|
|
target_link_libraries (osrm-routed ${ZLIB_LIBRARY})
|
|
|
|
|
2013-04-22 16:23:53 -04:00
|
|
|
if(WITH_TOOLS)
|
2013-10-16 05:58:29 -04:00
|
|
|
message(STATUS "Activating OSRM internal tools")
|
2013-04-22 16:23:53 -04:00
|
|
|
find_package( GDAL )
|
|
|
|
if(GDAL_FOUND)
|
|
|
|
add_executable(osrm-components Tools/componentAnalysis.cpp)
|
|
|
|
include_directories(${GDAL_INCLUDE_DIR})
|
2013-07-22 11:54:04 -04:00
|
|
|
target_link_libraries(
|
2013-12-17 11:59:44 -05:00
|
|
|
osrm-components ${GDAL_LIBRARIES} ${Boost_LIBRARIES} UUID GITDESCRIPTION COORDLIB
|
2013-07-22 11:54:04 -04:00
|
|
|
)
|
2013-04-22 16:23:53 -04:00
|
|
|
endif(GDAL_FOUND)
|
2013-10-15 12:28:14 -04:00
|
|
|
add_executable ( osrm-cli Tools/simpleclient.cpp)
|
2013-12-13 17:26:57 -05:00
|
|
|
target_link_libraries( osrm-cli ${Boost_LIBRARIES} OSRM UUID GITDESCRIPTION)
|
2013-09-04 06:30:16 -04:00
|
|
|
add_executable ( osrm-io-benchmark Tools/io-benchmark.cpp )
|
2013-10-21 06:01:19 -04:00
|
|
|
target_link_libraries( osrm-io-benchmark ${Boost_LIBRARIES} GITDESCRIPTION)
|
2013-10-30 08:01:49 -04:00
|
|
|
add_executable ( osrm-unlock-all Tools/unlock_all_mutexes.cpp )
|
|
|
|
target_link_libraries( osrm-unlock-all ${Boost_LIBRARIES} GITDESCRIPTION)
|
2013-10-30 11:33:16 -04:00
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
|
target_link_libraries( osrm-unlock-all rt )
|
|
|
|
endif(UNIX AND NOT APPLE)
|
2013-04-22 16:23:53 -04:00
|
|
|
endif(WITH_TOOLS)
|
2013-12-13 17:26:57 -05:00
|
|
|
|
2013-12-17 14:26:15 -05:00
|
|
|
file(GLOB InstallGlob Library/include/*.h Library/OSRM.h)
|
2013-12-17 11:59:44 -05:00
|
|
|
|
2013-12-17 14:26:15 -05:00
|
|
|
install(FILES ${InstallGlob} DESTINATION include/osrm)
|
2013-12-17 11:59:44 -05:00
|
|
|
install(TARGETS osrm-extract DESTINATION bin)
|
|
|
|
install(TARGETS osrm-prepare DESTINATION bin)
|
|
|
|
install(TARGETS osrm-datastore DESTINATION bin)
|
|
|
|
install(TARGETS osrm-routed DESTINATION bin)
|
|
|
|
install(TARGETS OSRM DESTINATION lib)
|