This is an archive of the discontinued LLVM Phabricator instance.

Explicitly set CMake policy CMP0068 to NEW to avoid warnings
AbandonedPublic

Authored by amadio on Nov 7 2017, 12:19 AM.

Details

Summary

This change is to avoid warnings from CMake 3.9.3 and newer on macOS.
See cmake --help-policy CMP0068 for more information.

Diff Detail

Event Timeline

amadio created this revision.Nov 7 2017, 12:19 AM

Adding people that could review.

smeenai edited edge metadata.Nov 7 2017, 9:33 AM

This seems fine as far as avoiding the warnings themselves go, but I'm not familiar enough with install_name and rpath on macOS to know if the new policy behavior is doing the right thing.

Looking at the list in https://cmake.org/cmake/help/v3.9/policy/CMP0068.html, the only affected property that's used by LLVM is BUILD_WITH_INSTALL_RPATH. The documentation suggests that BUILD_WITH_INSTALL_NAME_DIR should be set in addition to BUILD_WITH_INSTALL_RPATH to simulate the OLD behavior of CMP0068, which seems to be the safer route. Again, I'm not sure how important the old behavior is though; @beanz is the right person for that.

beanz edited edge metadata.Nov 27 2017, 10:34 AM

If we're setting the policy to NEW we should also be setting BUILD_WITH_INSTALL_NAME_DIR to match BUILD_WITH_INSTALL_RPATH, otherwise we're making builds using CMake 3.9 and later build differently than earlier versions of CMake which is undesirable.

Actually, I do not see the warning anymore in our builds, so maybe this patch is no longer necessary. Please feel free to discard it.

Actually, I do not see the warning anymore in our builds, so maybe this patch is no longer necessary. Please feel free to discard it.

FYI, I'm still seeing this warning for libclang and LTO libs in normal builds, and all libs when setting BUILD_SHARED_LIBS=ON.

amadio abandoned this revision.Nov 28 2018, 5:19 AM

Abandoning, equivalent change added by commit below:

commit b4cbf181f050dbe7cf1cfc4b174b856fe936a243
Author: Don Hinton <hintonda@gmail.com>
Date:   Thu Jan 25 04:55:18 2018 +0000

    [cmake] Set cmake policy CMP0068 to suppress warnings on OSX
    
    Set cmake policy CMP0068=NEW, if available, and set
    "CMAKE_BUILD_WITH_INSTALL_NAME_DIR=On" globally to
    maintain current behavior.
    
    This is needed to suppress warnings on OSX starting with cmake version
    3.9.6.
    
    Differential Revision: https://reviews.llvm.org/D42463
    
    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323404 91177308-0d34-0410-b5e6-96231b3b80d8