<table><tr><td style="">rjvbb created this revision.<br />rjvbb added a reviewer: Build System.<br />rjvbb added a project: Build System.<br />Herald added a project: Frameworks.<br />Herald added a subscriber: kde-buildsystem.<br />rjvbb requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D16894">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>It is crucial not to add unsupported compiler options because they can cause CMake's <tt style="background: #ebebeb; font-size: 13px;">check_<lang>_compiler_flags</tt> macro to fail, causing problems like <a href="https://bugs.kde.org/show_bug.cgi?id=401018" class="remarkup-link" target="_blank" rel="noreferrer">https://bugs.kde.org/show_bug.cgi?id=401018</a>.<br />
To prevent this, run an actual test when using clang on Mac.</p>

<p>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 <tt style="background: #ebebeb; font-size: 13px;">CMP0025</tt> set to <tt style="background: #ebebeb; font-size: 13px;">NEW</tt>. That policy cannot be set after the <tt style="background: #ebebeb; font-size: 13px;">project</tt> statement in the toplevel cmake file (= not in an ECM module).</p>

<p>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 <tt style="background: #ebebeb; font-size: 13px;">check_<lang>_compiler_flag()</tt>. This should be safe because Apple's llvm versions have always been ahead of stock versions; false negatives should thus never occur.<br />
The C++ version of the new macro is used where possible.</p>

<p>BUG: 401018</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>See <a href="https://bugs.kde.org/show_bug.cgi?id=401018" class="remarkup-link" target="_blank" rel="noreferrer">https://bugs.kde.org/show_bug.cgi?id=401018</a> ; 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.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R240 Extra CMake Modules</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D16894">https://phabricator.kde.org/D16894</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>kde-modules/KDECompilerSettings.cmake<br />
kde-modules/KDEFrameworkCompilerSettings.cmake</div></div></div><br /><div><strong>To: </strong>rjvbb, Build System<br /><strong>Cc: </strong>kde-frameworks-devel, kde-buildsystem, Build System, michaelh, ngraham, bruns<br /></div>