This is an archive of the discontinued LLVM Phabricator instance.

cmake: Introduce TEST_SUITE_C_FLAGS, TEST_SUITE_CXX_FLAGS, etc.
AbandonedPublic

Authored by MatzeB on May 3 2016, 6:10 PM.

Details

Summary

Intuitively one would use CMAKE_C_FLAGS, CMAKE_CXX_FLAGS and
CMAKE_EXE_LINKER_FLAGS to inject custom flags into the build. However
this clashes with the use of cmake cache files which want to add flags as well.
A user specifying CMAKE_C_FLAGS would (accidentally) override the flags set by the cache files.

The solution here is to introduce a new set of flags called
TEST_SUITE_C_FLAGS, TEST_SUITE_CXX_FLAGS and TEST_SUITE_EXE_LINKER_FLAGS
as a means for users to specify additional flags. This way the flags
will not override the settings from the cache file.

In order to educate users to use the new flags a warning message is
displayed if CMAKE_C_FLAGS is set.

Diff Detail

Repository
rL LLVM

Event Timeline

MatzeB updated this revision to Diff 56084.May 3 2016, 6:10 PM
MatzeB retitled this revision from to cmake: Introduce TEST_SUITE_C_FLAGS, TEST_SUITE_CXX_FLAGS, etc..
MatzeB updated this object.
MatzeB set the repository for this revision to rL LLVM.
MatzeB added a subscriber: llvm-commits.
MatzeB added a comment.May 3 2016, 6:18 PM

Some additional comments:

The goal of this is to enable things like:

cmake -GNinja -C $TESTSUITE/cmake/caches/target-arm64-iphoneos.cmake -DTEST_SUITE_C_FLAGS="-save-temps=obj" $TESTSUITE

with all the strange flags necessary for cross compilation hidden in the target-arm64-iphoneos.cmake file, while it is still being able to inject extra C flags into the build. Using -DCMAKE_C_FLAGS="-save-temps=obj" would override all the settings done in the cache file.

  • I am putting this out for review because lnt should be aware of the new flags. (Though in the meantime using CMAKE_C_FLAGS continues to work but gives you a warning message).
  • I tried to use new flag names in the cache files instead of forcing new names on the cmake users. However this did not work out: In all my attempts appending the custom flags to CMAKE_C_FLAGS happens too late in the cmake processing and various cmake environment/configuration checks would fail without the cache files target flags being in effect. Setting the crosscompilation flags early enough is essential for those to work so we need to set CMAKE_C_FLAGS in the cache files.
MatzeB abandoned this revision.May 3 2016, 8:02 PM

Abandoning this. After some experimentation and discussion with Justin, I believe that I can solve this by other means so the cache files can set their flags in a way that users don't accidentaly override them when setting CMAKE_C_FLAGS.