Skip to content

Commit

Permalink
CMake: reworked integration, fixed parser.hpp compiler warning with i…
Browse files Browse the repository at this point in the history
…nitialization order
  • Loading branch information
Joachim Schiele committed Jul 16, 2021
1 parent 4db1714 commit 866511a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
23 changes: 17 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ cmake_minimum_required(VERSION 3.0)

option(BUILD_SHARED_LIBS "Build shared library." OFF)

LIST(APPEND GHERKIN_CPP_SRS
src/compiler.cpp
src/parser.cpp
file(GLOB_RECURSE GHERKIN_CPP_SRS
src/*.cpp
)

file(GLOB_RECURSE GHERKIN_H_SRS
include/*.hpp
)

ADD_LIBRARY(gherkin-cpp ${GHERKIN_CPP_SRS})
Expand All @@ -14,11 +17,19 @@ ADD_LIBRARY(gherkin-cpp::gherkin-cpp ALIAS gherkin-cpp)
TARGET_INCLUDE_DIRECTORIES(gherkin-cpp
PUBLIC ${PROJECT_SOURCE_DIR}/include
)

ADD_SUBDIRECTORY(libs/fmem)
TARGET_LINK_LIBRARIES(gherkin-cpp PUBLIC fmem)
TARGET_LINK_LIBRARIES(gherkin-cpp PRIVATE fmem)

ADD_SUBDIRECTORY(libs/gherkin-c)
TARGET_LINK_LIBRARIES(gherkin-cpp PUBLIC gherkin)
TARGET_LINK_LIBRARIES(gherkin-cpp PRIVATE gherkin)

ADD_SUBDIRECTORY(test)

install(TARGETS gherkin-cpp
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

install(FILES
${GHERKIN_H_SRS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gherkin-cpp)
2 changes: 1 addition & 1 deletion include/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class parser {

private:
std::wstring language_;
std::unique_ptr<TokenMatcher, void (*)(TokenMatcher *)> token_matcher_;
std::unique_ptr<Builder, void (*)(Builder *)> builder_;
std::unique_ptr<Parser, void (*)(Parser *)> parser_;
std::unique_ptr<TokenMatcher, void (*)(TokenMatcher *)> token_matcher_;
};

} // v1
Expand Down
6 changes: 2 additions & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
ADD_EXECUTABLE(gherkin-cpp-test main.cpp)
TARGET_LINK_LIBRARIES(gherkin-cpp-test PUBLIC gherkin-cpp)

ADD_CUSTOM_TARGET(gherkin-cpp-test.run DEPENDS testgherkin-cpp-)
TARGET_LINK_LIBRARIES(gherkin-cpp-test PRIVATE gherkin-cpp)

FILE(COPY testdata DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

ADD_CUSTOM_TARGET(gherkin-cpp-test.run DEPENDS gherkin-cpp-test)
ADD_CUSTOM_COMMAND(
TARGET gherkin-cpp-test.run
POST_BUILD
Expand Down
4 changes: 2 additions & 2 deletions test/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class bcolors:
#print(target)
target_result = target+".result"
outfile = open(target_result, "w")
run_result = subprocess.run(["valgrind", "--leak-check=full", "--error-exitcode=-1", "./test", target], stdout=outfile, stderr=subprocess.DEVNULL)
run_result = subprocess.run(["valgrind", "--leak-check=full", "--error-exitcode=-1", "./gherkin-cpp-test", target], stdout=outfile, stderr=subprocess.DEVNULL)
#print(run_result.returncode)


Expand Down Expand Up @@ -58,7 +58,7 @@ class bcolors:
if overal_result == True:
os._exit(0)
else:
print("Compare the *.feature.out to the *.feature.result for each failed test")
print("Compare the *.feature.out to the *.feature.result for each failed test (in the build folder, since we are working on a copy)")
print("----------------------------------------------------------------------")
print("At least one test failed, so this script exits with an error (exit code 1)")
os._exit(1)

0 comments on commit 866511a

Please sign in to comment.