Skip to content

Commit 07850d5

Browse files
committed
Merge #160 enable Qt in CI
* Make building with Qt possible to disable (CUKE_DISABLE_QT) * Enable building with Qt on our CI systems for improved coverage * Refactor the CMake build system around this to be more clean * Refactor the CI configurations to be cleaner & leaner
2 parents 6f4a1d5 + e8eac1b commit 07850d5

File tree

8 files changed

+67
-79
lines changed

8 files changed

+67
-79
lines changed

.travis.yml

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
language: cpp
22
os:
3-
- osx
43
- linux
54
sudo: required
65
dist: trusty
@@ -12,15 +11,16 @@ env:
1211
- GMOCK_VER=1.7.0
1312
- GMOCK_PATH=/usr/src/gmock #1.6.0 from ubuntu trusty repo
1413
matrix:
15-
exclude:
16-
- os: osx
17-
env: GMOCK_PATH=/usr/src/gmock
18-
- os: osx
19-
compiler: gcc #does anyone on osx use it?
2014
include:
2115
- os: linux
2216
compiler: gcc
2317
env: GMOCK_VER=1.8.0 VALGRIND_TESTS=ON
18+
- os: osx
19+
compiler: clang
20+
env: GMOCK_VER=1.8.0 QT_DIR=/usr/local/Cellar/qt5/5.8.0_1
21+
- os: osx
22+
compiler: clang
23+
env: GMOCK_VER=1.7.0 QT_DIR=/usr/local/Cellar/qt5/5.8.0_1
2424

2525
addons:
2626
apt:
@@ -35,9 +35,10 @@ addons:
3535
- google-mock
3636
- ninja-build
3737
- valgrind
38+
- qtbase5-dev
3839

3940
before_install:
40-
- if [[ "${TRAVIS_OS_NAME}" = "osx" ]]; then brew update && brew install ninja; fi
41+
- if [[ "${TRAVIS_OS_NAME}" = "osx" ]]; then brew update && brew install ninja qt5; fi
4142

4243
script: ./travis.sh
4344

CMakeLists.txt

+30-12
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ cmake_minimum_required(VERSION 3.1)
22

33
project(Cucumber-Cpp)
44

5-
set(CUKE_USE_STATIC_BOOST ${WIN32} CACHE BOOL "Statically link Boost (except boost::test)")
6-
set(CUKE_USE_STATIC_GTEST ON CACHE BOOL "Statically link Google Test")
7-
8-
set(CUKE_DISABLE_BOOST_TEST OFF CACHE BOOL "Disable boost:test")
9-
set(CUKE_DISABLE_GTEST OFF CACHE BOOL "Disable Google Test framework")
10-
set(CUKE_DISABLE_UNIT_TESTS OFF CACHE BOOL "Disable unit tests")
11-
set(CUKE_DISABLE_E2E_TESTS OFF CACHE BOOL "Disable end-to-end tests")
12-
set(CUKE_ENABLE_EXAMPLES OFF CACHE BOOL "Enable the examples")
5+
option(CUKE_USE_STATIC_BOOST "Statically link Boost (except boost::test)" ${WIN32})
6+
option(CUKE_USE_STATIC_GTEST "Statically link Google Test" ON)
7+
option(CUKE_DISABLE_BOOST_TEST "Disable boost:test" OFF)
8+
option(CUKE_DISABLE_GTEST "Disable Google Test framework" OFF)
9+
option(CUKE_DISABLE_UNIT_TESTS "Disable unit tests" OFF)
10+
option(CUKE_DISABLE_E2E_TESTS "Disable end-to-end tests" OFF)
11+
option(CUKE_ENABLE_EXAMPLES "Enable the examples" OFF)
12+
option(CUKE_DISABLE_QT "Disable using Qt framework" OFF)
13+
option(VALGRIND_TESTS "Run tests within Valgrind" OFF)
1314
set(GMOCK_SRC_DIR "" CACHE STRING "Google Mock framework sources path (otherwise downloaded)")
1415
set(GMOCK_VER "1.7.0" CACHE STRING "Google Mock framework version to be used")
15-
option(VALGRIND_TESTS "Run tests within Valgrind" OFF)
1616

