Commit 7b2721b4 by Antonio Maiorano

CMake: split out boost into its own CMakeLists

This adds a third_party/boost folder with a CMakeLists.txt. If this folder is added via add_subdirectory, it downloads boost to the binary directory and exposes the Boost::boost target. Bug: b/145758253 Change-Id: I7d4e383630cb84da928cf0622a641e9e0efc2ad8 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43191Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com>
parent 6102276a
......@@ -18,8 +18,6 @@ cmake-build-debug/
!/build
/build/*
# Boost is downloaded and extracted to /third_party
/third_party/boost*
# Ignored files #
*.obj
......
......@@ -218,48 +218,6 @@ if (NOT TARGET libbacktrace)
endif()
endif()
# Boost is downloaded if necessary
# From https://www.boost.org/users/download/
set(BOOST_VER 1.70.0)
set(BOOST_HASH_TARGZ "882b48708d211a5f48e60b0124cf5863c1534cd544ecd0664bb534a4b5d506e9")
set(BOOST_HASH_ZIP "48f379b2e90dd1084429aae87d6bdbde9670139fa7569ee856c8c86dd366039d")
string(REPLACE "." "_" BOOST_VER_FNAME ${BOOST_VER})
set(BOOST_THIRD_PARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/boost_${BOOST_VER_FNAME})
function(DownloadBoost)
if (LINUX)
set(BOOST_EXT "tar.gz")
set(BOOST_HASH ${BOOST_HASH_TARGZ})
else()
set(BOOST_EXT "zip")
set(BOOST_HASH ${BOOST_HASH_ZIP})
endif()
# Note: bintray.com has rate limiting, so use the sourceforge mirror
# set(BOOST_URL https://dl.bintray.com/boostorg/release/${BOOST_VER}/source/boost_${BOOST_VER_FNAME}.${BOOST_EXT})
set(BOOST_URL https://iweb.dl.sourceforge.net/project/boost/boost/${BOOST_VER}/boost_${BOOST_VER_FNAME}.${BOOST_EXT})
if (NOT TARGET Boost::boost)
if(NOT EXISTS ${BOOST_THIRD_PARTY_DIR})
message(WARNING "
third_party/boost is missing.
Downloading and extracting boost:
")
set(BOOST_ARCHIVE ${CMAKE_BINARY_DIR}/temp/boost_archive)
message(STATUS "Downloading ${BOOST_URL} to ${BOOST_ARCHIVE}...")
file(DOWNLOAD ${BOOST_URL} ${BOOST_ARCHIVE} EXPECTED_HASH SHA256=${BOOST_HASH})
message(STATUS "Extracting ${BOOST_ARCHIVE} to ${BOOST_THIRD_PARTY_DIR}...")
execute_process(
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/third_party
COMMAND cmake -E tar xf ${BOOST_ARCHIVE}
)
endif()
endif()
endfunction()
if(SWIFTSHADER_GET_PVR)
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/PowerVR_Examples/.git)
message(WARNING "
......@@ -994,10 +952,7 @@ if(REACTOR_EMIT_DEBUG_INFO)
target_link_libraries(${Reactor} libbacktrace)
endif()
# Download boost and use it
DownloadBoost()
set(BOOST_INCLUDEDIR ${BOOST_THIRD_PARTY_DIR})
find_package(Boost REQUIRED)
add_subdirectory(third_party/boost)
target_link_libraries(${Reactor} Boost::boost)
endif(REACTOR_EMIT_DEBUG_INFO)
......
# Copyright 2020 The SwiftShader Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Boost is downloaded if necessary
# From https://www.boost.org/users/download/
set(BOOST_VER 1.70.0)
set(BOOST_HASH_TARGZ "882b48708d211a5f48e60b0124cf5863c1534cd544ecd0664bb534a4b5d506e9")
set(BOOST_HASH_ZIP "48f379b2e90dd1084429aae87d6bdbde9670139fa7569ee856c8c86dd366039d")
string(REPLACE "." "_" BOOST_VER_FNAME ${BOOST_VER})
set(BOOST_PARENT_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(BOOST_DIR ${BOOST_PARENT_DIR}/boost_${BOOST_VER_FNAME})
function(DownloadBoost)
if (LINUX)
set(BOOST_EXT "tar.gz")
set(BOOST_HASH ${BOOST_HASH_TARGZ})
else()
set(BOOST_EXT "zip")
set(BOOST_HASH ${BOOST_HASH_ZIP})
endif()
# Note: bintray.com has rate limiting, so use the sourceforge mirror
# set(BOOST_URL https://dl.bintray.com/boostorg/release/${BOOST_VER}/source/boost_${BOOST_VER_FNAME}.${BOOST_EXT})
set(BOOST_URL https://iweb.dl.sourceforge.net/project/boost/boost/${BOOST_VER}/boost_${BOOST_VER_FNAME}.${BOOST_EXT})
if (NOT TARGET Boost::boost)
if(NOT EXISTS ${BOOST_DIR})
message(WARNING "
${BOOST_DIR} is missing.
Downloading and extracting boost:
")
set(BOOST_ARCHIVE ${CMAKE_BINARY_DIR}/temp/boost_archive)
message(STATUS "Downloading ${BOOST_URL} to ${BOOST_ARCHIVE}...")
file(DOWNLOAD ${BOOST_URL} ${BOOST_ARCHIVE} EXPECTED_HASH SHA256=${BOOST_HASH})
message(STATUS "Extracting ${BOOST_ARCHIVE} to ${BOOST_DIR}...")
execute_process(
WORKING_DIRECTORY ${BOOST_PARENT_DIR}
COMMAND cmake -E tar xf ${BOOST_ARCHIVE}
)
endif()
endif()
endfunction()
DownloadBoost()
set(BOOST_INCLUDEDIR ${BOOST_DIR})
find_package(Boost REQUIRED)
# Expose Boost::boost target for parent project
add_library(boost INTERFACE)
target_link_libraries(boost INTERFACE
Boost::boost
)
add_library(Boost::boost ALIAS boost)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment