General: separation of marav-io as a library
[marnav.git] / test / CMakeLists.txt
blob1959004d732fad9ac80bc9c12525b5467309d7ec
1 cmake_minimum_required(VERSION 3.19)
3 add_executable(testrunner)
5 target_sources(testrunner
6         PRIVATE
7                 marnav/ais/Test_ais.cpp
8                 marnav/ais/Test_ais_angle.cpp
9                 marnav/ais/Test_ais_binary_001_11.cpp
10                 marnav/ais/Test_ais_binary_200_10.cpp
11                 marnav/ais/Test_ais_message.cpp
12                 marnav/ais/Test_ais_message_01.cpp
13                 marnav/ais/Test_ais_message_02.cpp
14                 marnav/ais/Test_ais_message_03.cpp
15                 marnav/ais/Test_ais_message_04.cpp
16                 marnav/ais/Test_ais_message_05.cpp
17                 marnav/ais/Test_ais_message_06.cpp
18                 marnav/ais/Test_ais_message_07.cpp
19                 marnav/ais/Test_ais_message_08.cpp
20                 marnav/ais/Test_ais_message_09.cpp
21                 marnav/ais/Test_ais_message_10.cpp
22                 marnav/ais/Test_ais_message_11.cpp
23                 marnav/ais/Test_ais_message_12.cpp
24                 marnav/ais/Test_ais_message_13.cpp
25                 marnav/ais/Test_ais_message_14.cpp
26                 marnav/ais/Test_ais_message_17.cpp
27                 marnav/ais/Test_ais_message_18.cpp
28                 marnav/ais/Test_ais_message_19.cpp
29                 marnav/ais/Test_ais_message_20.cpp
30                 marnav/ais/Test_ais_message_21.cpp
31                 marnav/ais/Test_ais_message_22.cpp
32                 marnav/ais/Test_ais_message_23.cpp
33                 marnav/ais/Test_ais_message_24.cpp
34                 marnav/ais/Test_ais_rate_of_turn.cpp
35                 marnav/geo/Test_geo_angle.cpp
36                 marnav/geo/Test_geo_cpa.cpp
37                 marnav/geo/Test_geo_geodesic.cpp
38                 marnav/geo/Test_geo_region.cpp
39                 marnav/math/floatingpoint.cpp
40                 marnav/math/floatingpoint_ulps.cpp
41                 marnav/math/Test_math_floatingpoint.cpp
42                 marnav/math/Test_math_matrix.cpp
43                 marnav/math/Test_math_quaternion.cpp
44                 marnav/math/Test_math_vector.cpp
45                 marnav/nmea/Test_nmea.cpp
46                 marnav/nmea/Test_nmea_aam.cpp
47                 marnav/nmea/Test_nmea_ack.cpp
48                 marnav/nmea/Test_nmea_alm.cpp
49                 marnav/nmea/Test_nmea_alr.cpp
50                 marnav/nmea/Test_nmea_angle.cpp
51                 marnav/nmea/Test_nmea_apa.cpp
52                 marnav/nmea/Test_nmea_apb.cpp
53                 marnav/nmea/Test_nmea_bec.cpp
54                 marnav/nmea/Test_nmea_bod.cpp
55                 marnav/nmea/Test_nmea_bwc.cpp
56                 marnav/nmea/Test_nmea_bwr.cpp
57                 marnav/nmea/Test_nmea_bww.cpp
58                 marnav/nmea/Test_nmea_checksum.cpp
59                 marnav/nmea/Test_nmea_date.cpp
60                 marnav/nmea/Test_nmea_dbk.cpp
61                 marnav/nmea/Test_nmea_dbt.cpp
62                 marnav/nmea/Test_nmea_dpt.cpp
63                 marnav/nmea/Test_nmea_dsc.cpp
64                 marnav/nmea/Test_nmea_dse.cpp
65                 marnav/nmea/Test_nmea_dtm.cpp
66                 marnav/nmea/Test_nmea_duration.cpp
67                 marnav/nmea/Test_nmea_fsi.cpp
68                 marnav/nmea/Test_nmea_gbs.cpp
69                 marnav/nmea/Test_nmea_gga.cpp
70                 marnav/nmea/Test_nmea_glc.cpp
71                 marnav/nmea/Test_nmea_gll.cpp
72                 marnav/nmea/Test_nmea_gns.cpp
73                 marnav/nmea/Test_nmea_grs.cpp
74                 marnav/nmea/Test_nmea_gsa.cpp
75                 marnav/nmea/Test_nmea_gst.cpp
76                 marnav/nmea/Test_nmea_gsv.cpp
77                 marnav/nmea/Test_nmea_gtd.cpp
78                 marnav/nmea/Test_nmea_hdg.cpp
79                 marnav/nmea/Test_nmea_hdm.cpp
80                 marnav/nmea/Test_nmea_hdt.cpp
81                 marnav/nmea/Test_nmea_hfb.cpp
82                 marnav/nmea/Test_nmea_hsc.cpp
83                 marnav/nmea/Test_nmea_io.cpp
84                 marnav/nmea/Test_nmea_its.cpp
85                 marnav/nmea/Test_nmea_lcd.cpp
86                 marnav/nmea/Test_nmea_manufacturer.cpp
87                 marnav/nmea/Test_nmea_mob.cpp
88                 marnav/nmea/Test_nmea_msk.cpp
89                 marnav/nmea/Test_nmea_mss.cpp
90                 marnav/nmea/Test_nmea_mta.cpp
91                 marnav/nmea/Test_nmea_mtw.cpp
92                 marnav/nmea/Test_nmea_mwd.cpp
93                 marnav/nmea/Test_nmea_mwv.cpp
94                 marnav/nmea/Test_nmea_osd.cpp
95                 marnav/nmea/Test_nmea_pgrme.cpp
96                 marnav/nmea/Test_nmea_pgrmm.cpp
97                 marnav/nmea/Test_nmea_pgrmz.cpp
98                 marnav/nmea/Test_nmea_r00.cpp
99                 marnav/nmea/Test_nmea_rma.cpp
100                 marnav/nmea/Test_nmea_rmb.cpp
101                 marnav/nmea/Test_nmea_rmc.cpp
102                 marnav/nmea/Test_nmea_rot.cpp
103                 marnav/nmea/Test_nmea_route.cpp
104                 marnav/nmea/Test_nmea_rpm.cpp
105                 marnav/nmea/Test_nmea_rsa.cpp
106                 marnav/nmea/Test_nmea_rsd.cpp
107                 marnav/nmea/Test_nmea_rte.cpp
108                 marnav/nmea/Test_nmea_sentence.cpp
109                 marnav/nmea/Test_nmea_sfi.cpp
110                 marnav/nmea/Test_nmea_split.cpp
111                 marnav/nmea/Test_nmea_stalk.cpp
112                 marnav/nmea/Test_nmea_stn.cpp
113                 marnav/nmea/Test_nmea_tag_block.cpp
114                 marnav/nmea/Test_nmea_tds.cpp
115                 marnav/nmea/Test_nmea_tep.cpp
116                 marnav/nmea/Test_nmea_tfi.cpp
117                 marnav/nmea/Test_nmea_time.cpp
118                 marnav/nmea/Test_nmea_tll.cpp
119                 marnav/nmea/Test_nmea_tpc.cpp
120                 marnav/nmea/Test_nmea_tpr.cpp
121                 marnav/nmea/Test_nmea_tpt.cpp
122                 marnav/nmea/Test_nmea_ttm.cpp
123                 marnav/nmea/Test_nmea_vbw.cpp
124                 marnav/nmea/Test_nmea_vdm.cpp
125                 marnav/nmea/Test_nmea_vdo.cpp
126                 marnav/nmea/Test_nmea_vdr.cpp
127                 marnav/nmea/Test_nmea_version.cpp
128                 marnav/nmea/Test_nmea_vhw.cpp
129                 marnav/nmea/Test_nmea_vlw.cpp
130                 marnav/nmea/Test_nmea_vpw.cpp
131                 marnav/nmea/Test_nmea_vtg.cpp
132                 marnav/nmea/Test_nmea_vwe.cpp
133                 marnav/nmea/Test_nmea_vwr.cpp
134                 marnav/nmea/Test_nmea_waypoint.cpp
135                 marnav/nmea/Test_nmea_wcv.cpp
136                 marnav/nmea/Test_nmea_wdc.cpp
137                 marnav/nmea/Test_nmea_wdr.cpp
138                 marnav/nmea/Test_nmea_wnc.cpp
139                 marnav/nmea/Test_nmea_wpl.cpp
140                 marnav/nmea/Test_nmea_xdr.cpp
141                 marnav/nmea/Test_nmea_xte.cpp
142                 marnav/nmea/Test_nmea_xtr.cpp
143                 marnav/nmea/Test_nmea_zda.cpp
144                 marnav/nmea/Test_nmea_zdl.cpp
145                 marnav/nmea/Test_nmea_zfi.cpp
146                 marnav/nmea/Test_nmea_zfo.cpp
147                 marnav/nmea/Test_nmea_zlz.cpp
148                 marnav/nmea/Test_nmea_zpi.cpp
149                 marnav/nmea/Test_nmea_zta.cpp
150                 marnav/nmea/Test_nmea_zte.cpp
151                 marnav/nmea/Test_nmea_ztg.cpp
152                 marnav/seatalk/Test_seatalk_message.cpp
153                 marnav/seatalk/Test_seatalk_message_00.cpp
154                 marnav/seatalk/Test_seatalk_message_01.cpp
155                 marnav/seatalk/Test_seatalk_message_05.cpp
156                 marnav/seatalk/Test_seatalk_message_10.cpp
157                 marnav/seatalk/Test_seatalk_message_11.cpp
158                 marnav/seatalk/Test_seatalk_message_20.cpp
159                 marnav/seatalk/Test_seatalk_message_21.cpp
160                 marnav/seatalk/Test_seatalk_message_22.cpp
161                 marnav/seatalk/Test_seatalk_message_23.cpp
162                 marnav/seatalk/Test_seatalk_message_24.cpp
163                 marnav/seatalk/Test_seatalk_message_25.cpp
164                 marnav/seatalk/Test_seatalk_message_26.cpp
165                 marnav/seatalk/Test_seatalk_message_27.cpp
166                 marnav/seatalk/Test_seatalk_message_30.cpp
167                 marnav/seatalk/Test_seatalk_message_36.cpp
168                 marnav/seatalk/Test_seatalk_message_38.cpp
169                 marnav/seatalk/Test_seatalk_message_50.cpp
170                 marnav/seatalk/Test_seatalk_message_51.cpp
171                 marnav/seatalk/Test_seatalk_message_52.cpp
172                 marnav/seatalk/Test_seatalk_message_53.cpp
173                 marnav/seatalk/Test_seatalk_message_54.cpp
174                 marnav/seatalk/Test_seatalk_message_56.cpp
175                 marnav/seatalk/Test_seatalk_message_58.cpp
176                 marnav/seatalk/Test_seatalk_message_59.cpp
177                 marnav/seatalk/Test_seatalk_message_65.cpp
178                 marnav/seatalk/Test_seatalk_message_66.cpp
179                 marnav/seatalk/Test_seatalk_message_6c.cpp
180                 marnav/seatalk/Test_seatalk_message_86.cpp
181                 marnav/seatalk/Test_seatalk_message_87.cpp
182                 marnav/seatalk/Test_seatalk_message_89.cpp
183                 marnav/units/detail/basic_quantity_cmp.cpp
184                 marnav/units/detail/basic_quantity.cpp
185                 marnav/units/detail/basic_quantity_fnc.cpp
186                 marnav/units/detail/basic_quantity_ops.cpp
187                 marnav/units/detail/basic_unit_cmp.cpp
188                 marnav/units/detail/basic_unit.cpp
189                 marnav/units/detail/basic_unit_fnc.cpp
190                 marnav/units/detail/basic_unit_ops.cpp
191                 marnav/units/detail/dimension.cpp
192                 marnav/units/detail/units.cpp
193                 marnav/units/Test_basic_unit.cpp
194                 marnav/units/Test_basic_quantity.cpp
195                 marnav/units/Test_custom_numeric_type.cpp
196                 marnav/utils/Test_utils_bitset.cpp
197                 marnav/utils/Test_utils_mmsi.cpp
198                 marnav/utils/Test_utils_mmsi_country.cpp
199         )
201 if(ENABLE_IO)
202         target_sources(testrunner
203                 PRIVATE
204                         marnav-io/Test_io_nmea_reader.cpp
205                         marnav-io/Test_io_seatalk_reader.cpp
206                 )
207 endif()
209 target_include_directories(testrunner
210         PRIVATE
211                 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
212                 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../src>
213                 $<BUILD_INTERFACE:${CMAKE_HOME_DIRECTORY}/src>
214         )
216 target_link_libraries(testrunner
217         marnav::marnav
218         marnav::marnav-io
219         googletest::gtest
220         googletest::gmock
221         googletest::gtest_main
222         googletest::gmock_main
223         pthread
224         )
226 add_test(
227         NAME unittest-testrunner
228         COMMAND testrunner
229         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
230         )
232 add_custom_target(testrunner_runtest
233         COMMAND testrunner --gtest_shuffle
234         DEPENDS testrunner
235         WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
236         )
238 add_custom_target(unittest)
239 add_dependencies(unittest testrunner_runtest)
241 execute_process(
242         COMMAND ${CMAKE_COMMAND} -E tar xzf "${CMAKE_CURRENT_SOURCE_DIR}/marnav/ais/ais-sample.tar.gz"
243         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
244         )
246 add_executable(test-ais-sample
247         test-ais-sample.cpp
248         )
250 target_include_directories(test-ais-sample
251         PRIVATE $<BUILD_INTERFACE:${CMAKE_HOME_DIRECTORY}/src>)
253 target_link_libraries(test-ais-sample PRIVATE marnav::marnav)
255 add_test(
256         NAME integrationtest-test-ais-sample
257         COMMAND test-ais-sample
258         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
259         )
261 execute_process(
262         COMMAND ${CMAKE_COMMAND} -E tar xzf "${CMAKE_CURRENT_SOURCE_DIR}/marnav/nmea/nmea-sample.tar.gz"
263         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
264         )
266 add_executable(test-nmea-sample test-nmea-sample.cpp)
268 target_include_directories(test-nmea-sample
269         PRIVATE $<BUILD_INTERFACE:${CMAKE_HOME_DIRECTORY}/src>)
271 target_link_libraries(test-nmea-sample PRIVATE marnav::marnav)
273 add_test(
274         NAME integrationtest-test-nmea-sample
275         COMMAND test-nmea-sample
276         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
277         )
279 # excluded with coverage builds, does not make sense otherwise
280 if(NOT CMAKE_BUILD_TYPE MATCHES Coverage AND ENABLE_TESTS_BENCHMARK)
281         macro(setup_benchmark NAME SOURCE)
282                 add_executable(${NAME} ${SOURCE})
283                 target_include_directories(${NAME}
284                         PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src>)
285                 target_link_libraries(${NAME} marnav::marnav benchmark::benchmark pthread)
286         endmacro()
288         setup_benchmark(benchmark_nmea_io marnav-io/Benchmark_nmea_io.cpp)
289         setup_benchmark(benchmark_nmea_split marnav/nmea/Benchmark_nmea_split.cpp)
290         setup_benchmark(benchmark_nmea_checksum marnav/nmea/Benchmark_nmea_checksum.cpp)
291         setup_benchmark(benchmark_nmea_manufacturer marnav/nmea/Benchmark_nmea_manufacturer.cpp)
292         setup_benchmark(benchmark_nmea_sentence marnav/nmea/Benchmark_nmea_sentence.cpp)
293         setup_benchmark(benchmark_ais_message marnav/ais/Benchmark_ais_message.cpp)
294 endif()