1717
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
1818

@@ -112,6 +112,27 @@ if(NOT CUKE_DISABLE_GTEST)
112112
endif()
113113
endif()
114114

115+
#
116+
# Qt
117+
#
118+
119+
if(NOT CUKE_DISABLE_QT)
120+
find_package(Qt5Core)
121+
find_package(Qt5Widgets)
122+
find_package(Qt5Test)
123+
124+
if(${Qt5Core_FOUND} AND ${Qt5Widgets_FOUND} AND ${Qt5Test_FOUND})
125+
message(STATUS "Found Qt version: ${Qt5Core_VERSION_STRING}")
126+
set(QT_LIBRARIES Qt5::Core Qt5::Widgets Qt5::Test)
127+
else()
128+
find_package(Qt4 COMPONENTS QtCore QtGui QtTest)
129+
if(QT4_FOUND)
130+
set(QT_LIBRARIES Qt4::QtCore Qt4::QtGui Qt4::QtTest)
131+
include(${QT_USE_FILE})
132+
endif()
133+
endif()
134+
endif()
135+
115136
#
116137
# Valgrind
117138
#
@@ -163,11 +184,8 @@ endif()
163184
#
164185

165186
set(CUKE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
166-
167187
include_directories(${CUKE_INCLUDE_DIR})
168-
169188
set(CUKE_LIBRARIES cucumber-cpp ${CUKE_EXTRA_LIBRARIES})
170-
171189
add_subdirectory(src)
172190

173191
#

HISTORY.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### New Features
44

55
* Listen on localhost by default to avoid firewall warnings ([#158](https://github.com./cucumber/cucumber-cpp/pull/158) Nik Reiman)
6+
* Better integrate Qt into buildsystem, it can now be disabled, and test it in CI ([#160](https://github.com./cucumber/cucumber-cpp/pull/160) Kamil Strzempowicz & Giel van Schijndel)
67

78
### Bugfixes
89

appveyor.yml

+18-25
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,55 @@ version: "{branch}-ci-{build}"
22
os: Visual Studio 2015
33

44
environment:
5-
RUBY_VERSION: 200
65
matrix:
7-
- build: mingw
8-
platform: x86
9-
MINGW_ARCH: i686
10-
MSYSTEM: MINGW32
6+
- MINGW_ARCH: i686
117
MINGW_ROOT: C:\msys64\mingw32
128
BOOST_ROOT: C:\msys64\mingw32
139
BOOST_LIBRARYDIR: C:\msys64\mingw32\lib
1410
BOOST_INCLUDEDIR: C:\msys64\mingw32\include\boost
1511
CMAKE_GENERATOR: 'MSYS Makefiles'
16-
- build: mingw
17-
platform: x64
18-
MINGW_ARCH: x86_64
19-
MSYSTEM: MINGW64
12+
QT_DIR: C:\Qt\5.8\mingw53_32
13+
- MINGW_ARCH: x86_64
2014
MINGW_ROOT: C:\msys64\mingw64
2115
BOOST_ROOT: C:\msys64\mingw64
2216
BOOST_LIBRARYDIR: C:\msys64\mingw64\lib
2317
BOOST_INCLUDEDIR: C:\msys64\mingw64\include\boost
2418
CMAKE_GENERATOR: 'MSYS Makefiles'
25-
- build: msvc
26-
platform: x86
19+
- MSVC_ARCH: x86
2720
BOOST_ROOT: C:\Libraries\boost_1_59_0
2821
BOOST_LIBRARYDIR: C:\Libraries\boost_1_59_0\lib32-msvc-14.0
2922
BOOST_INCLUDEDIR: C:\Libraries\boost_1_59_0\boost
3023
CMAKE_GENERATOR: 'NMake Makefiles'
31-
- build: msvc
32-
platform: x64
24+
QT_DIR: C:\Qt\5.8\msvc2015
25+
- MSVC_ARCH: x64
3326
BOOST_ROOT: C:\Libraries\boost_1_59_0
3427
BOOST_INCLUDEDIR: C:\Libraries\boost_1_59_0\boost
3528
BOOST_LIBRARYDIR: C:\Libraries\boost_1_59_0\lib64-msvc-14.0
3629
CMAKE_GENERATOR: 'NMake Makefiles'
30+
QT_DIR: C:\Qt\5.8\msvc2015_64
3731

3832
install:
3933
- git submodule init
4034
- git submodule update
41-
- set PATH=C:\Ruby%RUBY_VERSION%\bin;%BOOST_LIBRARYDIR%;%PATH%
35+
- set PATH=C:\Ruby200\bin;%BOOST_LIBRARYDIR%;%PATH%
4236
- gem install bundle
4337
- bundle install
44-
- bundle env
45-
- if "%build%"=="mingw" set PATH=%MINGW_ROOT%\bin;C:\msys64\usr\bin\;%PATH%
46-
- if "%build%"=="mingw" bash -lc "pacman --needed --noconfirm -S mingw-w64-%MINGW_ARCH%-boost
38+
- if defined MINGW_ROOT set PATH=%MINGW_ROOT%\bin;C:\msys64\usr\bin\;%PATH%
39+
- if defined MINGW_ARCH bash -lc "pacman --needed --noconfirm -S mingw-w64-%MINGW_ARCH%-boost"
40+
- if defined MSVC_ARCH call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %MSVC_ARCH%
4741

4842
build_script:
49-
- cmd: if "%build%"=="msvc" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %PLATFORM%
50-
- cmd: cmake -E make_directory build
51-
- 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%" ..
52-
- cmd: cmake --build build
43+
- cmake -E make_directory build
44+
- 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%" ..
45+
- cmake --build build
5346

5447
test_script:
55-
- cmd: set CTEST_OUTPUT_ON_FAILURE=ON
56-
- cmd: cmake --build build --target test
57-
- cmd: cmake --build build --target features
48+
- set CTEST_OUTPUT_ON_FAILURE=ON
49+
- cmake --build build --target test
50+
- cmake --build build --target features
5851

5952
after_test:
60-
- 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%
53+
- for /r %%v in (TEST-*.xml) do curl -s -F "file=@%%v;filename=%%~nxv" https://ci.appveyor.com/api/testresults/junit/%APPVEYOR_JOB_ID%
6154

6255
notifications:
6356
- provider: Email

examples/Calc/CMakeLists.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
project(Calc)
22

3-
include_directories(${CUKE_INCLUDE_DIRS} src)
4-
53
add_library(Calc src/Calculator)
4+
target_include_directories(Calc PUBLIC src)
65

76
if(GMOCK_FOUND)
87
add_executable(GTestCalculatorSteps features/step_definitions/GTestCalculatorSteps)
98
target_link_libraries(GTestCalculatorSteps Calc ${CUKE_LIBRARIES} ${CUKE_GTEST_LIBRARIES})
109
endif()
1110

1211
if(Boost_UNIT_TEST_FRAMEWORK_FOUND)
13-
include_directories(${Boost_INCLUDE_DIRS})
1412
add_executable(BoostCalculatorSteps features/step_definitions/BoostCalculatorSteps)
1513
target_link_libraries(BoostCalculatorSteps Calc ${CUKE_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
1614
endif()

examples/CalcQt/CMakeLists.txt

+7-30
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,17 @@
11
project(CalcQt)
22

3-
set(CALCQT_HEADERS src/CalculatorWidget.h)
4-
set(CALCQT_SOURCES src/CalcQt.cpp src/CalculatorWidget.cpp)
5-
include_directories(${CUKE_INCLUDE_DIRS} src)
6-
7-
find_package(Qt5Core QUIET)
8-
find_package(Qt5Widgets QUIET)
9-
find_package(Qt5Test QUIET)
10-
11-
if(${Qt5Core_FOUND} AND ${Qt5Widgets_FOUND} AND ${Qt5Test_FOUND})
12-
set(CMAKE_INCLUDE_CURRENT_DIR ON)
13-
set(CMAKE_AUTOMOC ON)
14-
set(QT_LIBRARIES Qt5::Core Qt5::Widgets Qt5::Test)
15-
16-
add_library(libcalcqt src/CalculatorWidget.cpp ${CALCQT_HEADERS})
3+
if(QT_LIBRARIES)
4+
add_library(libcalcqt src/CalculatorWidget.cpp src/CalculatorWidget.h)
5+
set_target_properties(libcalcqt PROPERTIES AUTOMOC ON)
6+
target_include_directories(libcalcqt PUBLIC src)
177
target_link_libraries(libcalcqt ${QT_LIBRARIES})
18-
19-
add_executable(calcqt ${CALCQT_SOURCES})
8+
9+
add_executable(calcqt src/CalcQt.cpp)
2010
target_link_libraries(calcqt libcalcqt ${QT_LIBRARIES})
21-
else()
22-
find_package(Qt4 COMPONENTS QtCore QtGui QtTest)
23-
if(QT4_FOUND)
24-
include(${QT_USE_FILE})
25-
qt4_wrap_cpp(CALCQT_HEADERS_MOC ${CALCQT_HEADERS})
26-
add_library(libcalcqt src/CalculatorWidget ${CALCQT_HEADERS_MOC})
27-
28-
add_executable(calcqt ${CALCQT_SOURCES} ${CALCQT_HEADERS_MOC})
29-
target_link_libraries(calcqt ${QT_LIBRARIES})
30-
endif()
31-
endif()
3211

33-
if(QT_LIBRARIES)
3412
if(Boost_UNIT_TEST_FRAMEWORK_FOUND)
35-
include_directories(${Boost_INCLUDE_DIRS})
3613
add_executable(BoostCalculatorQtSteps features/step_definitions/BoostCalculatorQtSteps)
37-
target_link_libraries(BoostCalculatorQtSteps libcalcqt ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${CUKE_LIBRARIES} ${QT_LIBRARIES})
14+
target_link_libraries(BoostCalculatorQtSteps libcalcqt ${CUKE_LIBRARIES} ${QT_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
3815
endif()
3916
if(GTEST_FOUND)
4017
add_executable(GTestCalculatorQtSteps features/step_definitions/GTestCalculatorQtSteps)

examples/FeatureShowcase/CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
project(FeatureShowcase)
22

3-
include_directories(${CUKE_INCLUDE_DIRS})
4-
53
if(GMOCK_FOUND)
64
function(add_cucumber_executable)
75
add_executable(FeatureShowcaseSteps ${ARGV})

travis.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/sh
22
set -e #break script on non-zero exitcode from any command
33
set -x #display command being executed
4+
45
gem install bundler
56
bundle install
67

@@ -11,6 +12,7 @@ cmake -E make_directory build
1112
cmake -E chdir build cmake \
1213
-G Ninja \
1314
-DCUKE_ENABLE_EXAMPLES=on \
15+
${QT_DIR:+"-DCMAKE_PREFIX_PATH=${QT_DIR}"} \
1416
${VALGRIND_TESTS:+"-DVALGRIND_TESTS=${VALGRIND_TESTS}"} \
1517
${GMOCK_PATH:-"-DGMOCK_VER=${GMOCK_VER}"} \
1618
${GMOCK_PATH:+"-DGMOCK_SRC_DIR=${GMOCK_PATH}"} \

0 commit comments

Comments
 (0)