Qt5Test is optional, so tests need to be too.
Diff Detail
- Repository
- R108 KWin
- Branch
- master
- Lint
No Linters Available - Unit
No Unit Test Coverage
kcmkwin/kwincompositing/CMakeLists.txt | ||
---|---|---|
48–49 | The code inside the if needs indentation. |
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...
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 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.
Glad this was apparently accepted when done by someone else... https://phabricator.kde.org/D13163