Put effectModelTest behind BUILD_TESTING conditional
AbandonedPublic

Authored by asturmlechner on Sep 14 2017, 8:22 AM.

Details

Reviewers
graesslin
Group Reviewers
KWin
Summary

Qt5Test is optional, so tests need to be too.

Test Plan

Builds again with Qt5Test disabled.

Diff Detail

Repository
R108 KWin
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
asturmlechner created this revision.Sep 14 2017, 8:22 AM
Restricted Application added a project: KWin. · View Herald TranscriptSep 14 2017, 8:22 AM
Restricted Application added subscribers: KWin, kwin. · View Herald Transcript
asturmlechner edited the summary of this revision. (Show Details)
apol added a subscriber: apol.Sep 14 2017, 10:45 AM
apol added inline comments.
kcmkwin/kwincompositing/CMakeLists.txt
48–49

The code inside the if needs indentation.

  • Add (auto)tests only if BUILD_TESTING
graesslin requested changes to this revision.Sep 14 2017, 4:49 PM
graesslin added a subscriber: graesslin.

Why is this needed? Wasn't the idea behind ecm_mark_as_test that they are not built when BUILD_TESTING is off?

This revision now requires changes to proceed.Sep 14 2017, 4:49 PM

Why is this needed? Wasn't the idea behind ecm_mark_as_test that they are not built when BUILD_TESTING is off?

That doesn't work that well anymore since some version of cmake or Frameworks - if the test links to Qt5::Test (or any other lib) that is not available due to building without tests, it will fail. We don't usually notice because tests/autotests are auto-commented from root CMakeLists.txt, but it is the reason why I pushed several BUILD_TESTING conditionals into sublevel tests directories of other packages.

From a packager's POV, what I'd really like is some add_testdirectory macro where everyone would isolate their tests that would be auto-disabled by BUILD_TESTING=OFF...

That doesn't work that well anymore since some version of cmake or Frameworks

I guess this does not work because Qt5::Test is used in target_link_libraries(). When there was a simple plain library name, EXCLUDE_FROM_ALL worked fine (library resolution is left to the linker), but now CMake has to resolve this target in any case, whether a test is built or not.
Maybe ecm_mark_as_test could modify LINK_LIBRARIES property of the target to replace Qt5::Test with ${Qt5Test_LIBRARIES}?

From a packager's POV, what I'd really like is some add_testdirectory macro where everyone would isolate their tests that would be auto-disabled by BUILD_TESTING=OFF...

From a maintainer perspective as well. Simply put I don't want to have to maintain changes like this one. This is going to break some day. Trying to get this working with if-else section is IMHO a futile exercise. I'm not a fan of adding stuff where I see that it will break. I rather force everyone to always build the tests.

Let's get this right in ecm and then not need this here.

asturmlechner abandoned this revision.Jun 1 2018, 6:20 PM

Glad this was apparently accepted when done by someone else... https://phabricator.kde.org/D13163