This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCMakeLists.txt
141 lines (127 loc) · 4 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
PROJECT(gherkin C)
cmake_minimum_required(VERSION 3.0)
enable_testing()
# Install library & headers in your directory
#SET(CMAKE_INSTALL_PREFIX "")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
LIST(APPEND GHERKIN_SRS
src/file_reader.c
src/file_utf8_source.c
src/print_utilities.c
src/string_utilities.c
src/unicode_utilities.c
src/utf8_source.c
src/parser.c
src/token_scanner.c
src/file_token_scanner.c
src/string_token_scanner.c
src/token_matcher.c
src/token.c
src/token_queue.c
src/item_queue.c
src/gherkin_line.c
src/error.c
src/error_event.c
src/error_list.c
src/dialect.c
src/ast_builder.c
src/ast_node.c
src/gherkin_document.c
src/feature.c
src/rule.c
src/scenario.c
src/background.c
src/comment.c
src/data_table.c
src/doc_string.c
src/example_table.c
src/step.c
src/table_cell.c
src/table_row.c
src/tag.c
src/compiler.c
src/pickle.c
src/pickle_ast_node_id.c
src/pickle_cell.c
src/pickle_row.c
src/pickle_step.c
src/pickle_string.c
src/pickle_table.c
src/pickle_tag.c
src/event.c
src/gherkin_document_event.c
src/pickle_event.c
src/source_event.c
src/ast_printer.c
src/pickle_printer.c
src/incrementing_id_generator.c
)
LIST(APPEND GENERATE_TOKEN
src/token_formatter_builder.c
src/gherkin_generate_tokens.c
)
LIST(APPEND GHERKIN_CLI
src/gherkin_cli.c
)
add_library(gherkin ${GHERKIN_SRS})
include(CheckLibraryExists)
CHECK_LIBRARY_EXISTS(m log10 "" HAVE_LIB_M)
if (HAVE_LIB_M)
target_link_libraries(gherkin PRIVATE m)
endif (HAVE_LIB_M)
target_include_directories(gherkin PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/src>")
add_executable(gherkinexe ${GHERKIN_CLI})
target_link_libraries(gherkinexe gherkin)
target_include_directories(gherkinexe PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src)
add_executable(gherkin_generate_tokens ${GENERATE_TOKEN})
target_link_libraries(gherkin_generate_tokens gherkin)
file(GLOB GOOD_FEATURE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/../testdata/good/*.feature
)
file(GLOB BAD_FEATURE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/../testdata/bad/*.feature
)
add_custom_target(invo DEPENDS invo)
add_dependencies(invo gherkinexe)
FOREACH(ENTITY ${GOOD_FEATURE_FILES})
string(REPLACE "${PROJECT_SOURCE_DIR}" "" TEST_NAME "${ENTITY}")
add_test(NAME "${TEST_NAME}"
COMMAND gherkinexe ${ENTITY}
)
ENDFOREACH()
add_custom_command(
TARGET gherkinexe
COMMENT "Run tests"
POST_BUILD
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
)
############ Installation section ############
set(include_install_dir "include")
set(lib_install_dir "lib/")
set(bin_install_dir "bin/")
set(config_install_dir "lib/cmake/")
set(project_config "${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_NAME}Config.cmake")
set(targets_export_name "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")
configure_file("${PROJECT_SOURCE_DIR}/cmake/Config.cmake.in" "${project_config}" @ONLY)
# Install target (will install the library to specified CMAKE_INSTALL_PREFIX variable)
install(
TARGETS gherkin
EXPORT ${targets_export_name}
ARCHIVE DESTINATION ${lib_install_dir}
LIBRARY DESTINATION ${lib_install_dir}
RUNTIME DESTINATION ${lib_install_dir}
INCLUDES DESTINATION ${include_install_dir})
install(
DIRECTORY "${PROJECT_SOURCE_DIR}/include/"
DESTINATION ${include_install_dir}
FILES_MATCHING PATTERN "*.*h")
install(
FILES "${project_config}"
DESTINATION "${config_install_dir}")
install(
EXPORT "${targets_export_name}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}")