Skip to content

Resolve CMake policy CMP0071 OLD warning

SlowRiot requested to merge SlowRiot/bitcoin-cash-node:cmake_cmp0071 into master

As per issue #371 (closed), newer versions of CMake produce a warning during generation:

CMake Deprecation Warning at src/qt/CMakeLists.txt:6 (cmake_policy): The OLD behavior for policy CMP0071 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.

CMP0071's OLD behaviour was to ignore generated files when processing with AUTOMOC and AUTOUIC. This directive was used by the Qt CMakeLists, presumably as Qt relies on AUTOMOC.

Having investigated, in fact there are no generated files that are affected by this directive, and its absence does not cause any change to the build (evidence in test plan).

Therefore this MR simply removes the policy definition, and hence resolves the warning.

Test plan

Create two build directories, before and after this MR, to compare results:

git checkout master
mkdir build
cd build
cmake -GNinja ..
ninja
git mreq upstream 1547
mkdir build2
cd build2
cmake -GNinja ..
ninja

Compare lists of AUTOMOC generated files in both targets:

find build2/ -name "moc_*" | tee build_moc_list.txt
find build2/ -name "moc_*" | tee build2_moc_list.txt
sed -i 's/^build2/build/' build2_moc_list.txt    # replace "build2" with "build" for diff
diff build_moc_list.txt build2_moc_list.txt

Verify that the lists are identical.

Compare the contents of each file:

for file in $(cat build2_moc_list.txt); do file2=$(sed 's/^build/build2/' <<< "$file"); diff $file $file2 && echo "$(basename $file) identical" || echo "$(basename $file) differences found!"; done

Visually verify that the full list of moc generated files has been checked, and that no differences have been found.

Run bitcoin-qt from both build dirs and verify everything looks normal.

build/src/qt/bitcoin-qt
build2/src/qt/bitcoin-qt
Edited by SlowRiot

Merge request reports