I've noticed that some recipes, like json-c [1], which use the cmake bbclass, are generating files that aren't being used. This is because CMake sets the BUILD_TESTING option to ON by default. According to the CMake documentation [2], when CTest is included, as json-c does here [3], the module automatically creates a |BUILD_TESTING| option. This option determines whether to enable testing support, and it is ON by default.

In the json-c example, the tests used by the do_install_ptest task are always generated. Thus, ${B}/tests/ exists even when ptests are not included in DISTRO_FEATURES.

As the behavior of CTest/CMake to build tests by default is rather surprising, we are wondering whether disabling this option by default is feasible in the OpenEmbedded context. Recipes expecting tests to be built (e.g. because of ptest support) would then turn on the flag explicitly.

For example, adding this to cmake.bbclass:

|OECMAKE_BUILD_TESTING ??= "false" EXTRA_OECMAKE:append = "\\ ${@bb.utils.contains('OECMAKE_BUILD_TESTING', 'false', '-DBUILD_TESTING=OFF', '', d)} \\ " |

and then set the OECMAKE_BUILD_TESTING in the recipe that requires BUILD_TESTING=ON

Do you have any suggestions on which steps we should take to verify that this does not introduce any regressions?


1 - https://git.openembedded.org/openembedded-core/tree/meta/recipes-devtools/json-c/json-c_0.17.bb?h=master

2 - https://cmake.org/cmake/help/latest/module/CTest.html

3 - https://github.com/json-c/json-c/blob/master/CMakeLists.txt#L19


Regards,

Fabio Berton
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#198621): 
https://lists.openembedded.org/g/openembedded-core/message/198621
Mute This Topic: https://lists.openembedded.org/mt/105688417/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to