Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List headers in cmake #274

Merged
merged 2 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,41 @@ if(TARGET Qt5::Test)
list(APPEND CUKE_EXTRA_PRIVATE_LIBRARIES Qt5::Test)
endif()

if(CMAKE_EXTRA_GENERATOR OR MSVC_IDE)
message(STATUS "Adding header files to project")
file(GLOB_RECURSE CUKE_HEADERS "${CUKE_INCLUDE_DIR}/cucumber-cpp/*.hpp")
if(MSVC_IDE)
source_group("Header Files" FILES ${CUKE_HEADERS})
endif()
list(APPEND CUKE_SOURCES ${CUKE_HEADERS})
message(STATUS "Adding header files to project")
set(CUKE_HEADERS
../include/cucumber-cpp/autodetect.hpp
../include/cucumber-cpp/defs.hpp
../include/cucumber-cpp/generic.hpp
../include/cucumber-cpp/internal/ContextManager.hpp
../include/cucumber-cpp/internal/CukeCommands.hpp
../include/cucumber-cpp/internal/CukeEngine.hpp
../include/cucumber-cpp/internal/CukeEngineImpl.hpp
../include/cucumber-cpp/internal/Macros.hpp
../include/cucumber-cpp/internal/RegistrationMacros.hpp
../include/cucumber-cpp/internal/Scenario.hpp
../include/cucumber-cpp/internal/Table.hpp
../include/cucumber-cpp/internal/connectors/wire/ProtocolHandler.hpp
../include/cucumber-cpp/internal/connectors/wire/WireProtocol.hpp
../include/cucumber-cpp/internal/connectors/wire/WireProtocolCommands.hpp
../include/cucumber-cpp/internal/connectors/wire/WireServer.hpp
../include/cucumber-cpp/internal/defs.hpp
../include/cucumber-cpp/internal/drivers/BoostDriver.hpp
../include/cucumber-cpp/internal/drivers/DriverSelector.hpp
../include/cucumber-cpp/internal/drivers/GTestDriver.hpp
../include/cucumber-cpp/internal/drivers/GenericDriver.hpp
../include/cucumber-cpp/internal/drivers/QtTestDriver.hpp
../include/cucumber-cpp/internal/hook/HookMacros.hpp
../include/cucumber-cpp/internal/hook/HookRegistrar.hpp
../include/cucumber-cpp/internal/hook/Tag.hpp
../include/cucumber-cpp/internal/step/StepMacros.hpp
../include/cucumber-cpp/internal/step/StepManager.hpp
../include/cucumber-cpp/internal/utils/IndexSequence.hpp
../include/cucumber-cpp/internal/utils/Regex.hpp
)
if(MSVC_IDE)
source_group("Header Files" FILES ${CUKE_HEADERS})
endif()
list(APPEND CUKE_SOURCES ${CUKE_HEADERS})

# Library for unit tests relying on internals
add_library(cucumber-cpp-internal STATIC ${CUKE_SOURCES})
Expand Down
15 changes: 13 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
add_library(utils INTERFACE
utils/HookRegistrationFixture.hpp
utils/ContextManagerTestDouble.hpp
utils/DriverTestRunner.hpp
utils/CukeCommandsFixture.hpp
utils/StepManagerTestDouble.hpp
)
target_include_directories(utils INTERFACE
.
)

function(cuke_add_driver_test TEST_FILE)
get_filename_component(TEST_NAME ${TEST_FILE} NAME)
message(STATUS "Adding " ${TEST_NAME})
add_executable(${TEST_NAME} ${TEST_FILE}.cpp)
target_link_libraries(${TEST_NAME} PRIVATE cucumber-cpp-internal ${ARGN})
target_link_libraries(${TEST_NAME} PRIVATE cucumber-cpp-internal utils ${ARGN})
add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
endfunction()

Expand All @@ -11,7 +22,7 @@ if(TARGET GMock::Main)
get_filename_component(TEST_NAME ${TEST_FILE} NAME)
message(STATUS "Adding " ${TEST_NAME})
add_executable(${TEST_NAME} ${TEST_FILE}.cpp)
target_link_libraries(${TEST_NAME} PRIVATE cucumber-cpp-internal ${ARGN} GMock::Main)
target_link_libraries(${TEST_NAME} PRIVATE cucumber-cpp-internal utils ${ARGN} GMock::Main)
gtest_add_tests(${TEST_NAME} "" ${TEST_FILE}.cpp)
# Run all tests in executable at once too. This ensures that the used fixtures get tested
# properly too. Additionally gather the output in jUnit compatible output for CI.
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/ContextHandlingTest.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <gtest/gtest.h>

#include "../utils/ContextManagerTestDouble.hpp"
#include "utils/ContextManagerTestDouble.hpp"

using namespace std;
using namespace cucumber::internal;
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/HookRegistrationTest.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <gtest/gtest.h>

#include "../utils/HookRegistrationFixture.hpp"
#include "utils/HookRegistrationFixture.hpp"

#include <cucumber-cpp/internal/hook/HookMacros.hpp>

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/TaggedHookRegistrationTest.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <gtest/gtest.h>

#include "../utils/HookRegistrationFixture.hpp"
#include "utils/HookRegistrationFixture.hpp"
#include <cucumber-cpp/internal/hook/HookMacros.hpp>

BEFORE("@a") {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/drivers/BoostDriverTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <boost/test/unit_test.hpp>
#include <cucumber-cpp/autodetect.hpp>

#include "../../utils/DriverTestRunner.hpp"
#include "utils/DriverTestRunner.hpp"

using namespace cucumber;

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/drivers/GTestDriverTest.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <gtest/gtest.h>
#include <cucumber-cpp/autodetect.hpp>

#include "../../utils/DriverTestRunner.hpp"
#include "utils/DriverTestRunner.hpp"

using namespace cucumber;

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/drivers/GenericDriverTest.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <cucumber-cpp/generic.hpp>

#include "../../utils/DriverTestRunner.hpp"
#include "utils/DriverTestRunner.hpp"

using namespace cucumber;

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/drivers/QtTestDriverTest.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <QtTest>
#include <cucumber-cpp/autodetect.hpp>

#include "../../utils/DriverTestRunner.hpp"
#include "utils/DriverTestRunner.hpp"

using namespace cucumber;

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/ContextManagerTest.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <gtest/gtest.h>

#include "../utils/ContextManagerTestDouble.hpp"
#include "utils/ContextManagerTestDouble.hpp"

#include <memory>

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/CukeCommandsTest.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <gtest/gtest.h>

#include <cucumber-cpp/internal/step/StepMacros.hpp>
#include "../utils/CukeCommandsFixture.hpp"
#include "utils/CukeCommandsFixture.hpp"

#include <boost/config.hpp>

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/StepManagerTest.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <gtest/gtest.h>

#include "../utils/StepManagerTestDouble.hpp"
#include "utils/StepManagerTestDouble.hpp"

#include <map>

Expand Down
Loading