Policy CMP0021: wrong detection relative path for msvc macro
First of all thank you for the perfect tool.
I have a simple project with compiler specific include directory macro:
project(foo)
#cmake_policy(SET CMP0021 OLD)
add_executable(foo main.cpp)
target_include_directories(foo PRIVATE $<$<CXX_COMPILER_ID:MSVC>:$(VCIDEInstallDir)>)
When I call cmake 3.17.3 to generate solution I get:
-- Configuring done
CMake Warning (dev) in CMakeLists.txt:
Policy CMP0021 is not set: Fatal error on relative paths in
INCLUDE_DIRECTORIES target property. Run "cmake --help-policy CMP0021" for
policy details. Use the cmake_policy command to set the policy and
suppress this warning.
Found relative path while evaluating include directories of "foo":
"$(VCIDEInstallDir)"
When I uncomment policy setting:
#cmake_policy(SET CMP0021 OLD)
I get:
CMake Deprecation Warning at CMakeLists.txt:4 (cmake_policy):
The OLD behavior for policy CMP0021 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
So if you will remove the OLD behaviour in future cmake versions my project could not be generated anymore.
Actually $(VCIDEInstallDir) - is MicroSoft Visual Studio macro, one is not relative path. CMP0021 must skip such definition.
Thanks in advance, Anatoly Shirokov
Edited by Anatoly Shirokov