bernedom / SI

A header only C++ library that provides type safety and user defined literals for physical units
https://si.dominikberner.ch/doc/
MIT License
486 stars 40 forks source link

Put Catch2 checks beind the SI_BUILD_TESTING option #126

Closed matthewtolman closed 11 months ago

matthewtolman commented 11 months ago

Summary

Moves the Catch2 checks to be behind the SI_BUILD_TESTING option. When SI_BUILD_TESTING, there will be no Catch2 checks.

Description

Currently the CMakeLists.txt file logs Catch2 checks emit lots of warnings when SI is included by source (e.g. FetchContent, git submodule, etc.) and Catch2 is not on the system. These warnings include the warning in the project itself, but they also include verbose warnings from CMake about not being able to find the Catch2 package (warnings in section below)

For maintainers or contributors to the library, this is the expected default behavior.

For someone who just includes by source (e.g. FetchContent, git submodule), this is not the expected default behavior. Currently, SI tests are not built by default when the project is included by source, so checks only related to test targets should not be running by default either.

This change set moves the Catch2 checks (and related warnings) behind the SI_BUILD_TESTING option. When SI_BUILD_TESTING is turned off (the default for source includes), then no Catch2 checks will run. However, when SI_BUILD_TESTING is turned on (the default for maintainers and contributors), then the Catch2 checks will run.

Example Warnings

CMake Warning at cmake-build-debug/_deps/SI/CMakeLists.txt:29 (find_package):
  By not providing "FindCatch2.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Catch2", but
  CMake did not find one.

  Could not find a package configuration file provided by "Catch2" with any
  of the following names:

    Catch2Config.cmake
    catch2-config.cmake

  Add the installation prefix of "Catch2" to CMAKE_PREFIX_PATH or set
  "Catch2_DIR" to a directory containing one of the above files.  If "Catch2"
  provides a separate development package or SDK, be sure it has been
  installed.

CMake Warning at CMakeLists.txt:31 (message):
  Catch2 not found, not building tests
bernedom commented 11 months ago

@matthewtolman Thanks for your contribution. It's highly welcome