In my project, I use the Boost and CUDA libraries. Previously, I used find_package(Boost)
and find_package(CUDA)
, followed by if(CUDA_FOUND)
and if(Boost_FOUND)
to check if those packages were available.
I recently upgraded to CMake 3.30. According to CMP0167 introduced in CMake 3.30 and CMP0146 from CMake 3.27, it is advised not to use find_package(Boost)
and find_package(CUDA)
directly, as CMake now handles these requirements differently.
How can I check if these requirements are satisfied without setting the policies to OLD?
Currently, I’m considering setting the policies to OLD to suppress warning messages:
if(POLICY CMP0146)
cmake_policy(SET CMP0146 OLD)
endif()
However, I would like to know if there is a better way to check for the presence of these packages without reverting to the old policy settings.
Ali Aghaeifar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.