Commit 477521c3 authored by Alexandre Leblanc's avatar Alexandre Leblanc
Browse files

First commit

parent de825711
......@@ -13,3 +13,8 @@ build/
# vim swap files
*.swp
.idea
.ycm_extra_conf.py
/build.sh
/cmake-build-debug/
[submodule "features/cucumber-tck"]
path = features/cucumber-tck
url = git://github.com/cucumber/cucumber-tck.git
[submodule "googletest"]
path = googletest
url = https://github.com/google/googletest.git
#cross compile options
set(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_CROSSCOMPILING TRUE)
INCLUDE(CMakeForceCompiler)
SET(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf)
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++-6)
set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc-6)
set(BOOST_INCLUDEDIR /usr/arm-linux-gnueabihf/include)
set(BOOST_LIBRARYDIR /usr/arm-linux-gnueabihf/lib)
\ No newline at end of file
......@@ -2,43 +2,24 @@ 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_BOOST ON 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")
set(GMOCK_DIR "" CACHE STRING "Google Mock framework sources path (otherwise downloaded)")
set(GOOGLETEST_DIR googletest )
set(GMOCK_VER "1.7.0" CACHE STRING "Google Mock framework version to be used")
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
#
# Generic Compiler Flags
#
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Weffc++")
# TODO: A better fix should handle ld's --as-needed flag
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker '--no-as-needed'")
elseif(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOMINMAX") # exclude M$ min/max macros
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /analyze")
endif()
#
# Boost
#
if(MSVC11)
# Boost 1.51 fixed a bug with MSVC11
message(STATUS "Forcing Boost 1.51+ on MSVC11")
set(BOOST_MIN_VERSION "1.51")
else()
set(BOOST_MIN_VERSION "1.40")
endif()
set(BOOST_MIN_VERSION "1.40")
set(CUKE_CORE_BOOST_LIBS thread system regex date_time program_options)
if(NOT CUKE_DISABLE_BOOST_TEST)
......@@ -51,10 +32,8 @@ if(CUKE_USE_STATIC_BOOST)
set(CUKE_DYNAMIC_BOOST_LIBS ${CUKE_TEST_BOOST_LIBS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_TEST_DYN_LINK")
if(NOT MSVC)
find_package(Threads)
set(CUKE_EXTRA_LIBRARIES ${CUKE_EXTRA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
endif()
find_package(Threads)
set(CUKE_EXTRA_LIBRARIES ${CUKE_EXTRA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
else()
set(CUKE_DYNAMIC_BOOST_LIBS ${CUKE_CORE_BOOST_LIBS} ${CUKE_TEST_BOOST_LIBS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_ALL_DYN_LINK")
......@@ -72,36 +51,66 @@ endif()
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
set(CUKE_EXTRA_LIBRARIES ${CUKE_EXTRA_LIBRARIES} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
set(CUKE_EXTRA_LIBRARIES
${CUKE_EXTRA_LIBRARIES}
${Boost_THREAD_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_REGEX_LIBRARY}
${Boost_DATE_TIME_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY})
endif()
#
# GTest
#
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)
if(GTEST_FOUND)
set(CUKE_GTEST_LIBRARIES
${GTEST_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
endif()
if(GMOCK_FOUND)
set(CUKE_GMOCK_LIBRARIES
${GTEST_BOTH_LIBRARIES}
${GMOCK_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
endif()
set(GTEST_DIR ${GOOGLETEST_DIR}/googletest)
set(GTEST_INCLUDE_DIR ${GTEST}/include)
set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIR})
set(GTEST_FOUND TRUE)
include_directories(
${GTEST_DIR}/include
${GTEST_DIR})
add_library(libgtest STATIC ${GTEST_DIR}/src/gtest-all.cc)
add_library(libgtest_main STATIC ${GTEST_DIR}/src/gtest_main.cc)
target_link_libraries(libgtest_main libgtest)
set(GTEST_BOTH_LIBRARIES libgtest libgtest_main)
set(CUKE_GTEST_LIBRARIES
${GTEST_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
set (GMOCK_DIR ${GOOGLETEST_DIR}/googlemock)
include_directories(${GMOCK_DIR}/include
${GMOCK_DIR}
${GTEST_DIR}/include
${GTEST_DIR})
add_library(libgmock STATIC
${GTEST_DIR}/src/gtest-all.cc
${GMOCK_DIR}/src/gmock-all.cc)
add_library(libgmock_main STATIC
${GTEST_DIR}/src/gtest-all.cc
${GMOCK_DIR}/src/gmock-all.cc
${GMOCK_DIR}/src/gmock_main.cc)
set(GMOCK_BOTH_LIBRARIES libgmock libgmock_main)
set(CUKE_GMOCK_LIBRARIES
${GTEST_BOTH_LIBRARIES}
${GMOCK_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
endif()
#
# Cucumber-Cpp
#
set(CUKE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
......@@ -111,65 +120,10 @@ set(CUKE_LIBRARIES cucumber-cpp ${CUKE_EXTRA_LIBRARIES})
add_subdirectory(src)
#
# Tests
#
if(CUKE_DISABLE_UNIT_TESTS)
message(STATUS "Skipping unit tests")
else()
enable_testing()
add_subdirectory(tests)
if(NOT DTEST_SOURCE AND NOT DTEST_BUILD_DIR)
set(DTEST_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/../sfl_cucumber_tests/features/linux_cpp)
set(DTEST_BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../sfl_cucumber_tests/features/linux_cpp/build)
endif()
if(CUKE_DISABLE_E2E_TESTS)
message(STATUS "Skipping end-to-end tests")
else()
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")
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})
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}
COMMAND ${CUCUMBER_RUBY}
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}/${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
)
endfunction(add_feature_target)
add_feature_target(features --format progress)
add_feature_target(features-pretty --format pretty)
add_feature_target(features-wip --format pretty --tags @wip)
else()
message(WARNING "Could not find Cucumber: skipping end-to-end tests")
endif()
add_subdirectory(${DTEST_SOURCE} ${DTEST_BUILD_DIR})
endif()
#
# Examples
#
if(CUKE_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()
Subproject commit a2b8a8e07628e5fd60644b6dd99c1b5e7d7f1f47
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