cucumber / cucumber-cpp

Support for writing Cucumber step definitions in C++
MIT License
304 stars 131 forks source link

Is there a working example of cucumber (c cmake, boost) for c++? #257

Closed Gonerr closed 8 months ago

Gonerr commented 1 year ago

Hello everybody! I ran into a problem: I can't build an example Calc, an error appears in the step

# Generate Makefiles
cmake -E chdir build cmake -DCUKE_ENABLE_EXAMPLES=on -DCMAKE_INSTALL_PREFIX=${prefix} ..

I can't fix it in any way. I use the latest version of Cmake 3.27.0 and Boost 1.82.0, googletest is also the latest version. I tried to run it with others (Boost 1.46, Cmake 3.25), but it still gives an error:

-- Could NOT find Boost (missing: unit_test_framework) (found suitable version "1.46.1", minimum required is "1.46")
CMake Error at C:/Program Files/CMake/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Boost (missing: thread system regex date_time
  program_options filesystem) (found suitable version "1.46.1", minimum
  required is "1.46")
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.27/Modules/FindBoost.cmake:2378 (find_package_handle_standard_args)
  CMakeLists.txt:137 (find_package)

File CMakeLists.txt Does anyone know which versions of Boost and Cmake the test will be built with?

jenisys commented 1 year ago

The following works for me using the current HEAD of git repository on branch=main:

I needed to manually tweak the CMAKE_CXX_STANDARD (reason: googletest v1.13.0 requires at least C++ STD14). After that I could and run the unit tests:

export BUILD_DIR=build
cmake -B $BUILD_DIR -DCMAKE_CXX_STANDARD=17 -G Ninja
...

# -- STEP: Build the library and test programs
cmake --build $BUILD_DIR
...

# -- STEP: Run. the unit tests
ctest --test-dir $BUILD_DIR
...
111/111 Test #111: GenericDriverTest ................................................................   Passed    0.01 sec

100% tests passed, 0 tests failed out of 111
...
ursfassler commented 1 year ago

The solution from @jenisys also works for me. Make sure you disable Qt, there is another problem with missing C++11 and gtest. I have on a current debian testing:

This is a bug within cucumber-cpp, we have to enforce C++14. Thanks for figuring that out.

ursfassler commented 1 year ago

@Gonerr the mentioned error:

-- Could NOT find Boost (missing: unit_test_framework) (found suitable version "1.46.1", minimum required is "1.46")
CMake Error at C:/Program Files/CMake/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Boost (missing: thread system regex date_time
  program_options filesystem) (found suitable version "1.46.1", minimum
  required is "1.46")

Says that the boost modules "thread system regex date_time program_options filesystem" are missing. You may have to install them explicitly/manually.

linopsa commented 1 year ago

We still need help with the described issue. We can not get past this error. We are building on Windows with VS2022. Built boost explicitly with .\b2 --with-thread --with-system --with-regex --with-date_time

But got the following errors:

$ cmake -E chdir build cmake -DCUKE_ENABLE_EXAMPLES=on -DCMAKE_INSTALL_PREFIX=${prefix} .. -DCUKE_USE_STATIC_BOOST=ON -DCUKE_ENABLE_QT=OFF -DCMAKE_CXX_STANDARD=20
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19043.
-- Could NOT find Boost (missing: unit_test_framework) (found suitable version "1.82.0", minimum required is "1.46")
CMake Error at C:/Program Files/CMake/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Boost (missing: thread system regex date_time
  program_options filesystem) (found suitable version "1.82.0", minimum
  required is "1.46")
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.27/Modules/FindBoost.cmake:2378 (find_package_handle_standard_args)
  CMakeLists.txt:132 (find_package)

-- Configuring incomplete, errors occurred!

We also tried with set BUILD_DIR=build cmake -B $BUILD_DIR -DCMAKE_CXX_STANDARD=20 -G Ninja but got

c:\cucumber\cucumber-cpp>cmake -B $BUILD_DIR -DCMAKE_CXX_STANDARD=20 -G Ninja
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- The C compiler identification is MSVC 19.36.32535.0
-- The CXX compiler identification is MSVC 19.36.32535.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.36.32532/bin/Hostx86/x86/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.36.32532/bin/Hostx86/x86/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find Boost (missing: Boost_INCLUDE_DIR unit_test_framework) (Required is at least version "1.46")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
CMake Error at C:/Program Files/CMake/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Boost (missing: Boost_INCLUDE_DIR thread system regex
  date_time program_options filesystem) (Required is at least version "1.46")
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.27/Modules/FindBoost.cmake:2378 (find_package_handle_standard_args)
  CMakeLists.txt:132 (find_package)

-- Configuring incomplete, errors occurred!
ursfassler commented 8 months ago

@Gonerr @linopsa Please reopen this issue if it is not resolved for you. In the case it works for you, I would appreciate if you can help others by doing one or more: