FindBoost.cmake creates targets even if Boost was not found
Tested with cmake 3.16.2.
When issuing find_package(Boost), FindBoost.cmake creates Boost legacy targets (e.g. Boost::diagnostic_definitions) even if Boost was not found. Here is a minimal example:
cmake_minimum_required(VERSION 3.16)
project(Test)
find_package(Boost)
if(TARGET Boost::diagnostic_definitions)
message(WARNING "Boost::diagnostic_definitions has been created as a target")
endif()
And when I configure without a findable Boost:
$ cmake .
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find Boost (missing: Boost_INCLUDE_DIR)
CMake Warning at CMakeLists.txt:5 (message):
Boost::diagnostic_definitions has been created as a target
-- Configuring done
-- Generating done
-- Build files have been written to:
Edited by Niall Murphy