From 65331599ecbbb9ba4546897d967036b7feebaf08 Mon Sep 17 00:00:00 2001 From: Mykola Orliuk Date: Sat, 5 Oct 2019 18:43:50 +0200 Subject: [PATCH] BoostTestTargets.cmake: support CMake 3.15 Signed-off-by: James Turner --- CMakeLists.txt | 3 +++ CMakeModules/BoostTestTargets.cmake | 16 +++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 705b610d..1bc7b920 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,9 @@ if(COMMAND cmake_policy) if(POLICY CMP0067) cmake_policy(SET CMP0067 NEW) endif() + if(POLICY CMP0093) + cmake_policy(SET CMP0093 NEW) + endif() endif() diff --git a/CMakeModules/BoostTestTargets.cmake b/CMakeModules/BoostTestTargets.cmake index 580bf9d2..f1bd0f99 100644 --- a/CMakeModules/BoostTestTargets.cmake +++ b/CMakeModules/BoostTestTargets.cmake @@ -46,11 +46,17 @@ set(BOOST_TEST_TARGET_PREFIX "test") if(NOT Boost_FOUND) find_package(Boost 1.34.0 QUIET) endif() -if("${Boost_VERSION}0" LESS "1034000") + +if (NOT Boost_VERSION_MACRO) + # Compatibility with pre CMP0093 (CMake 3.15) + set(Boost_VERSION_MACRO ${Boost_VERSION}) +endif() + +if("${Boost_VERSION_MACRO}0" LESS "1034000") set(_shared_msg "NOTE: boost::test-based targets and tests cannot " "be added: boost >= 1.34.0 required but not found. " - "(found: '${Boost_VERSION}'; want >=103400) ") + "(found: '${Boost_VERSION_MACRO}'; want >=103400) ") if(ENABLE_TESTS) message(FATAL_ERROR ${_shared_msg} @@ -66,7 +72,7 @@ endif() include(GetForceIncludeDefinitions) include(CopyResourcesToBuildTree) -if(Boost_FOUND AND NOT "${Boost_VERSION}0" LESS "1034000") +if(Boost_FOUND AND NOT "${Boost_VERSION_MACRO}0" LESS "1034000") set(_boosttesttargets_libs) set(_boostConfig "BoostTestTargetsIncluded.h") if(NOT Boost_UNIT_TEST_FRAMEWORK_LIBRARY) @@ -129,7 +135,7 @@ function(add_boost_test _name) "Syntax error in use of add_boost_test: at least one source file required!") endif() - if(Boost_FOUND AND NOT "${Boost_VERSION}0" LESS "1034000") + if(Boost_FOUND AND NOT "${Boost_VERSION_MACRO}0" LESS "1034000") include_directories(${Boost_INCLUDE_DIRS}) @@ -221,7 +227,7 @@ function(add_boost_test _name) set(_test_command ${_target_name}) endif() - if(TESTS AND ( "${Boost_VERSION}" VERSION_GREATER "103799" )) + if(TESTS AND ( "${Boost_VERSION_MACRO}" VERSION_GREATER "103799" )) foreach(_test ${TESTS}) add_test( ${_name}-${_test}