<table><tr><td style="">kfunk requested changes to this revision.<br />kfunk added a comment.<br />This revision now requires changes to proceed.
</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><div><p>I don't like the hiding of the if-branches as argument to macro. We shouldn't to this as it makes the code harder to understand.</p>

<p>The general issue with the existing code here is: Statements like <tt style="background: #ebebeb; font-size: 13px;">CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5</tt> do not make sense. If we check the compiler version, then we need to differentiate between Clang and AppleClang (cf. something like <a href="https://github.com/Microsoft/LightGBM/blob/master/CMakeLists.txt#L20" class="remarkup-link" target="_blank" rel="noreferrer">https://github.com/Microsoft/LightGBM/blob/master/CMakeLists.txt#L20</a>).</p>

<p>Thus these places need to be turned into:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">...
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.8")
  ...
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.1.0")
  ...
endif()</pre></div>

<p>If you're unsure in which version of AppleClang a certain feature was introduced then:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">...
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.1.0")
  add_compile_flag_if_supported(...)
endif()</pre></div>

<p>Please check out the functions provided in: kdevelop.git:cmake/modules/KDevelopMacrosInternal.cmake</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">#   add_compile_flag_if_supported(<flag> [CXX_ONLY])
#   add_target_compile_flag_if_supported(<target> <INTERFACE|PUBLIC|PRIVATE> <flag>)</pre></div>

<p>They are more clean than your implementation, I think it would make sense to actually add them to KDECompilerSettings.cmake and prefix them with <tt style="background: #ebebeb; font-size: 13px;">kde_</tt>.</p></div></div><br /><div><strong>INLINE COMMENTS</strong><div><div style="margin: 6px 0 12px 0;"><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D16894#inline-92196">View Inline</a><span style="color: #4b4d51; font-weight: bold;">KDECompilerSettings.cmake:202</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span style="color: #74777d"># is expected to support _FLAG.</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span style="color: #304a96">if</span> <span class="p">(</span><span style="color: #aa2211">${</span><span style="color: #001294">ARGN</span><span style="color: #aa2211">}</span><span class="p">)</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span style="color: #304a96">if</span><span class="p">(</span><span style="color: #766510">APPLE</span> <span style="color: #766510">AND</span> <span style="color: #766510">CMAKE_CXX_COMPILER_ID</span> <span style="color: #766510">MATCHES</span> <span style="color: #766510">"Clang"</span><span class="p">)</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">This "let's abuse ${ARGN} as code to be evaluated later" is pretty ugly. The previous version (with the if-statements at  the caller side) is way more clean and understandable.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D16894#inline-92197">View Inline</a><span style="color: #4b4d51; font-weight: bold;">KDECompilerSettings.cmake:203</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span style="color: #304a96">if</span> <span class="p">(</span><span style="color: #aa2211">${</span><span style="color: #001294">ARGN</span><span style="color: #aa2211">}</span><span class="p">)</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span style="color: #304a96">if</span><span class="p">(</span><span style="color: #766510">APPLE</span> <span style="color: #766510">AND</span> <span style="color: #766510">CMAKE_CXX_COMPILER_ID</span> <span style="color: #766510">MATCHES</span> <span style="color: #766510">"Clang"</span><span class="p">)</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #74777d"># Clang on APPLE needs verification because of Apple's</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">I don't really understand why this branch is needed. The macro name name suggests it does the compile check on all compilers. Again very misleading.</p></div></div></div></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>To: </strong>rjvbb, Build System, kfunk<br /><strong>Cc: </strong>kfunk, apol, kde-frameworks-devel, kde-buildsystem, Build System, michaelh, ngraham, bruns<br /></div>