Commit b20b94f5 authored by Paolo Ambrosio's avatar Paolo Ambrosio
Browse files

Merge #113 'Fix Windows build'

parents ab3bcd6c 9ca99535
......@@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 2.8.12)
project(Cucumber-Cpp)
set(CUKE_USE_STATIC_BOOST ${MSVC} 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_CPPSPEC OFF CACHE BOOL "Disable CppSpec")
set(CUKE_DISABLE_GTEST OFF CACHE BOOL "Disable Google Test framework")
......@@ -11,7 +13,6 @@ set(CUKE_DISABLE_E2E_TESTS OFF CACHE BOOL "Disable end-to-end tests")
set(CUKE_ENABLE_EXAMPLES OFF CACHE BOOL "Enable the examples")
set(GMOCK_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")
set(VERBOSE OFF CACHE BOOL "Verbose output")
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
......@@ -60,11 +61,11 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_ALL_DYN_LINK")
endif()
set(Boost_USE_STATIC_RUNTIME OFF)
if(CUKE_STATIC_BOOST_LIBS)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost ${BOOST_MIN_VERSION} COMPONENTS ${CUKE_STATIC_BOOST_LIBS})
endif()
if(CUKE_DYNAMIC_BOOST_LIBS)
set(Boost_USE_STATIC_LIBS OFF)
find_package(Boost ${BOOST_MIN_VERSION} COMPONENTS ${CUKE_DYNAMIC_BOOST_LIBS})
......@@ -88,6 +89,7 @@ endif()
#
if(NOT CUKE_DISABLE_GTEST)
set(GTEST_USE_STATIC_LIBS ${CUKE_USE_STATIC_GTEST})
set(GMOCK_ROOT "${CMAKE_CURRENT_BINARY_DIR}/gmock")
find_package(GMock REQUIRED)
......@@ -130,29 +132,20 @@ endif()
if(CUKE_DISABLE_E2E_TESTS)
message(STATUS "Skipping end-to-end tests")
else()
find_program(BUNDLE bundle)
if(BUNDLE)
message(STATUS "Installing gem dependencies")
execute_process(COMMAND ${BUNDLE} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
else()
message(WARNING "Could not find Bundler: skipping Ruby Gem management")
endif()
find_program(CUCUMBER_RUBY cucumber)
if(CUCUMBER_RUBY)
message(STATUS "Found Cucumber")
set(CUKE_FEATURES_DIR ${CMAKE_SOURCE_DIR}/features)
set(CUKE_FEATURES_TMP ${CMAKE_BINARY_DIR}/tmp)
set(CUKE_TEST_FEATURES_DIR ${CUKE_FEATURES_TMP}/test_features)
set(CUKE_DYNAMIC_CPP_STEPS ${CUKE_TEST_FEATURES_DIR}/step_definitions/cpp_steps.cpp)
set(CUKE_FEATURES_DIR "${CMAKE_SOURCE_DIR}/features")
set(CUKE_FEATURES_TMP "${CMAKE_BINARY_DIR}/tmp")
set(CUKE_TEST_FEATURES_DIR "${CUKE_FEATURES_TMP}/test_features")
set(CUKE_DYNAMIC_CPP_STEPS "${CUKE_TEST_FEATURES_DIR}/step_definitions/cpp_steps.cpp")
string(REPLACE "/tmp" "${CMAKE_FILES_DIRECTORY}/e2e-steps.dir/tmp" CUKE_DYNAMIC_CPP_STEPS_OBJ "${CUKE_DYNAMIC_CPP_STEPS}${CMAKE_CXX_OUTPUT_EXTENSION}")
file(WRITE ${CUKE_DYNAMIC_CPP_STEPS})
add_executable(e2e-steps EXCLUDE_FROM_ALL ${CUKE_DYNAMIC_CPP_STEPS})
target_link_libraries(e2e-steps ${CUKE_LIBRARIES})
# TODO It does not escape paths
set(CUKE_COMPILE_DYNAMIC_CPP_STEPS "${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target e2e-steps")
set(CUKE_COMPILE_DYNAMIC_CPP_STEPS '"${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target e2e-steps')
function(add_feature_target TARGET_NAME)
add_custom_target(${TARGET_NAME}
......@@ -160,9 +153,10 @@ else()
TEST_FEATURES_DIR=${CUKE_TEST_FEATURES_DIR}
TMP_DIR=${CUKE_FEATURES_TMP}
DYNAMIC_CPP_STEPS_SRC=${CUKE_DYNAMIC_CPP_STEPS}
DYNAMIC_CPP_STEPS_EXE=${CMAKE_BINARY_DIR}/e2e-steps
DYNAMIC_CPP_STEPS_EXE=${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/e2e-steps
DYNAMIC_CPP_STEPS_OBJ=${CUKE_DYNAMIC_CPP_STEPS_OBJ}
COMPILE_DYNAMIC_CPP_STEPS=${CUKE_COMPILE_DYNAMIC_CPP_STEPS}
CUCUMBER_RUBY=${CUCUMBER_RUBY}
${ARGV1} ${ARGV2} ${ARGV3} ${ARGV4} ${ARGV5} ${ARGV6}
${CUKE_FEATURES_DIR}
DEPENDS cucumber-cpp
......
......@@ -21,7 +21,7 @@ It relies on a few libraries:
Optional library for Boost Test driver: *test*.
* [GTest](http://code.google.com/p/googletest/) 1.6 or later.
Optional for the GTest driver. By default downloaded and built by CMake.
* [CppSpec](https://github.com/tpuronen/cppspec) development branch.
* [CppSpec](https://github.com/tpuronen/cppspec) development branch.
Optional for the CppSpec driver.
* [GMock](http://code.google.com/p/googlemock/) 1.6 or later.
Optional for the internal test suite. By default downloaded and built by CMake.
......@@ -38,6 +38,13 @@ Cucumber-Cpp uses the wire protocol at the moment, so you will need
Cucumber-Ruby installed and available on the path. It is also needed
to run the functional test suite.
To install the Ruby prerequisites:
```
gem install bundler
bundle install
```
Building Cucumber-Cpp with tests and samples:
```
......
......@@ -7,7 +7,7 @@
#
# GMOCK_FOUND - Got the Google Mocking framework
# GMOCK_INCLUDE_DIRS - GMock include directory
# GTEST_INCLUDE_DIRS - GTest include direcotry
# GTEST_INCLUDE_DIRS - GTest include direcotry
#
# Also defines the library variables below as normal variables
#
......@@ -45,23 +45,23 @@
# Copyright 2000-2016 Kitware, Inc.
# Copyright 2000-2011 Insight Software Consortium
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
#
# * Neither the names of Kitware, Inc., the Insight Software Consortium,
# nor the names of their contributors may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -73,30 +73,30 @@
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#
# ------------------------------------------------------------------------------
#
#
# The above copyright and license notice applies to distributions of
# CMake in source and binary form. Some source files contain additional
# notices of original copyright by their contributors; see each source
# for details. Third-party software packages supplied with CMake under
# compatible licenses provide their own copyright notices documented in
# corresponding subdirectories.
#
#
# ------------------------------------------------------------------------------
#
#
# CMake was initially developed by Kitware with the following sponsorship:
#
#
# * National Library of Medicine at the National Institutes of Health
# as part of the Insight Segmentation and Registration Toolkit (ITK).
#
#
# * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
# Visualization Initiative.
#
#
# * National Alliance for Medical Image Computing (NAMIC) is funded by the
# National Institutes of Health through the NIH Roadmap for Medical Research,
# Grant U54 EB005149.
#
#
# * Kitware, Inc.
#=============================================================================
# Thanks to Daniel Blezek <blezek@gmail.com> for the GTEST_ADD_TESTS code
......@@ -142,10 +142,16 @@ else()
set(Suffix ".lib")
endif()
if("${GMOCK_SRC_DIR}" STREQUAL "")
if("${GMOCK_VER}" STREQUAL "")
if(GTEST_USE_STATIC_LIBS)
set(GTEST_CMAKE_ARGS -Dgtest_force_shared_crt:BOOL=ON -DBUILD_SHARED_LIBS=OFF)
else()
set(GTEST_CMAKE_ARGS -DBUILD_SHARED_LIBS=ON)
endif()
if("${GMOCK_SRC_DIR}" STREQUAL "")
if("${GMOCK_VER}" STREQUAL "")
set(GMOCK_VER "1.7.0")
endif()
endif()
message(STATUS "Downloading GMock / GTest version ${GMOCK_VER}")
ExternalProject_Add(
gmock
......@@ -155,6 +161,7 @@ if("${GMOCK_SRC_DIR}" STREQUAL "")
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON
CMAKE_ARGS ${GTEST_CMAKE_ARGS}
)
else()
Message(STATUS "Building Gmock / Gtest from dir ${GMOCK_SRC_DIR}")
......@@ -166,6 +173,7 @@ else()
LOG_DOWNLOAD OFF
LOG_CONFIGURE ON
LOG_BUILD ON
CMAKE_ARGS ${GTEST_CMAKE_ARGS}
)
endif()
......@@ -173,12 +181,8 @@ add_library(libgmock IMPORTED STATIC GLOBAL)
add_dependencies(libgmock gmock)
ExternalProject_Get_Property(gmock source_dir binary_dir)
if(MSVC)
set(MS_DIR "/${CMAKE_BUILD_TYPE}")
endif()
set(GTEST_LIB_DIR "${binary_dir}/gtest${MS_DIR}")
set(GMOCK_LIB_DIR "${binary_dir}${MS_DIR}")
set(GTEST_LIB_DIR "${binary_dir}/gtest/${CMAKE_CFG_INTDIR}")
set(GMOCK_LIB_DIR "${binary_dir}/${CMAKE_CFG_INTDIR}")
set_target_properties(libgmock PROPERTIES
"IMPORTED_LOCATION" "${GMOCK_LIB_DIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gmock.${Suffix}"
......@@ -219,4 +223,3 @@ if(GTEST_FOUND)
Message(STATUS "GTest libs: ${GTEST_BOTH_LIBRARIES}")
endif()
endif()
......@@ -253,6 +253,7 @@ EOF
STEP_DEFINITIONS_OBJ = ENV["DYNAMIC_CPP_STEPS_OBJ"]
STEP_DEFINITIONS_EXE = ENV["DYNAMIC_CPP_STEPS_EXE"]
COMPILE_STEP_DEFINITIONS_CMD = ENV["COMPILE_DYNAMIC_CPP_STEPS"]
CUCUMBER_RUBY = ENV["CUCUMBER_RUBY"]
WORLD_VARIABLE_LOG_FILE = "#{TMP_DIR}/world_variable.log"
WORLD_FUNCTION_LOG_FILE = "#{TMP_DIR}/world_function.log"
......@@ -320,7 +321,7 @@ EOF
end
def run_cucumber_test_feature(params)
run_simple "cucumber #{params} #{FEATURES_DIR}", false
run_simple "#{CUCUMBER_RUBY} #{params} #{FEATURES_DIR}", false
end
end
......
......@@ -10,7 +10,7 @@ After do
# for when there are no scenarios
if @steps_out
begin
Process.kill :SIGTERM, @steps_out.pid
Process.kill :SIGKILL, @steps_out.pid # :SIGTERM not supported on Windows
Process.wait @steps_out.pid
rescue Errno::ESRCH # exited already
rescue Errno::ECHILD # killed before wait call
......
#!/bin/sh
set -e #break script on non-zero exitcode from any command
gem install bundler
bundle install
cmake -E make_directory build
if [ -z ${GMOCK_PATH+x} ]; then
if [ -z ${GMOCK_PATH+x} ]; then
cmake -E chdir build cmake -DCUKE_ENABLE_EXAMPLES=on -DGMOCK_VER=${GMOCK_VER} ..
else
cmake -E chdir build cmake -DCUKE_ENABLE_EXAMPLES=on -DGMOCK_SRC_DIR=${GMOCK_PATH} ..
......@@ -12,14 +13,13 @@ cmake --build build
cmake --build build --target test
cmake --build build --target features
GTEST=build/examples/Calc/GTestCalculatorSteps
GTEST=build/examples/Calc/GTestCalculatorSteps
BOOST=build/examples/Calc/BoostCalculatorSteps
if [ -f $GTEST ]; then
$GTEST >/dev/null &
cucumber examples/Calc
fi
if [ -f $BOOST ]; then
if [ -f $BOOST ]; then
$BOOST >/dev/null &
cucumber examples/Calc
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment