Skip to content

Commit

Permalink
Added ability to specify a root dir for boost-libs, curl and libseccomp.
Browse files Browse the repository at this point in the history
  • Loading branch information
akornatskyy committed Apr 27, 2020
1 parent 77fa450 commit 9543c0b
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 23 deletions.
72 changes: 49 additions & 23 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 @@ -696,7 +701,16 @@ if (ENABLE_SECCOMP_ISOLATOR)
URL ${LIBSECCOMP_URL}
URL_HASH ${LIBSECCOMP_HASH})
else ()
find_package(LIBSECCOMP REQUIRED)
if ("${LIBSECCOMP_ROOT_DIR}" STREQUAL "")
find_package(LIBSECCOMP REQUIRED)
else ()
set(POSSIBLE_LIBSECCOMP_INCLUDE_DIRS ${LIBSECCOMP_ROOT_DIR}/include)
set(POSSIBLE_LIBSECCOMP_LIB_DIRS ${LIBSECCOMP_ROOT_DIR}/lib)

set(LIBSECCOMP_LIBRARY_NAMES seccomp)

FIND_PACKAGE_HELPER(LIBSECCOMP seccomp.h)
endif ()
add_library(libseccomp SHARED IMPORTED GLOBAL)
set_target_properties(libseccomp PROPERTIES
IMPORTED_LOCATION ${LIBSECCOMP_LIBS}
Expand Down Expand Up @@ -861,7 +875,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 @@ -90,6 +90,20 @@ option(
"Use libevent instead of libev as the core event loop implementation."
FALSE)

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()

if (ENABLE_LIBEVENT)
option(
UNBUNDLED_LIBEVENT
Expand Down

0 comments on commit 9543c0b

Please sign in to comment.