From fde4e7699afa006d2cad741064f9339c509c85fa Mon Sep 17 00:00:00 2001 From: Kamil Strzempowicz Date: Wed, 29 Mar 2017 14:47:21 +0200 Subject: [PATCH 1/6] CMake cleanup: use 'option' for parameters Use the 'option' command for user-selectable options instead of cached bool variables. Just like CMake recommends. Also delete some excess whitespace. --- CMakeLists.txt | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a11f536..d32b6bbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,17 +2,16 @@ cmake_minimum_required(VERSION 3.1) project(Cucumber-Cpp) -set(CUKE_USE_STATIC_BOOST ${WIN32} CACHE BOOL "Statically link Boost (except boost::test)") -set(CUKE_USE_STATIC_GTEST ON CACHE BOOL "Statically link Google Test") - -set(CUKE_DISABLE_BOOST_TEST OFF CACHE BOOL "Disable boost:test") -set(CUKE_DISABLE_GTEST OFF CACHE BOOL "Disable Google Test framework") -set(CUKE_DISABLE_UNIT_TESTS OFF CACHE BOOL "Disable unit tests") -set(CUKE_DISABLE_E2E_TESTS OFF CACHE BOOL "Disable end-to-end tests") -set(CUKE_ENABLE_EXAMPLES OFF CACHE BOOL "Enable the examples") +option(CUKE_USE_STATIC_BOOST "Statically link Boost (except boost::test)" ${WIN32}) +option(CUKE_USE_STATIC_GTEST "Statically link Google Test" ON) +option(CUKE_DISABLE_BOOST_TEST "Disable boost:test" OFF) +option(CUKE_DISABLE_GTEST "Disable Google Test framework" OFF) +option(CUKE_DISABLE_UNIT_TESTS "Disable unit tests" OFF) +option(CUKE_DISABLE_E2E_TESTS "Disable end-to-end tests" OFF) +option(CUKE_ENABLE_EXAMPLES "Enable the examples" OFF) +option(VALGRIND_TESTS "Run tests within Valgrind" OFF) set(GMOCK_SRC_DIR "" CACHE STRING "Google Mock framework sources path (otherwise downloaded)") set(GMOCK_VER "1.7.0" CACHE STRING "Google Mock framework version to be used") -option(VALGRIND_TESTS "Run tests within Valgrind" OFF) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules) @@ -163,11 +162,8 @@ endif() # set(CUKE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) - include_directories(${CUKE_INCLUDE_DIR}) - set(CUKE_LIBRARIES cucumber-cpp ${CUKE_EXTRA_LIBRARIES}) - add_subdirectory(src) # From 9f82d7fdef0f8b6a885b99f61b2271e44eb18af6 Mon Sep 17 00:00:00 2001 From: Kamil Strzempowicz Date: Wed, 29 Mar 2017 14:47:21 +0200 Subject: [PATCH 2/6] CMake: merge Qt4 and Qt5 handling Also use the more localized target_include_directories instead of include_directories and AUTOMOC target property instead of CMAKE_AUTOMOC (which is the default for the value of all target's AUTOMOC property). --- CMakeLists.txt | 22 ++++++++++++++++++++++ examples/CalcQt/CMakeLists.txt | 34 ++++++---------------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d32b6bbd..65d5d4b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ option(CUKE_DISABLE_GTEST "Disable Google Test framework" OFF) option(CUKE_DISABLE_UNIT_TESTS "Disable unit tests" OFF) option(CUKE_DISABLE_E2E_TESTS "Disable end-to-end tests" OFF) option(CUKE_ENABLE_EXAMPLES "Enable the examples" OFF) +option(CUKE_DISABLE_QT "Disable using Qt framework" OFF) option(VALGRIND_TESTS "Run tests within Valgrind" OFF) set(GMOCK_SRC_DIR "" CACHE STRING "Google Mock framework sources path (otherwise downloaded)") set(GMOCK_VER "1.7.0" CACHE STRING "Google Mock framework version to be used") @@ -111,6 +112,27 @@ if(NOT CUKE_DISABLE_GTEST) endif() endif() +# +# Qt +# + +if(NOT CUKE_DISABLE_QT) + find_package(Qt5Core) + find_package(Qt5Widgets) + find_package(Qt5Test) + + if(${Qt5Core_FOUND} AND ${Qt5Widgets_FOUND} AND ${Qt5Test_FOUND}) + message(STATUS "Found Qt version: ${Qt5Core_VERSION_STRING}") + set(QT_LIBRARIES Qt5::Core Qt5::Widgets Qt5::Test) + else() + find_package(Qt4 COMPONENTS QtCore QtGui QtTest) + if(QT4_FOUND) + set(QT_LIBRARIES Qt4::QtCore Qt4::QtGui Qt4::QtTest) + include(${QT_USE_FILE}) + endif() + endif() +endif() + # # Valgrind # diff --git a/examples/CalcQt/CMakeLists.txt b/examples/CalcQt/CMakeLists.txt index 998f16bc..eecd8012 100644 --- a/examples/CalcQt/CMakeLists.txt +++ b/examples/CalcQt/CMakeLists.txt @@ -1,36 +1,14 @@ project(CalcQt) -set(CALCQT_HEADERS src/CalculatorWidget.h) -set(CALCQT_SOURCES src/CalcQt.cpp src/CalculatorWidget.cpp) -include_directories(${CUKE_INCLUDE_DIRS} src) - -find_package(Qt5Core QUIET) -find_package(Qt5Widgets QUIET) -find_package(Qt5Test QUIET) - -if(${Qt5Core_FOUND} AND ${Qt5Widgets_FOUND} AND ${Qt5Test_FOUND}) - set(CMAKE_INCLUDE_CURRENT_DIR ON) - set(CMAKE_AUTOMOC ON) - set(QT_LIBRARIES Qt5::Core Qt5::Widgets Qt5::Test) - - add_library(libcalcqt src/CalculatorWidget.cpp ${CALCQT_HEADERS}) +if(QT_LIBRARIES) + add_library(libcalcqt src/CalculatorWidget.cpp src/CalculatorWidget.h) + set_target_properties(libcalcqt PROPERTIES AUTOMOC ON) + target_include_directories(libcalcqt PUBLIC src) target_link_libraries(libcalcqt ${QT_LIBRARIES}) - - add_executable(calcqt ${CALCQT_SOURCES}) + + add_executable(calcqt src/CalcQt.cpp) target_link_libraries(calcqt libcalcqt ${QT_LIBRARIES}) -else() - find_package(Qt4 COMPONENTS QtCore QtGui QtTest) - if(QT4_FOUND) - include(${QT_USE_FILE}) - qt4_wrap_cpp(CALCQT_HEADERS_MOC ${CALCQT_HEADERS}) - add_library(libcalcqt src/CalculatorWidget ${CALCQT_HEADERS_MOC}) - - add_executable(calcqt ${CALCQT_SOURCES} ${CALCQT_HEADERS_MOC}) - target_link_libraries(calcqt ${QT_LIBRARIES}) - endif() -endif() -if(QT_LIBRARIES) if(Boost_UNIT_TEST_FRAMEWORK_FOUND) include_directories(${Boost_INCLUDE_DIRS}) add_executable(BoostCalculatorQtSteps features/step_definitions/BoostCalculatorQtSteps) From 42d39707d9573a973107f32d810016dd212b9337 Mon Sep 17 00:00:00 2001 From: Kamil Strzempowicz Date: Thu, 17 Aug 2017 08:28:45 +0200 Subject: [PATCH 3/6] AppVeyor: cleanup * remove 'cmd' prefix - because this is already the default * remove intermediate RUBY_VERSION environment variable * remove unused environment variables * rename %PLATFORM% to %MSVC_ARCH% where used * distinguish platform by presence of %MINGW_ARCH% or %MSVC_ARCH% --- appveyor.yml | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 6ddb51ad..50cf19cd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,34 +2,25 @@ version: "{branch}-ci-{build}" os: Visual Studio 2015 environment: - RUBY_VERSION: 200 matrix: - - build: mingw - platform: x86 - MINGW_ARCH: i686 - MSYSTEM: MINGW32 + - MINGW_ARCH: i686 MINGW_ROOT: C:\msys64\mingw32 BOOST_ROOT: C:\msys64\mingw32 BOOST_LIBRARYDIR: C:\msys64\mingw32\lib BOOST_INCLUDEDIR: C:\msys64\mingw32\include\boost CMAKE_GENERATOR: 'MSYS Makefiles' - - build: mingw - platform: x64 - MINGW_ARCH: x86_64 - MSYSTEM: MINGW64 + - MINGW_ARCH: x86_64 MINGW_ROOT: C:\msys64\mingw64 BOOST_ROOT: C:\msys64\mingw64 BOOST_LIBRARYDIR: C:\msys64\mingw64\lib BOOST_INCLUDEDIR: C:\msys64\mingw64\include\boost CMAKE_GENERATOR: 'MSYS Makefiles' - - build: msvc - platform: x86 + - MSVC_ARCH: x86 BOOST_ROOT: C:\Libraries\boost_1_59_0 BOOST_LIBRARYDIR: C:\Libraries\boost_1_59_0\lib32-msvc-14.0 BOOST_INCLUDEDIR: C:\Libraries\boost_1_59_0\boost CMAKE_GENERATOR: 'NMake Makefiles' - - build: msvc - platform: x64 + - MSVC_ARCH: x64 BOOST_ROOT: C:\Libraries\boost_1_59_0 BOOST_INCLUDEDIR: C:\Libraries\boost_1_59_0\boost BOOST_LIBRARYDIR: C:\Libraries\boost_1_59_0\lib64-msvc-14.0 @@ -38,26 +29,25 @@ environment: install: - git submodule init - git submodule update -- set PATH=C:\Ruby%RUBY_VERSION%\bin;%BOOST_LIBRARYDIR%;%PATH% +- set PATH=C:\Ruby200\bin;%BOOST_LIBRARYDIR%;%PATH% - gem install bundle - bundle install -- bundle env -- if "%build%"=="mingw" set PATH=%MINGW_ROOT%\bin;C:\msys64\usr\bin\;%PATH% -- if "%build%"=="mingw" bash -lc "pacman --needed --noconfirm -S mingw-w64-%MINGW_ARCH%-boost +- if defined MINGW_ROOT set PATH=%MINGW_ROOT%\bin;C:\msys64\usr\bin\;%PATH% +- if defined MINGW_ARCH bash -lc "pacman --needed --noconfirm -S mingw-w64-%MINGW_ARCH%-boost" +- if defined MSVC_ARCH call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %MSVC_ARCH% build_script: -- cmd: if "%build%"=="msvc" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %PLATFORM% -- cmd: cmake -E make_directory build -- cmd: cmake -E chdir build cmake -G "%CMAKE_GENERATOR%" -DCUKE_ENABLE_EXAMPLES=ON -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_INCLUDEDIR="%BOOST_INCLUDEDIR%" -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR%" .. -- cmd: cmake --build build +- cmake -E make_directory build +- cmake -E chdir build cmake -G "%CMAKE_GENERATOR%" -DCUKE_ENABLE_EXAMPLES=ON -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_INCLUDEDIR="%BOOST_INCLUDEDIR%" -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR%" .. +- cmake --build build test_script: -- cmd: set CTEST_OUTPUT_ON_FAILURE=ON -- cmd: cmake --build build --target test -- cmd: cmake --build build --target features +- set CTEST_OUTPUT_ON_FAILURE=ON +- cmake --build build --target test +- cmake --build build --target features after_test: -- cmd: for /r %%v in (TEST-*.xml) do curl -s -F "file=@%%v;filename=%%~nxv" https://ci.appveyor.com/api/testresults/junit/%APPVEYOR_JOB_ID% +- for /r %%v in (TEST-*.xml) do curl -s -F "file=@%%v;filename=%%~nxv" https://ci.appveyor.com/api/testresults/junit/%APPVEYOR_JOB_ID% notifications: - provider: Email From b2a0b0d78d4669e129f99179ab0efebea396980a Mon Sep 17 00:00:00 2001 From: Kamil Strzempowicz Date: Wed, 29 Mar 2017 14:47:21 +0200 Subject: [PATCH 4/6] CI: Make Qt available and discoverable To ensure our Qt-using code gets tested by our CI systems as well. --- .travis.yml | 15 ++++++++------- appveyor.yml | 5 ++++- travis.sh | 2 ++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 05685dcb..be30d8d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: cpp os: - - osx - linux sudo: required dist: trusty @@ -12,15 +11,16 @@ env: - GMOCK_VER=1.7.0 - GMOCK_PATH=/usr/src/gmock #1.6.0 from ubuntu trusty repo matrix: - exclude: - - os: osx - env: GMOCK_PATH=/usr/src/gmock - - os: osx - compiler: gcc #does anyone on osx use it? include: - os: linux compiler: gcc env: GMOCK_VER=1.8.0 VALGRIND_TESTS=ON + - os: osx + compiler: clang + env: GMOCK_VER=1.8.0 QT_DIR=/usr/local/Cellar/qt5/5.8.0_1 + - os: osx + compiler: clang + env: GMOCK_VER=1.7.0 QT_DIR=/usr/local/Cellar/qt5/5.8.0_1 addons: apt: @@ -35,9 +35,10 @@ addons: - google-mock - ninja-build - valgrind + - qtbase5-dev before_install: - - if [[ "${TRAVIS_OS_NAME}" = "osx" ]]; then brew update && brew install ninja; fi + - if [[ "${TRAVIS_OS_NAME}" = "osx" ]]; then brew update && brew install ninja qt5; fi script: ./travis.sh diff --git a/appveyor.yml b/appveyor.yml index 50cf19cd..71dca2e1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,6 +9,7 @@ environment: BOOST_LIBRARYDIR: C:\msys64\mingw32\lib BOOST_INCLUDEDIR: C:\msys64\mingw32\include\boost CMAKE_GENERATOR: 'MSYS Makefiles' + QT_DIR: C:\Qt\5.8\mingw53_32 - MINGW_ARCH: x86_64 MINGW_ROOT: C:\msys64\mingw64 BOOST_ROOT: C:\msys64\mingw64 @@ -20,11 +21,13 @@ environment: BOOST_LIBRARYDIR: C:\Libraries\boost_1_59_0\lib32-msvc-14.0 BOOST_INCLUDEDIR: C:\Libraries\boost_1_59_0\boost CMAKE_GENERATOR: 'NMake Makefiles' + QT_DIR: C:\Qt\5.8\msvc2015 - MSVC_ARCH: x64 BOOST_ROOT: C:\Libraries\boost_1_59_0 BOOST_INCLUDEDIR: C:\Libraries\boost_1_59_0\boost BOOST_LIBRARYDIR: C:\Libraries\boost_1_59_0\lib64-msvc-14.0 CMAKE_GENERATOR: 'NMake Makefiles' + QT_DIR: C:\Qt\5.8\msvc2015_64 install: - git submodule init @@ -38,7 +41,7 @@ install: build_script: - cmake -E make_directory build -- cmake -E chdir build cmake -G "%CMAKE_GENERATOR%" -DCUKE_ENABLE_EXAMPLES=ON -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_INCLUDEDIR="%BOOST_INCLUDEDIR%" -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR%" .. +- cmake -E chdir build cmake -G "%CMAKE_GENERATOR%" -DCUKE_ENABLE_EXAMPLES=ON -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_INCLUDEDIR="%BOOST_INCLUDEDIR%" -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR%" -DCMAKE_PREFIX_PATH="%QT_DIR%" .. - cmake --build build test_script: diff --git a/travis.sh b/travis.sh index 9279fec2..447b8b8f 100755 --- a/travis.sh +++ b/travis.sh @@ -1,6 +1,7 @@ #!/bin/sh set -e #break script on non-zero exitcode from any command set -x #display command being executed + gem install bundler bundle install @@ -11,6 +12,7 @@ cmake -E make_directory build cmake -E chdir build cmake \ -G Ninja \ -DCUKE_ENABLE_EXAMPLES=on \ + ${QT_DIR:+"-DCMAKE_PREFIX_PATH=${QT_DIR}"} \ ${VALGRIND_TESTS:+"-DVALGRIND_TESTS=${VALGRIND_TESTS}"} \ ${GMOCK_PATH:-"-DGMOCK_VER=${GMOCK_VER}"} \ ${GMOCK_PATH:+"-DGMOCK_SRC_DIR=${GMOCK_PATH}"} \ From 0a16f31bff9a33eaf5452ae4ae3553e70d45afad Mon Sep 17 00:00:00 2001 From: Kamil Strzempowicz Date: Thu, 17 Aug 2017 19:57:16 +0200 Subject: [PATCH 5/6] Reorder linking libraries for CalcQt That should fix appveyor build for mingw + small cleanups in examples CMake configuration --- examples/Calc/CMakeLists.txt | 4 +--- examples/CalcQt/CMakeLists.txt | 3 +-- examples/FeatureShowcase/CMakeLists.txt | 2 -- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/examples/Calc/CMakeLists.txt b/examples/Calc/CMakeLists.txt index 7157f3ec..bb80177c 100644 --- a/examples/Calc/CMakeLists.txt +++ b/examples/Calc/CMakeLists.txt @@ -1,8 +1,7 @@ project(Calc) -include_directories(${CUKE_INCLUDE_DIRS} src) - add_library(Calc src/Calculator) +target_include_directories(Calc PUBLIC src) if(GMOCK_FOUND) add_executable(GTestCalculatorSteps features/step_definitions/GTestCalculatorSteps) @@ -10,7 +9,6 @@ if(GMOCK_FOUND) endif() if(Boost_UNIT_TEST_FRAMEWORK_FOUND) - include_directories(${Boost_INCLUDE_DIRS}) add_executable(BoostCalculatorSteps features/step_definitions/BoostCalculatorSteps) target_link_libraries(BoostCalculatorSteps Calc ${CUKE_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) endif() diff --git a/examples/CalcQt/CMakeLists.txt b/examples/CalcQt/CMakeLists.txt index eecd8012..6af66d3b 100644 --- a/examples/CalcQt/CMakeLists.txt +++ b/examples/CalcQt/CMakeLists.txt @@ -10,9 +10,8 @@ if(QT_LIBRARIES) target_link_libraries(calcqt libcalcqt ${QT_LIBRARIES}) if(Boost_UNIT_TEST_FRAMEWORK_FOUND) - include_directories(${Boost_INCLUDE_DIRS}) add_executable(BoostCalculatorQtSteps features/step_definitions/BoostCalculatorQtSteps) - target_link_libraries(BoostCalculatorQtSteps libcalcqt ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${CUKE_LIBRARIES} ${QT_LIBRARIES}) + target_link_libraries(BoostCalculatorQtSteps libcalcqt ${CUKE_LIBRARIES} ${QT_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) endif() if(GTEST_FOUND) add_executable(GTestCalculatorQtSteps features/step_definitions/GTestCalculatorQtSteps) diff --git a/examples/FeatureShowcase/CMakeLists.txt b/examples/FeatureShowcase/CMakeLists.txt index c5f18254..71ab99e0 100644 --- a/examples/FeatureShowcase/CMakeLists.txt +++ b/examples/FeatureShowcase/CMakeLists.txt @@ -1,7 +1,5 @@ project(FeatureShowcase) -include_directories(${CUKE_INCLUDE_DIRS}) - if(GMOCK_FOUND) function(add_cucumber_executable) add_executable(FeatureShowcaseSteps ${ARGV}) From e8eac1b36caaa47505155a555c058edabc8175d6 Mon Sep 17 00:00:00 2001 From: Kamil Strzempowicz Date: Thu, 17 Aug 2017 20:52:02 +0200 Subject: [PATCH 6/6] update History.md --- HISTORY.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index 27da28fd..3abc2044 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,7 @@ ### New Features * Listen on localhost by default to avoid firewall warnings ([#158](https://github.com/cucumber/cucumber-cpp/pull/158) Nik Reiman) +* Enable Qt framework in CI and refactoring of CI configuration ([#160](https://github.com/cucumber/cucumber-cpp/pull/160) Kamil Strzempowicz & Giel van Schijndel) ### Bugfixes @@ -10,6 +11,7 @@ * Fix QNX build by depending on standard C++ instead of specific implementation ([#156](https://github.com/cucumber/cucumber-cpp/issues/156) Giel van Schijndel) * Ensure CMake 3.1+ is available, 2.8.12 wasn't enough for quite a while ([#152](https://github.com/cucumber/cucumber-cpp/pull/152) Giel van Schijndel) + ## [0.4](https://github.com/cucumber/cucumber-cpp/compare/v0.3.1...v0.4) (31 March 2017) ### New Features @@ -27,6 +29,8 @@ * Fixed `defs.hpp` deprecation warning on MSVC ([#124](https://github.com/cucumber/cucumber-cpp/pull/124) Antoine Allard) * Fixed parallel build ([#135](https://github.com/cucumber/cucumber-cpp/pull/135) Giel van Schijndel) * Fixed memory leaks and better memory management ([#134](https://github.com/cucumber/cucumber-cpp/pull/134) Giel van Schijndel) +* Got rid of clang warning - fix for issue #119 ([#138](https://github.com/cucumber/cucumber-cpp/pull/138) Kamil Strzempowicz, [f933ad1](https://github.com/paoloambrosio/cucumber-cpp/commit/f933ad1983cf15cc0573532f98b5457bc1ba2a18) Paolo Ambrosio) + ## [0.3.1](https://github.com/cucumber/cucumber-cpp/compare/v0.3...v0.3.1) (11 April 2016) @@ -41,6 +45,7 @@ None + ## [0.3](https://github.com/cucumber/cucumber-cpp/compare/v0.2...v0.3) (22 December 2013) ### New Features