D16894: [ECM] use a macro to test compiler flag support
René J.V. Bertin
noreply at phabricator.kde.org
Thu Nov 15 12:08:08 GMT 2018
rjvbb created this revision.
rjvbb added a reviewer: Build System.
rjvbb added a project: Build System.
Herald added a project: Frameworks.
Herald added a subscriber: kde-buildsystem.
rjvbb requested review of this revision.
REVISION SUMMARY
It is crucial not to add unsupported compiler options because they can cause CMake's `check_<lang>_compiler_flags` macro to fail, causing problems like https://bugs.kde.org/show_bug.cgi?id=401018.
To prevent this, run an actual test when using clang on Mac.
This is almost unavoidable because determining compiler flag availability from compiler ID + version can be tricky to near impossible on Mac. Apple's llvm version numbers that are ahead of stock llvm versions and not easy to match. In addition, not all cmake versions distinguish between stock clang and "AppleClang" and those that do need policy `CMP0025` set to `NEW`. That policy cannot be set after the `project` statement in the toplevel cmake file (= not in an ECM module).
This patch introduces a set of macros to simplify writing reliable conditional code for adding compiler flags. If will do the usual compiler ID + version checking to determine if a flag should be supported; when using Clang on Mac it will in addition use `check_<lang>_compiler_flag()`. This should be safe because Apple's llvm versions have always been ahead of stock versions; false negatives should thus never occur.
The C++ version of the new macro is used where possible.
BUG: 401018
TEST PLAN
See https://bugs.kde.org/show_bug.cgi?id=401018 ; without this patch the project fails to build using Xcode compiler versions because the generated kcddb_export.h header does not match the visibility settings.
REPOSITORY
R240 Extra CMake Modules
REVISION DETAIL
https://phabricator.kde.org/D16894
AFFECTED FILES
kde-modules/KDECompilerSettings.cmake
kde-modules/KDEFrameworkCompilerSettings.cmake
To: rjvbb, #build_system
Cc: kde-frameworks-devel, kde-buildsystem, #build_system, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20181115/b4810686/attachment.html>
More information about the Kde-frameworks-devel
mailing list