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 0779f06
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 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 "At least one test framework should be enabled. Options are: ${CUKE_TEST_FRAMEWORKS}.")
endif()

#
# Generic Compiler Flags
Expand Down
8 changes: 4 additions & 4 deletions run-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ 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
Expand Down

0 comments on commit 0779f06

Please sign in to comment.