FindBoost: Define Boost::boost for all boost versions

This commit is contained in:
Roger Leigh 2016-04-17 16:24:51 +01:00
parent 7d4c99a957
commit 2c1b720e64
5 changed files with 32 additions and 2 deletions

View File

@ -1573,7 +1573,7 @@ endif()
# Add imported targets
# ------------------------------------------------------------------------
if(Boost_FOUND AND _Boost_IMPORTED_TARGETS)
if(Boost_FOUND)
# For header-only libraries
if(NOT TARGET Boost::boost)
add_library(Boost::boost INTERFACE IMPORTED)
@ -1584,7 +1584,7 @@ if(Boost_FOUND AND _Boost_IMPORTED_TARGETS)
endif()
foreach(COMPONENT ${Boost_FIND_COMPONENTS})
if(NOT TARGET Boost::${COMPONENT})
if(_Boost_IMPORTED_TARGETS AND NOT TARGET Boost::${COMPONENT})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
if(Boost_${UPPERCOMPONENT}_FOUND)
if(Boost_USE_STATIC_LIBS)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 496 B

After

Width:  |  Height:  |  Size: 472 B

View File

@ -8,3 +8,14 @@ add_test(NAME FindBoost.Test COMMAND
--build-options ${build_options}
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
add_test(NAME FindBoost.TestHeaders COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindBoost/TestHeaders"
"${CMake_BINARY_DIR}/Tests/FindBoost/TestHeaders"
${build_generator_args}
--build-project TestFindBoostHeaders
--build-options ${build_options}
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(TestFindBoostHeaders CXX)
include(CTest)
find_package(Boost REQUIRED)
add_executable(test_boost_headers_tgt main.cxx)
target_link_libraries(test_boost_headers_tgt
Boost::boost)
add_test(NAME test_boost_headers_tgt COMMAND test_boost_headers_tgt)

View File

@ -0,0 +1,9 @@
#include <boost/any.hpp>
int main() {
boost::any a;
a = 5;
a = std::string("A string");
return 0;
}