<table><tr><td style="">kfunk created this revision.<br />Restricted Application added projects: Frameworks, Build System.<br />Restricted Application added subscribers: Build System, Frameworks.
</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/D7187" rel="noreferrer">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>Use-case: Make building unit tests optional, by just following the CMake<br />
BUILD_TESTING option.</p>
<p>The usual approach to conditionally build tests is to do:</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 (BUILD_TESTING)
add_executable(TestOne TestOne.cpp)
target_link_libraries(TestOne my_library)
endif()</pre></div>
<p>or:</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 (BUILD_TESTING)
add_subdirectory(tests)
endif()</pre></div>
<p>This patch just turns all calls to ecm_add_test(...) into no-ops if<br />
BUILD_TESTING=OFF.</p>
<p>See:</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);">https://cmake.org/cmake/help/v3.6/module/CTest.html</pre></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R240 Extra CMake Modules</div></div></div><br /><div><strong>BRANCH</strong><div><div>master</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D7187" rel="noreferrer">https://phabricator.kde.org/D7187</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>modules/ECMAddTests.cmake<br />
modules/ECMEnableSanitizers.cmake</div></div></div><br /><div><strong>To: </strong>kfunk<br /><strong>Cc: </strong>Frameworks, Build System<br /></div>