Skip to content

Commit

Permalink
Added ability to specify a root dir for boost and curl with cmake.
Browse files Browse the repository at this point in the history
This closes #361
  • Loading branch information
akornatskyy authored and greggomann committed May 11, 2020
1 parent 630dbf7 commit 07cd355
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 22 deletions.
61 changes: 39 additions & 22 deletions 3rdparty/CMakeLists.txt
Expand Up @@ -194,29 +194,34 @@ endfunction()
# Boost: C++ Libraries.
# http://www.boost.org
#######################
EXTERNAL(boost ${BOOST_VERSION} ${CMAKE_CURRENT_BINARY_DIR})
add_library(boost INTERFACE)
add_dependencies(boost ${BOOST_TARGET})
if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
# Headers including Boost 1.65.0 fail to compile with GCC 7.2 and
# CLang 3.6 without `-Wno-unused-local-typedefs`.
# TODO(andschwa): Remove this when Boost has a resolution.
target_compile_options(boost INTERFACE -Wno-unused-local-typedefs)
endif ()
target_include_directories(boost INTERFACE ${BOOST_ROOT})
if ("${BOOST_ROOT_DIR}" STREQUAL "")
EXTERNAL(boost ${BOOST_VERSION} ${CMAKE_CURRENT_BINARY_DIR})
add_library(boost INTERFACE)
add_dependencies(boost ${BOOST_TARGET})
if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
# Headers including Boost 1.65.0 fail to compile with GCC 7.2 and
# CLang 3.6 without `-Wno-unused-local-typedefs`.
# TODO(andschwa): Remove this when Boost has a resolution.
target_compile_options(boost INTERFACE -Wno-unused-local-typedefs)
endif ()
target_include_directories(boost INTERFACE ${BOOST_ROOT})

# Patch Boost to avoid repeated "Unknown compiler warnings" on Windows.
PATCH_CMD(BOOST_PATCH_CMD boost-${BOOST_VERSION}.patch)
# Patch Boost to avoid repeated "Unknown compiler warnings" on Windows.
PATCH_CMD(BOOST_PATCH_CMD boost-${BOOST_VERSION}.patch)

ExternalProject_Add(
${BOOST_TARGET}
PREFIX ${BOOST_CMAKE_ROOT}
PATCH_COMMAND ${BOOST_PATCH_CMD}
CONFIGURE_COMMAND ${CMAKE_NOOP}
BUILD_COMMAND ${CMAKE_NOOP}
INSTALL_COMMAND ${CMAKE_NOOP}
URL ${BOOST_URL}
URL_HASH ${BOOST_HASH})
ExternalProject_Add(
${BOOST_TARGET}
PREFIX ${BOOST_CMAKE_ROOT}
PATCH_COMMAND ${BOOST_PATCH_CMD}
CONFIGURE_COMMAND ${CMAKE_NOOP}
BUILD_COMMAND ${CMAKE_NOOP}
INSTALL_COMMAND ${CMAKE_NOOP}
URL ${BOOST_URL}
URL_HASH ${BOOST_HASH})
else ()
add_library(boost INTERFACE)
target_include_directories(boost INTERFACE ${BOOST_ROOT_DIR}/include)
endif ()


# moodycamel::ConcurrentQueue: An industrial-strength lock-free queue.
Expand Down Expand Up @@ -861,7 +866,19 @@ if (WIN32)
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:curl> ${CMAKE_BINARY_DIR}/src/curl.exe
DEPENDEES build)
else ()
find_package(CURL REQUIRED)
if ("${CURL_ROOT_DIR}" STREQUAL "")
find_package(CURL REQUIRED)
else ()
set(POSSIBLE_CURL_INCLUDE_DIRS ${CURL_ROOT_DIR}/include)
set(POSSIBLE_CURL_LIB_DIRS ${CURL_ROOT_DIR}/lib)

set(CURL_LIBRARY_NAMES curl)

FIND_PACKAGE_HELPER(CURL curl/curl.h)
SET(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
SET(CURL_LIBRARIES ${CURL_LIBS})
endif ()

add_library(libcurl SHARED IMPORTED)

set_target_properties(
Expand Down
14 changes: 14 additions & 0 deletions cmake/CompilationConfigure.cmake
Expand Up @@ -103,6 +103,20 @@ if (ENABLE_LIBEVENT)
"Specify the path to libevent, e.g. \"C:\\libevent-Win64\".")
endif()

set(
BOOST_ROOT_DIR
""
CACHE STRING
"Specify the path to boost.")

if (NOT WIN32)
set(
CURL_ROOT_DIR
""
CACHE STRING
"Specify the path to libcurl.")
endif()

option(
UNBUNDLED_LEVELDB
"Build with an installed leveldb version instead of the bundled."
Expand Down

0 comments on commit 07cd355

Please sign in to comment.