diff --git a/CMakeLists.txt b/CMakeLists.txt index a065c23c5b..c5314a3f0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,24 +138,15 @@ endif() # Find installed packages -find_package(Threads) - -set(Boost_USE_MULTITHREADED ON) - -if (PLATFORM_MAC) - set(Boost_USE_STATIC_LIBS ON) - set(Boost_USE_STATIC_RUNTIME ON) -endif() set(BOOST_VERSION 1.68) -set(BOOST_ROOT "${OMIM_ROOT}/3party/boost") -set(BOOST_INCLUDEDIR "${OMIM_ROOT}/3party/boost") -set(BOOST_BOOST_LIBRARYDIR "${OMIM_ROOT}/3party/boost/stage/lib/") -set(Boost_NO_SYSTEM_PATHS ON) - -set(Boost_INCLUDE_DIR "${BOOST_INCLUDEDIR}") -set(Boost_LIBRARY_DIR "${BOOST_BOOST_LIBRARYDIR}") +set(OMIM_BOOST_SRC "${OMIM_ROOT}/3party/boost") +set(OMIM_BOOST_BINARY_PATH "${CMAKE_BINARY_DIR}/3party/boost/") +set(Boost_INCLUDE_DIR "${OMIM_BOOST_SRC}") +set(Boost_LIBRARY_DIR "${OMIM_BOOST_BINARY_PATH}/lib") set(Boost_USE_STATIC_LIBS ON) +find_package(Threads) +set(Boost_USE_MULTITHREADED ON) init_boost() install_boost_headers() diff --git a/cmake/ExternalBoost.cmake b/cmake/ExternalBoost.cmake index a38fd98434..146aca15f5 100644 --- a/cmake/ExternalBoost.cmake +++ b/cmake/ExternalBoost.cmake @@ -1,24 +1,28 @@ -function(run_bash_command command) - execute_process(COMMAND bash -c ${command} RESULT_VARIABLE ret) +function(run_bash) + cmake_parse_arguments(ARG "" "CMD" "WORKING_DIRECTORY" ${ARGN}) + message("Run ${ARG_CMD} ...") + execute_process(COMMAND bash -c ${ARG_CMD} + WORKING_DIRECTORY ${ARG_WORKING_DIRECTORY} + RESULT_VARIABLE ret) if (NOT (ret EQUAL "0")) - message(FATAL_ERROR "Сommand ${command} failed with code ${ret}.") + message(FATAL_ERROR "Сommand ${ARG_CMD} failed with code ${ret}.") endif() endfunction() function(init_boost) - run_bash_command("cd ${BOOST_ROOT} && ./bootstrap.sh") + run_bash(CMD "./bootstrap.sh" WORKING_DIRECTORY ${OMIM_BOOST_SRC}) endfunction() -function(install_boost option) - run_bash_command("cd ${BOOST_ROOT} && ./b2 ${option}") +function(boost_b2 option) + run_bash(CMD "./b2 ${option}" WORKING_DIRECTORY ${OMIM_BOOST_SRC}) endfunction() function(install_boost_headers) - install_boost("headers") + boost_b2("headers") endfunction() function(link_boost_lib exe library) - install_boost("link=static --with-${library}") + boost_b2("install link=static --with-${library} --prefix=${OMIM_BOOST_BINARY_PATH}") find_package(Boost ${BOOST_VERSION} COMPONENTS ${library} REQUIRED) target_link_libraries(${exe} ${Boost_LIBRARIES}) endfunction()