Utils: update of bitset to f9e019f5650a21d55add06fc7bd4fbc0859082a7.
[marnav.git] / src / CMakeLists.txt
blobd4a7e497160ad937ef6c6da9a73475d532bc8aca
1 cmake_minimum_required(VERSION 3.2)
3 option(ENABLE_STATIC "Enable static library" ON)
5 ### lib: marnav
7 if(${ENABLE_STATIC})
8         set(LIBRARY_TYPE "STATIC")
9 else()
10         set(LIBRARY_TYPE "SHARED")
11 endif()
12 message(STATUS "Build library type: ${LIBRARY_TYPE}")
14 message(STATUS "Build AIS support    : ${ENABLE_AIS}")
15 message(STATUS "Build SeaTalk support: ${ENABLE_SEATALK}")
16 message(STATUS "Build IO support     : ${ENABLE_IO}")
18 configure_file(
19         ${CMAKE_CURRENT_SOURCE_DIR}/marnav/version.hpp.in
20         ${CMAKE_CURRENT_BINARY_DIR}/marnav/version.hpp
21         )
23 set(SOURCES
24         # intentionally left blank
25         )
27 if(ENABLE_SEATALK)
28         set(SOURCES ${SOURCES}
29                 marnav/seatalk/seatalk.cpp
30                 marnav/seatalk/message.cpp
31                 marnav/seatalk/message_00.cpp
32                 marnav/seatalk/message_01.cpp
33                 marnav/seatalk/message_05.cpp
34                 marnav/seatalk/message_10.cpp
35                 marnav/seatalk/message_11.cpp
36                 marnav/seatalk/message_20.cpp
37                 marnav/seatalk/message_21.cpp
38                 marnav/seatalk/message_22.cpp
39                 marnav/seatalk/message_23.cpp
40                 marnav/seatalk/message_24.cpp
41                 marnav/seatalk/message_25.cpp
42                 marnav/seatalk/message_26.cpp
43                 marnav/seatalk/message_27.cpp
44                 marnav/seatalk/message_30.cpp
45                 marnav/seatalk/message_36.cpp
46                 marnav/seatalk/message_38.cpp
47                 marnav/seatalk/message_50.cpp
48                 marnav/seatalk/message_51.cpp
49                 marnav/seatalk/message_52.cpp
50                 marnav/seatalk/message_53.cpp
51                 marnav/seatalk/message_54.cpp
52                 marnav/seatalk/message_56.cpp
53                 marnav/seatalk/message_58.cpp
54                 marnav/seatalk/message_59.cpp
55                 marnav/seatalk/message_65.cpp
56                 marnav/seatalk/message_66.cpp
57                 marnav/seatalk/message_6c.cpp
58                 marnav/seatalk/message_86.cpp
59                 marnav/seatalk/message_87.cpp
60                 marnav/seatalk/message_89.cpp
61                 )
62 endif()
64 if(ENABLE_AIS)
65         set(SOURCES ${SOURCES}
66                 marnav/ais/ais.cpp
67                 marnav/ais/angle.cpp
68                 marnav/ais/name.cpp
69                 marnav/ais/message.cpp
70                 marnav/ais/message_01.cpp
71                 marnav/ais/message_02.cpp
72                 marnav/ais/message_03.cpp
73                 marnav/ais/message_04.cpp
74                 marnav/ais/message_05.cpp
75                 marnav/ais/message_09.cpp
76                 marnav/ais/message_10.cpp
77                 marnav/ais/message_11.cpp
78                 marnav/ais/message_18.cpp
79                 marnav/ais/message_19.cpp
80                 marnav/ais/message_21.cpp
81                 marnav/ais/message_22.cpp
82                 marnav/ais/message_23.cpp
83                 marnav/ais/message_24.cpp
84                 )
85 endif()
87 if(ENABLE_IO)
88         set(SOURCES ${SOURCES}
89                 marnav/io/serial.cpp
90                 marnav/io/nmea_reader.cpp
91                 marnav/io/default_nmea_reader.cpp
92                 )
94         if(ENABLE_SEATALK)
95                 set(SOURCES ${SOURCES}
96                         marnav/io/seatalk_reader.cpp
97                         marnav/io/default_seatalk_reader.cpp
98                         )
99         endif()
100 endif()
102 add_library(marnav ${LIBRARY_TYPE}
103         marnav/math/floatingpoint.hpp
104         marnav/math/vector.hpp
105         marnav/math/matrix.hpp
106         marnav/math/quaternion.hpp
107         marnav/utils/mmsi.cpp
108         marnav/utils/mmsi_country.cpp
109         marnav/geo/angle.cpp
110         marnav/geo/position.cpp
111         marnav/geo/region.cpp
112         marnav/geo/cpa.cpp
113         marnav/geo/geodesic.cpp
114         marnav/nmea/waypoint.cpp
115         marnav/nmea/talker_id.cpp
116         marnav/nmea/convert.cpp
117         marnav/nmea/manufacturer.cpp
118         marnav/nmea/checks.cpp
119         marnav/nmea/split.cpp
120         marnav/nmea/angle.cpp
121         marnav/nmea/string.cpp
122         marnav/nmea/name.cpp
123         marnav/nmea/io.cpp
124         marnav/nmea/date.cpp
125         marnav/nmea/time.cpp
126         marnav/nmea/checksum.cpp
127         marnav/nmea/sentence.cpp
128         marnav/nmea/detail.cpp
129         marnav/nmea/ais_helper.cpp
130         marnav/nmea/nmea.cpp
131         marnav/nmea/aam.cpp
132         marnav/nmea/alm.cpp
133         marnav/nmea/apa.cpp
134         marnav/nmea/apb.cpp
135         marnav/nmea/bod.cpp
136         marnav/nmea/bwc.cpp
137         marnav/nmea/bww.cpp
138         marnav/nmea/bwr.cpp
139         marnav/nmea/dbk.cpp
140         marnav/nmea/dbt.cpp
141         marnav/nmea/dpt.cpp
142         marnav/nmea/dsc.cpp
143         marnav/nmea/dse.cpp
144         marnav/nmea/dtm.cpp
145         marnav/nmea/fsi.cpp
146         marnav/nmea/gbs.cpp
147         marnav/nmea/gga.cpp
148         marnav/nmea/glc.cpp
149         marnav/nmea/gll.cpp
150         marnav/nmea/gns.cpp
151         marnav/nmea/grs.cpp
152         marnav/nmea/gsa.cpp
153         marnav/nmea/gst.cpp
154         marnav/nmea/gsv.cpp
155         marnav/nmea/gtd.cpp
156         marnav/nmea/hdg.cpp
157         marnav/nmea/hfb.cpp
158         marnav/nmea/hdm.cpp
159         marnav/nmea/hdt.cpp
160         marnav/nmea/hsc.cpp
161         marnav/nmea/its.cpp
162         marnav/nmea/lcd.cpp
163         marnav/nmea/msk.cpp
164         marnav/nmea/mss.cpp
165         marnav/nmea/mtw.cpp
166         marnav/nmea/mwd.cpp
167         marnav/nmea/mwv.cpp
168         marnav/nmea/osd.cpp
169         marnav/nmea/r00.cpp
170         marnav/nmea/rma.cpp
171         marnav/nmea/rmb.cpp
172         marnav/nmea/rmc.cpp
173         marnav/nmea/rot.cpp
174         marnav/nmea/rpm.cpp
175         marnav/nmea/rsa.cpp
176         marnav/nmea/rsd.cpp
177         marnav/nmea/rte.cpp
178         marnav/nmea/sfi.cpp
179         marnav/nmea/stn.cpp
180         marnav/nmea/tds.cpp
181         marnav/nmea/tfi.cpp
182         marnav/nmea/tll.cpp
183         marnav/nmea/tpc.cpp
184         marnav/nmea/tpr.cpp
185         marnav/nmea/tpt.cpp
186         marnav/nmea/ttm.cpp
187         marnav/nmea/vbw.cpp
188         marnav/nmea/vdm.cpp
189         marnav/nmea/vdo.cpp
190         marnav/nmea/vdr.cpp
191         marnav/nmea/vhw.cpp
192         marnav/nmea/vlw.cpp
193         marnav/nmea/vpw.cpp
194         marnav/nmea/vtg.cpp
195         marnav/nmea/vwr.cpp
196         marnav/nmea/wcv.cpp
197         marnav/nmea/wnc.cpp
198         marnav/nmea/wpl.cpp
199         marnav/nmea/xdr.cpp
200         marnav/nmea/xte.cpp
201         marnav/nmea/xtr.cpp
202         marnav/nmea/zda.cpp
203         marnav/nmea/zdl.cpp
204         marnav/nmea/zfo.cpp
205         marnav/nmea/ztg.cpp
206         marnav/nmea/pgrme.cpp
207         marnav/nmea/pgrmm.cpp
208         marnav/nmea/pgrmz.cpp
209         ${SOURCES}
210         )
212 target_include_directories(marnav
213         PRIVATE
214                 ${CMAKE_CURRENT_SOURCE_DIR}
215                 ${CMAKE_CURRENT_BINARY_DIR}
216         )
218 target_compile_options(marnav
219         PRIVATE
220                 -pipe
221                 -ggdb
222                 -Wall
223                 -Wextra
224                 -pedantic-errors
225                 -Wold-style-cast
226         )
227 if(ENABLE_PROFILING)
228         target_compile_options(marnav
229                 PRIVATE
230                         -pg
231                 )
232 endif()
233 if(ENABLE_BENCHMARK)
234         target_compile_options(marnav
235                 PRIVATE
236                         -fno-omit-frame-pointer
237                 )
238 endif()
239 if(ENABLE_WARNING_HELL)
240         message(STATUS "Behold: entering the hell of extended warnings")
241         target_compile_options(marnav
242                 PRIVATE
243                         # some are not enabled on purpose
244                         -Wcast-align
245                         -Wcast-qual
246                         -Werror
247                         -Wdisabled-optimization
248                         -Wfloat-equal
249                         -Wformat=2
250                         -Wformat-security
251                         -Wformat-y2k
252                         -Wimport
253                         -Winit-self
254                         -Winline
255                         -Wmissing-field-initializers
256                         -Wmissing-format-attribute
257                         -Wmissing-include-dirs
258                         -Wmissing-noreturn
259                         -Woverloaded-virtual
260                         -Wpacked
261                         -Wpointer-arith
262                         -Wredundant-decls
263                         -Wstrict-aliasing=2
264                         -Wswitch
265                         -Wunreachable-code
266                         -Wunused
267                         -Wunused-parameter
268                         -Wvariadic-macros
269                         -Wwrite-strings
270                         # explicitly disabled on purpose:
271                         #-Wconversion
272                         #-Wsign-conversion
273                         #-Wstack-protector
274                         -Wno-effc++
275                         -Wno-padded
276                         -Wno-long-long
277                         -Wno-unused-function
278                         -Wno-comment
279                         -Wno-format-nonliteral
280                         -Wno-shadow
281                         -Wno-switch-enum
282                         -Wno-switch-default
283                 )
284 endif()
286 if(ENABLE_SANITIZER)
287         message(STATUS "Sanitizer: enabled")
288         target_compile_options(marnav
289                 PRIVATE
290                         -fsanitize=address
291                         -fsanitize=undefined
292                 )
294         target_link_libraries(marnav
295                 asan
296                 ubsan
297                 )
298 endif()
300 if(build_type_lower MATCHES coverage)
301         message(STATUS "Coverage: enabled")
302         target_compile_options(marnav
303                 PRIVATE
304                         --coverage
305                         -fprofile-arcs
306                         -ftest-coverage
307                         -fno-inline
308                         -fno-inline-small-functions
309                         -fno-default-inline
310                 )
311 endif()
313 set_target_properties(marnav
314         PROPERTIES VERSION "${PROJECT_VERSION}"
315         SOVERSION "${PROJECT_VERSION}"
316         )
318 install(
319         TARGETS marnav
320         LIBRARY DESTINATION lib
321         ARCHIVE DESTINATION lib
322         RUNTIME DESTINATION bin
323         )
325 install(
326         FILES
327                 ${CMAKE_CURRENT_BINARY_DIR}/marnav/version.hpp
328         DESTINATION include/marnav
329         )
331 install(
332         FILES
333                 marnav/nmea/constants.hpp
334                 marnav/nmea/talker_id.hpp
335                 marnav/nmea/sentence_id.hpp
336                 marnav/nmea/convert.hpp
337                 marnav/nmea/waypoint.hpp
338                 marnav/nmea/manufacturer.hpp
339                 marnav/nmea/angle.hpp
340                 marnav/nmea/string.hpp
341                 marnav/nmea/name.hpp
342                 marnav/nmea/io.hpp
343                 marnav/nmea/date.hpp
344                 marnav/nmea/time.hpp
345                 marnav/nmea/checksum.hpp
346                 marnav/nmea/sentence.hpp
347                 marnav/nmea/detail.hpp
348                 marnav/nmea/ais_helper.hpp
349                 marnav/nmea/nmea.hpp
350                 marnav/nmea/aam.hpp
351                 marnav/nmea/alm.hpp
352                 marnav/nmea/apa.hpp
353                 marnav/nmea/apb.hpp
354                 marnav/nmea/bod.hpp
355                 marnav/nmea/bwc.hpp
356                 marnav/nmea/bww.hpp
357                 marnav/nmea/bwr.hpp
358                 marnav/nmea/dbk.hpp
359                 marnav/nmea/dbt.hpp
360                 marnav/nmea/dpt.hpp
361                 marnav/nmea/dsc.hpp
362                 marnav/nmea/dse.hpp
363                 marnav/nmea/dtm.hpp
364                 marnav/nmea/fsi.hpp
365                 marnav/nmea/gbs.hpp
366                 marnav/nmea/gga.hpp
367                 marnav/nmea/glc.hpp
368                 marnav/nmea/gll.hpp
369                 marnav/nmea/gns.hpp
370                 marnav/nmea/grs.hpp
371                 marnav/nmea/gsa.hpp
372                 marnav/nmea/gst.hpp
373                 marnav/nmea/gsv.hpp
374                 marnav/nmea/gtd.hpp
375                 marnav/nmea/hdg.hpp
376                 marnav/nmea/hfb.hpp
377                 marnav/nmea/hdm.hpp
378                 marnav/nmea/hdt.hpp
379                 marnav/nmea/hsc.hpp
380                 marnav/nmea/its.hpp
381                 marnav/nmea/lcd.hpp
382                 marnav/nmea/msk.hpp
383                 marnav/nmea/mss.hpp
384                 marnav/nmea/mtw.hpp
385                 marnav/nmea/mwd.hpp
386                 marnav/nmea/mwv.hpp
387                 marnav/nmea/osd.hpp
388                 marnav/nmea/r00.hpp
389                 marnav/nmea/rma.hpp
390                 marnav/nmea/rmb.hpp
391                 marnav/nmea/rmc.hpp
392                 marnav/nmea/rot.hpp
393                 marnav/nmea/rpm.hpp
394                 marnav/nmea/rsa.hpp
395                 marnav/nmea/rsd.hpp
396                 marnav/nmea/rte.hpp
397                 marnav/nmea/sfi.hpp
398                 marnav/nmea/stn.hpp
399                 marnav/nmea/tds.hpp
400                 marnav/nmea/tfi.hpp
401                 marnav/nmea/tll.hpp
402                 marnav/nmea/tpc.hpp
403                 marnav/nmea/tpr.hpp
404                 marnav/nmea/tpt.hpp
405                 marnav/nmea/ttm.hpp
406                 marnav/nmea/vbw.hpp
407                 marnav/nmea/vdm.hpp
408                 marnav/nmea/vdo.hpp
409                 marnav/nmea/vdr.hpp
410                 marnav/nmea/vhw.hpp
411                 marnav/nmea/vlw.hpp
412                 marnav/nmea/vpw.hpp
413                 marnav/nmea/vtg.hpp
414                 marnav/nmea/vwr.hpp
415                 marnav/nmea/wcv.hpp
416                 marnav/nmea/wnc.hpp
417                 marnav/nmea/wpl.hpp
418                 marnav/nmea/xdr.hpp
419                 marnav/nmea/xte.hpp
420                 marnav/nmea/xtr.hpp
421                 marnav/nmea/zda.hpp
422                 marnav/nmea/zdl.hpp
423                 marnav/nmea/zfo.hpp
424                 marnav/nmea/ztg.hpp
425                 marnav/nmea/pgrme.hpp
426         DESTINATION include/marnav/nmea
427         )
429 if(ENABLE_AIS)
430         install(
431                 FILES
432                         marnav/ais/ais.hpp
433                         marnav/ais/angle.hpp
434                         marnav/ais/name.hpp
435                         marnav/ais/message.hpp
436                         marnav/ais/message_01.hpp
437                         marnav/ais/message_02.hpp
438                         marnav/ais/message_03.hpp
439                         marnav/ais/message_04.hpp
440                         marnav/ais/message_05.hpp
441                         marnav/ais/message_09.hpp
442                         marnav/ais/message_10.hpp
443                         marnav/ais/message_11.hpp
444                         marnav/ais/message_18.hpp
445                         marnav/ais/message_19.hpp
446                         marnav/ais/message_21.hpp
447                         marnav/ais/message_22.hpp
448                         marnav/ais/message_23.hpp
449                         marnav/ais/message_24.hpp
450                 DESTINATION include/marnav/ais
451                 )
452 endif()
454 if(ENABLE_SEATALK)
455         install(
456                 FILES
457                         marnav/seatalk/key.hpp
458                         marnav/seatalk/equipment.hpp
459                         marnav/seatalk/seatalk.hpp
460                         marnav/seatalk/message.hpp
461                         marnav/seatalk/message_00.hpp
462                         marnav/seatalk/message_01.hpp
463                         marnav/seatalk/message_05.hpp
464                         marnav/seatalk/message_10.hpp
465                         marnav/seatalk/message_11.hpp
466                         marnav/seatalk/message_20.hpp
467                         marnav/seatalk/message_21.hpp
468                         marnav/seatalk/message_22.hpp
469                         marnav/seatalk/message_23.hpp
470                         marnav/seatalk/message_24.hpp
471                         marnav/seatalk/message_25.hpp
472                         marnav/seatalk/message_26.hpp
473                         marnav/seatalk/message_27.hpp
474                         marnav/seatalk/message_30.hpp
475                         marnav/seatalk/message_36.hpp
476                         marnav/seatalk/message_38.hpp
477                         marnav/seatalk/message_50.hpp
478                         marnav/seatalk/message_51.hpp
479                         marnav/seatalk/message_52.hpp
480                         marnav/seatalk/message_53.hpp
481                         marnav/seatalk/message_54.hpp
482                         marnav/seatalk/message_56.hpp
483                         marnav/seatalk/message_58.hpp
484                         marnav/seatalk/message_59.hpp
485                         marnav/seatalk/message_65.hpp
486                         marnav/seatalk/message_66.hpp
487                         marnav/seatalk/message_6c.hpp
488                         marnav/seatalk/message_86.hpp
489                         marnav/seatalk/message_87.hpp
490                         marnav/seatalk/message_89.hpp
491                 DESTINATION include/marnav/seatalk
492                 )
493 endif()
495 install(
496         FILES
497                 marnav/utils/unused.hpp
498                 marnav/utils/unique.hpp
499                 marnav/utils/bitset.hpp
500                 marnav/utils/bitset_string.hpp
501                 marnav/utils/optional.hpp
502                 marnav/utils/mmsi.hpp
503                 marnav/utils/mmsi_country.hpp
504         DESTINATION include/marnav/utils
505         )
507 install(
508         FILES
509                 marnav/math/floatingpoint.hpp
510                 marnav/math/vector.hpp
511                 marnav/math/matrix.hpp
512                 marnav/math/quaternion.hpp
513         DESTINATION include/marnav/math
514         )
516 install(
517         FILES
518                 marnav/geo/angle.hpp
519                 marnav/geo/position.hpp
520                 marnav/geo/region.hpp
521                 marnav/geo/cpa.hpp
522                 marnav/geo/geodesic.hpp
523         DESTINATION include/marnav/geo
524         )
526 if(ENABLE_IO)
527         install(
528                 FILES
529                         marnav/io/device.hpp
530                         marnav/io/serial.hpp
531                         marnav/io/nmea_reader.hpp
532                         marnav/io/default_nmea_reader.hpp
533                         marnav/io/default_nmea_serial.hpp
534                 DESTINATION include/marnav/io
535                 )
536         if(ENABLE_SEATALK)
537                 install(
538                         FILES
539                                 marnav/io/seatalk_reader.hpp
540                                 marnav/io/default_seatalk_reader.hpp
541                                 marnav/io/default_seatalk_serial.hpp
542                         DESTINATION include/marnav/io
543                         )
544         endif()
545 endif()
547 # stuff for the config and config-version files
548 set(INCLUDE_INSTALL_DIR include)
549 set(LIB_INSTALL_DIR lib)
550 include(CMakePackageConfigHelpers)
551 configure_package_config_file(
552         config.cmake.in
553         "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
554         INSTALL_DESTINATION "${LIB_INSTALL_DIR}/${PROJECT_NAME}/cmake"
555         PATH_VARS INCLUDE_INSTALL_DIR
556         )
557 write_basic_package_version_file(
558         "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
559         VERSION "${PROJECT_VERSION}"
560         COMPATIBILITY SameMajorVersion)
561 install(
562         FILES
563                 "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
564                 "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
565         DESTINATION
566                 "${LIB_INSTALL_DIR}/${PROJECT_NAME}/cmake"
567         )
569 ### bin: nmeasum
571 add_executable(nmeasum
572         nmeasum.cpp
573         )
575 target_include_directories(nmeasum PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
577 target_compile_options(nmeasum
578         PRIVATE
579                 -pipe
580                 -ggdb
581                 -Wall
582                 -Wextra
583                 -pedantic-errors
584         )
586 ### bin: nmeadump
588 if(ENABLE_AIS AND ENABLE_IO)
589         add_executable(nmeadump
590                 nmeadump.cpp
591                 )
593         target_include_directories(nmeadump
594                 PRIVATE
595                         ${CMAKE_CURRENT_SOURCE_DIR}
596                         ${CMAKE_CURRENT_SOURCE_DIR}/../extern
597                 )
599         target_compile_options(nmeadump
600                 PRIVATE
601                         -pipe
602                         -ggdb
603                         -Wall
604                         -Wextra
605                         -pedantic-errors
606                 )
608         target_link_libraries(nmeadump
609                 marnav
610                 )
611 endif()