Skip to content

Commit

Permalink
only enable minimal set of options by default
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ursfassler committed Jan 3, 2024
1 parent 748b561 commit 74d840b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
32 changes: 27 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
11 changes: 5 additions & 6 deletions run-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 74d840b

Please sign in to comment.