From 74d840ba2df32478da9457c0e741dcce6eb8ffa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Urs=20F=C3=A4ssler?= Date: Wed, 3 Jan 2024 17:01:59 +0100 Subject: [PATCH] only enable minimal set of options by default This is to reduce error output since cmake fails when an option is enabled but a dependency for it not installed. Test frameworks are off by default because every one has an external dependency. A warning is shown when no test framework is selected as one is needed for cucumber-cpp to be usable. --- CMakeLists.txt | 32 +++++++++++++++++++++++++++----- README.md | 11 ++++------- run-all.sh | 11 +++++------ 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e99f5b1..6f2b7e7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,12 +13,14 @@ endif() project(Cucumber-Cpp) -option(BUILD_SHARED_LIBS "Generate shared libraries" OFF) -option(CUKE_ENABLE_BOOST_TEST "Enable Boost.Test framework" ON) +option(CUKE_ENABLE_BOOST_TEST "Enable Boost.Test framework" OFF) +option(CUKE_ENABLE_GTEST "Enable Google Test framework" OFF) +option(CUKE_ENABLE_QT "Enable Qt framework" OFF) + option(CUKE_ENABLE_EXAMPLES "Build examples" OFF) -option(CUKE_ENABLE_GTEST "Enable Google Test framework" ON) -option(CUKE_ENABLE_QT "Enable Qt framework" ON) -option(CUKE_TESTS_UNIT "Enable unit tests" ON) +option(CUKE_TESTS_UNIT "Enable unit tests" OFF) + +option(BUILD_SHARED_LIBS "Generate shared libraries" OFF) option(CUKE_CODE_COVERAGE "Enable instrumentation for code coverage" OFF) set(CUKE_ENABLE_SANITIZER "OFF" CACHE STRING "Sanitizer to use for checking") set_property(CACHE CUKE_ENABLE_SANITIZER PROPERTY STRINGS OFF "address" "thread" "undefined") @@ -68,6 +70,26 @@ option_depr_invert (CUKE_DISABLE_QT CUKE_ENABLE_QT) option_depr_invert (CUKE_DISABLE_UNIT_TESTS CUKE_TESTS_UNIT) option_depr (VALGRIND_TESTS CUKE_TESTS_VALGRIND) +# +# Check that at least one test framework is enabled +# + +set(CUKE_TEST_FRAMEWORKS + CUKE_ENABLE_BOOST_TEST + CUKE_ENABLE_GTEST + CUKE_ENABLE_QT +) + +set(TEST_FRAMEWORK_FOUND FALSE) +foreach(test_framework ${CUKE_TEST_FRAMEWORKS}) + if(${test_framework}) + set(TEST_FRAMEWORK_FOUND TRUE) + endif() +endforeach() + +if(NOT TEST_FRAMEWORK_FOUND) + message(WARNING "No test framework enabled. At least one should be enabled. Options are: ${CUKE_TEST_FRAMEWORKS}.") +endif() # # Generic Compiler Flags diff --git a/README.md b/README.md index 456764b4..6537a830 100644 --- a/README.md +++ b/README.md @@ -55,23 +55,20 @@ Building Cucumber-Cpp with tests and samples: cmake -E make_directory build # Generate Makefiles -cmake -E chdir build cmake -DCUKE_ENABLE_EXAMPLES=on -DCMAKE_INSTALL_PREFIX=${prefix} .. +cmake -E chdir build cmake -DCUKE_ENABLE_BOOST_TEST=on -DCUKE_ENABLE_GTEST=on -DCUKE_ENABLE_QT=on -DCUKE_TESTS_UNIT=on -DCUKE_ENABLE_EXAMPLES=on .. -# Build cucumber-cpp and tests +# Build cucumber-cpp cmake --build build -# Run unit tests -cmake --build build --target test - # Run install -cmake --build build --target install +cmake --install build ``` Running the Calc example on Unix: ``` build/examples/Calc/BoostCalculatorSteps >/dev/null & -cucumber examples/Calc +(cd examples/Calc; cucumber) ``` Running the Calc example on Windows (NMake): diff --git a/run-all.sh b/run-all.sh index 3c25416c..b1e095ca 100755 --- a/run-all.sh +++ b/run-all.sh @@ -21,15 +21,14 @@ export CTEST_OUTPUT_ON_FAILURE cmake -E make_directory build cmake -E chdir build cmake \ -G Ninja \ + -DCUKE_ENABLE_BOOST_TEST=on \ + -DCUKE_ENABLE_GTEST=on \ + -DCUKE_ENABLE_QT=on \ -DCUKE_ENABLE_EXAMPLES=on \ + -DCUKE_TESTS_UNIT=on \ -DCUKE_CODE_COVERAGE=on \ - -DBUILD_SHARED_LIBS="${BUILD_SHARED_LIBS:-OFF}" \ - -DCMAKE_INSTALL_PREFIX=${HOME}/.local \ - ${CMAKE_PREFIX_PATH:+"-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}"} \ - ${VALGRIND_TESTS:+"-DVALGRIND_TESTS=${VALGRIND_TESTS}"} \ .. cmake --build build --parallel -cmake --build build --parallel --target test # # Execute Calc examples @@ -80,4 +79,4 @@ wait % mkdir -p coverage gcovr build/ --html-details --output coverage/index.html --xml coverage/cobertura.xml -cmake --build build --target install +sudo cmake --install build