Define imported targets manually, if not provided by find_package(Boost).

This commit is contained in:
Daniel Kirchner 2019-06-06 19:20:31 +02:00
parent 2ec45797b2
commit cb9c35f883
3 changed files with 11 additions and 4 deletions

View File

@ -28,9 +28,16 @@ set(BOOST_COMPONENTS "regex;filesystem;unit_test_framework;program_options;syste
find_package(Boost 1.65.0 QUIET REQUIRED COMPONENTS ${BOOST_COMPONENTS})
# make sure we actually get all required imported targets for boost
list(APPEND BOOST_COMPONENTS "boost") # header only target
if (NOT TARGET Boost::boost) # header only target
add_library(Boost::boost INTERFACE IMPORTED)
target_include_directories(Boost::boost INTERFACE ${Boost_INCLUDE_DIRS})
endif()
foreach (BOOST_COMPONENT IN LISTS BOOST_COMPONENTS)
if (NOT TARGET Boost::${BOOST_COMPONENT})
message(FATAL_ERROR "Boost target Boost::${BOOST_COMPONENT} was not defined by cmake.")
add_library(Boost::${BOOST_COMPONENT} UNKNOWN IMPORTED)
string(TOUPPER ${BOOST_COMPONENT} BOOST_COMPONENT_UPPER)
set_property(TARGET Boost::${BOOST_COMPONENT} PROPERTY IMPORTED_LOCATION ${Boost_${BOOST_COMPONENT_UPPER}_LIBRARY})
set_property(TARGET Boost::${BOOST_COMPONENT} PROPERTY INTERFACE_LINK_LIBRARIES ${Boost_${BOOST_COMPONENT_UPPER}_LIBRARIES})
set_property(TARGET Boost::${BOOST_COMPONENT} PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS})
endif()
endforeach()

View File

@ -64,7 +64,7 @@ fi
# Boost
echo -en 'travis_fold:start:compiling_boost\\r'
test -e "$WORKSPACE"/boost_1_70_0_install || (
test -e "$WORKSPACE"/boost_1_70_0_install/include/boost/version.hpp || (
cd "$WORKSPACE"/boost_1_70_0
./b2 toolset=emscripten link=static variant=release threading=single runtime-link=static \
--with-system --with-regex --with-filesystem --with-test --with-program_options cxxflags="-Wno-unused-local-typedef -Wno-variadic-macros -Wno-c99-extensions -Wno-all" \

View File

@ -30,7 +30,7 @@
set -ev
echo -en 'travis_fold:start:installing_dependencies\\r'
test -e boost_1_70_0_install || (
test -e boost_1_70_0_install/include/boost/version.hpp || (
rm -rf boost_1_70_0
rm -f boost.tar.gz
wget -q 'https://sourceforge.net/projects/boost/files/boost/1.70.0/boost_1_70_0.tar.gz/download'\