[build] Build separate omim for osrm-backend, fix variables

This commit is contained in:
Ilya Zverev 2015-10-19 21:05:46 +03:00
parent bc18d672bc
commit 561a870da4
3 changed files with 101 additions and 52 deletions

View file

@ -11,9 +11,10 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(CheckCXXCompilerFlag)
include(FindPackageHandleStandardArgs)
set(OMIM_STORAGE_PATH "../../../storage/")
set(OMIM_DEBUG_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../omim-build-debug/out/debug")
set(OMIM_RELEASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../omim-build-release/out/release")
set(OMIM_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../.." CACHE PATH "Path to the root of omim repository")
set(OMIM_STORAGE_PATH "${OMIM_PATH}/storage/")
set(OMIM_DEBUG_PATH "${OMIM_PATH}/../omim-build-debug/out/debug" CACHE PATH "Path to the debug build of omim")
set(OMIM_RELEASE_PATH "${OMIM_PATH}/../omim-build-release/out/release" CACHE PATH "Path to the release build of omim")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
@ -226,31 +227,39 @@ include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(OSRM ${Boost_LIBRARIES})
target_link_libraries(osrm-extract ${Boost_LIBRARIES})
target_link_libraries(osrm-prepare ${Boost_LIBRARIES})
target_link_libraries(osrm-routed ${Boost_LIBRARIES} ${OPTIONAL_SOCKET_LIBS} OSRM
debug "${OMIM_DEBUG_PATH}/libcoding.a"
"${OMIM_DEBUG_PATH}/libbase.a"
"${OMIM_DEBUG_PATH}/libgeometry.a"
"${OMIM_DEBUG_PATH}/libindexer.a"
"${OMIM_DEBUG_PATH}/libjansson.a"
general "${OMIM_RELEASE_PATH}/libcoding.a"
"${OMIM_RELEASE_PATH}/libgeometry.a"
"${OMIM_RELEASE_PATH}/libindexer.a"
"${OMIM_RELEASE_PATH}/libjansson.a"
"${OMIM_RELEASE_PATH}/libbase.a"
)
target_link_libraries(osrm-datastore ${Boost_LIBRARIES})
target_link_libraries(osrm-mapsme ${Boost_LIBRARIES} OSRM
debug "${OMIM_DEBUG_PATH}/libcoding.a"
"${OMIM_DEBUG_PATH}/libbase.a"
"${OMIM_DEBUG_PATH}/librouting.a"
"${OMIM_DEBUG_PATH}/libgeometry.a"
"${OMIM_DEBUG_PATH}/libindexer.a"
general "${OMIM_RELEASE_PATH}/libcoding.a"
"${OMIM_RELEASE_PATH}/libbase.a"
"${OMIM_RELEASE_PATH}/librouting.a"
"${OMIM_RELEASE_PATH}/libgeometry.a"
"${OMIM_RELEASE_PATH}/libindexer.a")
if(CMAKE_BUILD_TYPE MATCHES Debug)
target_link_libraries(osrm-routed ${Boost_LIBRARIES} ${OPTIONAL_SOCKET_LIBS} OSRM
"${OMIM_DEBUG_PATH}/libcoding.a"
"${OMIM_DEBUG_PATH}/libbase.a"
"${OMIM_DEBUG_PATH}/libgeometry.a"
"${OMIM_DEBUG_PATH}/libindexer.a"
"${OMIM_DEBUG_PATH}/libjansson.a"
)
target_link_libraries(osrm-mapsme ${Boost_LIBRARIES} OSRM
"${OMIM_DEBUG_PATH}/libcoding.a"
"${OMIM_DEBUG_PATH}/libbase.a"
"${OMIM_DEBUG_PATH}/librouting.a"
"${OMIM_DEBUG_PATH}/libgeometry.a"
"${OMIM_DEBUG_PATH}/libindexer.a"
)
else()
target_link_libraries(osrm-routed ${Boost_LIBRARIES} ${OPTIONAL_SOCKET_LIBS} OSRM
"${OMIM_RELEASE_PATH}/libcoding.a"
"${OMIM_RELEASE_PATH}/libgeometry.a"
"${OMIM_RELEASE_PATH}/libindexer.a"
"${OMIM_RELEASE_PATH}/libjansson.a"
"${OMIM_RELEASE_PATH}/libbase.a"
)
target_link_libraries(osrm-mapsme ${Boost_LIBRARIES} OSRM
"${OMIM_RELEASE_PATH}/libcoding.a"
"${OMIM_RELEASE_PATH}/libbase.a"
"${OMIM_RELEASE_PATH}/librouting.a"
"${OMIM_RELEASE_PATH}/libgeometry.a"
"${OMIM_RELEASE_PATH}/libindexer.a"
)
endif()
find_package(Threads REQUIRED)
target_link_libraries(osrm-extract ${CMAKE_THREAD_LIBS_INIT} ${OPTIONAL_OMP_LIB})

View file

@ -28,24 +28,27 @@ win32:CONFIG(drape) {
SUBDIRS = 3party base geometry coding
SUBDIRS += platform
SUBDIRS += stats
SUBDIRS += indexer
SUBDIRS += routing
SUBDIRS += storage
# Integration tests dependencies for gtool
CONFIG(gtool):!CONFIG(no-tests) {
SUBDIRS += search
SUBDIRS += map
SUBDIRS += routing/routing_integration_tests
!CONFIG(osrm) {
SUBDIRS += platform
SUBDIRS += stats
SUBDIRS += storage
# Integration tests dependencies for gtool
CONFIG(gtool):!CONFIG(no-tests) {
SUBDIRS += search
SUBDIRS += map
SUBDIRS += routing/routing_integration_tests
}
CONFIG(desktop) {
SUBDIRS += generator generator/generator_tool
}
}
CONFIG(desktop) {
SUBDIRS += generator generator/generator_tool
}
!CONFIG(gtool) {
!CONFIG(gtool):!CONFIG(osrm) {
SUBDIRS *= anim
SUBDIRS *= graphics
SUBDIRS *= gui

View file

@ -26,7 +26,7 @@ while getopts ":cdro" opt; do
echo -e "-o\tBuild osrm-backend"
echo -e "-c\tClean before building"
echo
echo "By default everything is built. Specify TARGET for omim-* if needed."
echo "By default release is built. Specify TARGET and OSRM_TARGET if needed."
exit 1
;;
esac
@ -34,13 +34,12 @@ done
# By default build everything
if [ -z "$OPT_DEBUG$OPT_RELEASE$OPT_OSRM" ]; then
OPT_DEBUG=1
OPT_RELEASE=1
OPT_OSRM=1
fi
set -x -u -e
OMIM_PATH="$(cd "${OMIM_PATH:-$(dirname "$0")/../..}"; pwd)"
BOOST_PATH="${BOOST_PATH:-/usr/local/boost_1.54.0}"
DEVTOOLSET_PATH=/opt/rh/devtoolset-2
if [ -d "$DEVTOOLSET_PATH" ]; then
@ -48,36 +47,41 @@ if [ -d "$DEVTOOLSET_PATH" ]; then
else
DEVTOOLSET_PATH=
fi
OMIM_PATH="$(cd "${OMIM_PATH:-$(dirname "$0")/../..}"; pwd)"
export MANPATH=""
# Find qmake, prefer qmake-qt5
if [ ! -x "${QMAKE-}" ]; then
QMAKE=qmake-qt5
if ! hash "$QMAKE" 2>/dev/null; then
QMAKE=qmake
fi
fi
# Find cmake, prefer cmake28
if [ ! -x "${CMAKE-}" ]; then
CMAKE=cmake28
if ! hash "$CMAKE" 2>/dev/null; then
CMAKE=cmake
fi
fi
# OS-specific parameters
if [ "$(uname -s)" == "Darwin" ]; then
SPEC=macx-clang
PROCESSES=4
PROCESSES=$(sysctl -n hw.ncpu)
else
SPEC=linux-clang-libc++
PROCESSES=$(nproc)
fi
# Build one configuration into $TARGET or omim-build-{debug,release}
build_conf()
{
CONF=$1
DIRNAME="${TARGET:-$OMIM_PATH/..}/omim-build-$CONF"
DIRNAME="${TARGET:-$OMIM_PATH/../omim-build-$CONF}"
[ -d "$DIRNAME" -a -n "$OPT_CLEAN" ] && rm -r "$DIRNAME"
if [ ! -d "$DIRNAME" ]; then
mkdir "$DIRNAME"
mkdir -p "$DIRNAME"
ln -s "$OMIM_PATH/data" "$DIRNAME/data"
fi
@ -95,18 +99,51 @@ build_conf()
)
}
[ -n "$OPT_DEBUG" ] && build_conf debug
[ -n "$OPT_RELEASE" ] && build_conf release
# Build some omim libraries for osrm backend
build_conf_osrm()
{
CONF=$1
DIRNAME="$2"
mkdir -p "$DIRNAME"
OSPEC="$SPEC"
[ "$OSPEC" == "linux-clang-libc++" ] && OSPEC=linux-clang
if [ -n "$OPT_OSRM" ]; then
(
export BOOST_INCLUDEDIR="$BOOST_PATH/include"
cd "$DIRNAME"
if [ -n "$DEVTOOLSET_PATH" ]; then
"$QMAKE" "$OMIM_PATH/omim.pro" -spec $OSPEC "CONFIG+=$CONF osrm" \
"QMAKE_CXXFLAGS *=--gcc-toolchain=$DEVTOOLSET_PATH/root/usr" \
"QMAKE_LFLAGS *=--gcc-toolchain=$DEVTOOLSET_PATH/root/usr"
else
"$QMAKE" "$OMIM_PATH/omim.pro" -spec $OSPEC "CONFIG+=$CONF osrm"
fi
make -j $PROCESSES
)
}
# Build OSRM Backend
build_osrm()
{
OSRM_OMIM_CONF=$1
# Making the first letter uppercase for CMake
OSRM_CONF="$(echo ${OSRM_OMIM_CONF:0:1} | tr '[a-z]' '[A-Z]')${OSRM_OMIM_CONF:1}"
BACKEND="$OMIM_PATH/3party/osrm/osrm-backend"
OSRM_TARGET="${OSRM_TARGET:-$BACKEND/build}"
[ -d "$OSRM_TARGET" -a -n "$OPT_CLEAN" ] && rm -r "$OSRM_TARGET"
mkdir -p "$OSRM_TARGET"
# First, build omim libraries
build_conf_osrm $OSRM_OMIM_CONF "$OSRM_TARGET/omim-build"
OSRM_OMIM_LIBS="omim-build/out/$OSRM_OMIM_CONF"
(
cd "$OSRM_TARGET"
"$CMAKE" "-DBOOST_ROOT=$BOOST_PATH" "$BACKEND"
"$CMAKE" "-DBOOST_ROOT=$BOOST_PATH" -DCMAKE_BUILD_TYPE=$OSRM_CONF "-DOMIM_DEBUG_PATH=$OSRM_OMIM_LIBS" "-DOMIM_RELEASE_PATH=$OSRM_OMIM_LIBS" "$BACKEND"
make clean
make
)
fi
rm -r "$OSRM_TARGET/$OSRM_OMIM_LIBS"
}
[ -n "$OPT_DEBUG" ] && build_conf debug
[ -n "$OPT_RELEASE" ] && build_conf release
[ -n "$OPT_OSRM" ] && build_osrm release