'Is there a way to get rid of the "New Boost version may have incorrect or missing dependencies and imported targets" warning?
I am using CMake and Boost. I am using Boost 1.68.0 and CMake 3.11.0. I cannot upgrade to newer versions of CMake as cotire prevents moc files from being generated on CMake 3.12.0 and onwards. However, this causes the following warning: New Boost version may have incorrect or missing dependencies and imported targets. Everything works fine and it finds the right files, but this warning is rather annoying. Is there a way to disable this warning while keeping the current version of Boost and CMake?
Solution 1:[1]
cmake ... -DBoost_NO_WARN_NEW_VERSIONS=1
Solution 2:[2]
Since you have installed the last version of Boost, if we go at the line which raises this error, we find :
if(NOT Boost_VERSION VERSION_LESS 107100)
message(WARNING "New Boost version may have incorrect or missing dependencies and imported targets")
endif()
It does not change anything, just keep going or downgrade your boost installation.
Solution 3:[3]
To get rid of the warning, you need to check your FindBoost.cmake file present in <your_path>\CMake\share\cmake-3.19\Modules
Open your your command prompt, cd into the above directory, then open the FindBoost.cmake file by typing:
notepad FindBoost.cmake
In the file, you will find an if else statement with the your above stated warning. Inspect it then, from that you can figure out which version of boost will NOT give you the warning, then use that version.
Hope this would help !
Solution 4:[4]
According to this note found in the CMake bug tracker, https://gitlab.kitware.com/cmake/cmake/-/issues/19658#note_620411, it should work to add NO_MODULE or CONFIG or CMAKE_FIND_PACKAGE_PREFER_CONFIG to your find_package(Boost) call to force avoidance of the FindBoost module file.
If your clients are using a newer CMake and also guaranteed to be using a version of boost which is new enough to support cmake finding via config file instead of cmake finding via the FindBoost module file included with CMake, then adding one of those keywords to your find_package call could be a solution.
Solution 5:[5]
Ying Dai's solution is pretty good, and I want to expand a bit on it. After doing a string search in my .cmake files, I found FindBoost.cmake containing those lines:
if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.79.0 AND NOT Boost_NO_WARN_NEW_VERSIONS)
message(WARNING "New Boost version may have incorrect or missing dependencies and imported targets")
endif()
I don't want to change that file, because it might get overridden later, and maybe I still want the warning by default, so the most elegant fix in my opinion is to add set(Boost_NO_WARN_NEW_VERSIONS 1) in the CMakeLists.txt of your project, so mine looks like that at the top:
project("main")
set(CMAKE_CXX_STANDARD 20)
set(Boost_NO_WARN_NEW_VERSIONS 1)
Then even if you use CMake gui, you will not see the warnings anymore.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Paul Roub |
| Solution 2 | Kevin |
| Solution 3 | |
| Solution 4 | DLRdave |
| Solution 5 | Octo Poulos |
