tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

Allow opting out of test building #3084

Closed OPNA2608 closed 2 weeks ago

OPNA2608 commented 2 weeks ago

https://cmake.org/cmake/help/v3.0/module/CTest.html explains that including the CTest module and using the created BUILD_TESTING option allows users to opt out of creating tests when testing isn't desired.

This is what I would usually submit to projects, where using it via add_subdirectory() from another project is not a consideration. Since BUILD_TESTING is a cache variable, is this a problem again? So maybe just

if (BUILD_TESTING)
  enable_testing()
  add_subdirectory(test)
endif()

…without including CTest (since that's what defines the option())? Though this would default to the tests not being built, while using the option() would preserve current behaviour

levlam commented 2 weeks ago

This change will be accepted.

Scutua commented 2 weeks ago

Thanks too much everyone and github also

On Thu, 17 Oct 2024, 04:44 Aliaksei Levin, @.***> wrote:

Merged #3084 https://github.com/tdlib/td/pull/3084 into master.

— Reply to this email directly, view it on GitHub https://github.com/tdlib/td/pull/3084#event-14689833266, or unsubscribe https://github.com/notifications/unsubscribe-auth/BJ4PV45SSTPR6BUWTXYSJBDZ33M4TAVCNFSM6AAAAABPZZOP76VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJUGY4DSOBTGMZDMNQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

levlam commented 2 weeks ago

By the way, if you include projects via add_subdirectory there are no issues, because BUILD_TESTING must be used explicitly to have any effect. This isn't a built-in option like BUILD_SHARED_LIBS, CMAKE_INSTALL_PREFIX, or CMAKE_BUILD_TYPE, which have implicit effect on all projects.