-
Notifications
You must be signed in to change notification settings - Fork 0
/
project_config_embeddable.cmake
2690 lines (2292 loc) · 105 KB
/
project_config_embeddable.cmake
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#######################################################################
## CMake Macros for an embeddable project
##
## Author: Denis Arnaud
## Date: July 2011
#######################################################################
###################################################################
## Project Configuration ##
###################################################################
##
# Set the project names
macro (set_project_names _project_name_param)
# Set the pretty name
string (TOUPPER ${_project_name_param} _pretty_name_tmp)
if (${ARGC} GREATER 1)
set (_pretty_name_tmp ${ARGV1})
endif (${ARGC} GREATER 1)
set (PACKAGE_PRETTY_NAME "${_pretty_name_tmp}" CACHE INTERNAL "Description")
# Set the lowercase project name
string (TOLOWER "${_project_name_param}" _package_tmp)
set (PACKAGE "${_package_tmp}" CACHE INTERNAL "Description")
# Set the uppercase project name
string (TOUPPER "${_project_name_param}" _package_name_tmp)
set (PACKAGE_NAME "${_package_name_tmp}" CACHE INTERNAL "Description")
# Set the project name
project (${PACKAGE})
endmacro (set_project_names)
##
# Set the project brief
macro (set_project_brief _project_brief)
set (PACKAGE_BRIEF ${_project_brief})
endmacro (set_project_brief)
##
# Set the project versions
macro (set_project_versions _major _minor _patch)
set (_full_version ${_major}.${_minor}.${_patch})
#
set (${PROJECT_NAME}_VERSION_MAJOR ${_major})
set (${PROJECT_NAME}_VERSION_MINOR ${_minor})
set (${PROJECT_NAME}_VERSION_PATCH ${_patch})
set (${PROJECT_NAME}_VERSION ${_full_version})
#
set (PACKAGE_VERSION ${_full_version})
# Note that the soname can be different from the version. The soname
# should change only when the ABI compatibility is no longer guaranteed.
set (GENERIC_LIB_VERSION ${_full_version})
set (GENERIC_LIB_SOVERSION ${_major}.${_minor})
endmacro (set_project_versions)
##
# Set a few options:
# * BUILD_SHARED_LIBS - Whether or not to build shared libraries
# * CMAKE_BUILD_TYPE - Debug or release
# * CMAKE_INSTALL_PREFIX - Where to install the deliverable parts
# * CMAKE_INSTALL_RPATH - The list of paths to be used by the linker
# * CMAKE_INSTALL_RPATH_USE_LINK_PATH
# - Whether or not to set the run-path/rpath within
# the (executable and library) binaries
# * ENABLE_TEST - Whether or not to build and check the unit tests
# * INSTALL_DOC - Whether or not to build and install the documentation
# * INSTALL_LIB_DIR - Installation directory for the libraries
# * INSTALL_BIN_DIR - Installation directory for the binaries
# * INSTALL_INCLUDE_DIR - Installation directory for the header files
# * INSTALL_DATA_DIR - Installation directory for the data files
# * INSTALL_SAMPLE_DIR - Installation directory for the (CSV) sample files
# * RUN_GCOV - Whether or not to perform code coverage
#
macro (set_project_options _build_doc _enable_tests _run_gcov)
# Shared libraries
option (BUILD_SHARED_LIBS "Set to OFF to build static libraries" ON)
# Set default cmake build type to Debug (None Debug Release RelWithDebInfo
# MinSizeRel)
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Debug")
endif()
# Set default install prefix to project root directory
if (CMAKE_INSTALL_PREFIX STREQUAL "/usr/local")
set (CMAKE_INSTALL_PREFIX "/usr")
endif()
# Unit tests (thanks to CMake/CTest)
option (ENABLE_TEST "Set to OFF to skip build/check unit tests"
${_enable_tests})
# Documentation
option (INSTALL_DOC "Set to OFF to skip build/install Documentation"
${_build_doc})
# Initialise a few variables
set (DOXYGEN_OUTPUT_REL)
set (REFMAN_TEX)
set (REFMAN_PDF)
set (CSS_ALL_TARGETS)
set (IMG_ALL_TARGETS)
set (MAN_ALL_TARGETS)
# Set the library installation directory (either 32 or 64 bits)
set (LIBDIR "lib${LIB_SUFFIX}" CACHE PATH
"Library directory name, either lib or lib64")
# Offer the user the choice of overriding the installation directories
set (INSTALL_LIB_DIR ${LIBDIR} CACHE PATH
"Installation directory for libraries")
set (INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
set (INSTALL_INCLUDE_DIR include CACHE PATH
"Installation directory for header files")
set (INSTALL_DATA_DIR share CACHE PATH "Installation directory for data files")
set (INSTALL_SAMPLE_DIR share/${PROJECT_NAME}/samples CACHE PATH
"Installation directory for (CSV) sample files")
set (INSTALL_ETC_DIR etc CACHE PATH "Installation directory for Config files")
# GCOV
option (RUN_GCOV "Set to OFF to skip code coverage" ${_run_gcov})
# Make relative paths absolute (needed later on)
foreach (_path_type LIB BIN INCLUDE DATA SAMPLE)
set (var INSTALL_${_path_type}_DIR)
if (NOT IS_ABSOLUTE "${${var}}")
set (${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif ()
endforeach (_path_type)
# When the install directory is the canonical one (i.e., /usr), the
# run-path/rpath must be set in all the (executable and library)
# binaries, so that the dynamic loader can find the dependencies
# without the user having to set the LD_LIBRARY_PATH environment
# variable.
if (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
set (CMAKE_INSTALL_RPATH "")
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH OFF)
else()
set (CMAKE_INSTALL_RPATH ${INSTALL_LIB_DIR})
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
endif()
# Define STDAIR_SAMPLE_DIR if the project is STDAIR
if ("${PROJECT_NAME}" STREQUAL "stdair")
set (STDAIR_SAMPLE_DIR ${INSTALL_SAMPLE_DIR})
endif ("${PROJECT_NAME}" STREQUAL "stdair")
##
# Basic documentation (i.e., AUTHORS, NEWS, README, INSTALL)
set (DOC_INSTALL_FILE INSTALL)
if (NOT EXISTS ${DOC_INSTALL_FILE})
unset (DOC_INSTALL_FILE)
endif (NOT EXISTS ${DOC_INSTALL_FILE})
set (DOC_NEWS_FILE NEWS)
if (NOT EXISTS ${DOC_NEWS_FILE})
unset (DOC_NEWS_FILE)
endif (NOT EXISTS ${DOC_NEWS_FILE})
set (BASICDOC_FILES AUTHORS ${DOC_NEWS_FILE} README ${DOC_INSTALL_FILE})
set (BASICDOC_PATH "share/doc/${PACKAGE}-${PACKAGE_VERSION}")
endmacro (set_project_options)
#
macro (install_basic_documentation)
install (FILES ${BASICDOC_FILES} DESTINATION ${BASICDOC_PATH})
endmacro (install_basic_documentation)
#
macro (store_in_cache)
# Force some variables that could be defined in the command line to be
# written to cache
set (PACKAGE_VERSION "${PACKAGE_VERSION}" CACHE STRING
"Version of the project/package")
set (BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS}" CACHE BOOL
"Set to OFF to build static libraries" FORCE)
set (CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE PATH
"Where to install ${PROJECT_NAME}" FORCE)
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" CACHE PATH
"Run-path for the library/executable binaries" FORCE)
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH "${CMAKE_INSTALL_RPATH_USE_LINK_PATH}"
CACHE BOOL
"Whether to set the run-path for the library/executable binaries" FORCE)
set (CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING
"C++ compilation flags" FORCE)
set (COMPILE_FLAGS "${COMPILE_FLAGS}" CACHE STRING
"Supplementary C++ compilation flags" FORCE)
set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" CACHE PATH
"Path to custom CMake Modules" FORCE)
set (ENABLE_TEST "${ENABLE_TEST}" CACHE BOOL
"Set to OFF to skip build/check unit tests" FORCE)
set (INSTALL_DOC "${INSTALL_DOC}" CACHE BOOL
"Set to OFF to skip build/install Documentation" FORCE)
set (RUN_GCOV "${RUN_GCOV}" CACHE BOOL
"Set to OFF to skip coverage tests" FORCE)
endmacro (store_in_cache)
#####################################
## Packaging ##
#####################################
#
macro (packaging_init _project_name)
set (CPACK_PACKAGE_NAME "${_project_name}")
set (CPACK_PACKAGE_DESCRIPTION "${PACKAGE_BRIEF}")
endmacro (packaging_init)
#
macro (packaging_set_summary _project_summary)
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "${_project_summary}")
endmacro (packaging_set_summary)
#
macro (packaging_set_contact _project_contact)
set (CPACK_PACKAGE_CONTACT "${_project_contact}")
endmacro (packaging_set_contact)
#
macro (packaging_set_vendor _project_vendor)
set (CPACK_PACKAGE_VENDOR "${_project_vendor}")
endmacro (packaging_set_vendor)
# Both parameters are semi-colon sepetated lists of the types of
# packages to generate, e.g., "TGZ;TBZ2"
macro (packaging_set_other_options _package_type_list _source_package_type_list)
#
set (CPACK_PACKAGE_VERSION_MAJOR ${${PROJECT_NAME}_VERSION_MAJOR})
set (CPACK_PACKAGE_VERSION_MINOR ${${PROJECT_NAME}_VERSION_MINOR})
#set (CPACK_PACKAGE_VERSION_PATCH ${${PROJECT_NAME}_VERSION_PATCH})
set (CPACK_PACKAGE_VERSION_PATCH ${GIT_REVISION})
set (CPACK_PACKAGE_VERSION ${${PROJECT_NAME}_VERSION})
# Basic documentation
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/README)
message (FATAL_ERROR "A README file must be defined and located at the root directory")
endif (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/README)
set (CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README)
set (CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README)
# Licence
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
message (FATAL_ERROR "A licence file, namely COPYING, must be defined and located at the root directory")
endif (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
set (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
##
# Reset the generators for the binary packages
# Available types of package: DEB, RPM, STGZ, TZ, TGZ, TBZ2
set (CPACK_GENERATOR "${_package_type_list}")
#set (CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.6), libgcc1 (>= 1:4.1)")
##
# Source packages
# Available types of package: TZ, TGZ, TBZ2
set (CPACK_SOURCE_GENERATOR "${_source_package_type_list}")
set (CPACK_SOURCE_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}"
CACHE INTERNAL "tarball basename")
set (AUTOTOOLS_IGNRD "/tmp/;/tmp2/;/autom4te\\\\.cache/;autogen\\\\.sh$")
set (PACK_IGNRD
"${CMAKE_CURRENT_BINARY_DIR};${CPACK_PACKAGE_NAME}\\\\.spec;\\\\.gz$;\\\\.bz2$")
set (EDIT_IGNRD "\\\\.swp$;\\\\.#;/#;~$")
set (SCM_IGNRD
"/CVS/;/\\\\.svn/;/\\\\.bzr/;/\\\\.hg/;/\\\\.git/;\\\\.gitignore$")
set (PYTHON_IGNRD "\\\\.pyc$;\\\\.pyo$")
set (JS_IGNRD "/browser/js/libs;/browser/js/mylibs;/browser/libs")
set (CPACK_SOURCE_IGNORE_FILES
"${AUTOTOOLS_IGNRD};${SCM_IGNRD};${EDIT_IGNRD};${PACK_IGNRD};${PYTHON_IGNRD};${JS_IGNRD}"
CACHE STRING "CPACK will ignore these files")
#set (CPACK_SOURCE_IGNORE_DIRECTORY ${CPACK_SOURCE_IGNORE_FILES} .git)
# Initialise the source package generator with the variables above
include (InstallRequiredSystemLibraries)
include (CPack)
# Add a 'dist' target, similar to what is given by GNU Autotools
add_custom_target (dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
##
# Reset the generator types for the binary packages. Indeed, the variable
# has been reset by "include (CPack)".
set (CPACK_GENERATOR "${_package_type_list}")
endmacro (packaging_set_other_options)
###################################################################
## Dependencies ##
###################################################################
# ~~~~~~~~ Wrapper ~~~~~~~~
macro (get_external_libs)
# CMake scripts, to find some dependencies (e.g., Boost, MySQL, SOCI)
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/config/)
#
set (PROJ_DEP_LIBS_FOR_LIB "")
set (PROJ_DEP_LIBS_FOR_BIN "")
set (PROJ_DEP_LIBS_FOR_TST "")
foreach (_arg ${ARGV})
string (TOLOWER ${_arg} _arg_lower_full)
# Extract the name of the external dependency
string (REGEX MATCH "^[a-z]+" _arg_lower ${_arg_lower_full})
# Extract the required version of the external dependency
string (REGEX MATCH "[0-9._-]+$" _arg_version ${_arg_lower_full})
if (${_arg_lower} STREQUAL "git")
get_git (${_arg_version})
endif (${_arg_lower} STREQUAL "git")
if (${_arg_lower} STREQUAL "gcov")
get_gcov (${_arg_version})
endif (${_arg_lower} STREQUAL "gcov")
if (${_arg_lower} STREQUAL "lcov")
get_lcov (${_arg_version})
endif (${_arg_lower} STREQUAL "lcov")
if (${_arg_lower} STREQUAL "python")
get_python (${_arg_version})
endif (${_arg_lower} STREQUAL "python")
if (${_arg_lower} STREQUAL "icu")
get_icu (${_arg_version})
endif (${_arg_lower} STREQUAL "icu")
if (${_arg_lower} STREQUAL "zeromq")
get_zeromq (${_arg_version})
endif (${_arg_lower} STREQUAL "zeromq")
if (${_arg_lower} STREQUAL "boost")
get_boost (${_arg_version})
endif (${_arg_lower} STREQUAL "boost")
if (${_arg_lower} STREQUAL "xapian")
get_xapian (${_arg_version})
endif (${_arg_lower} STREQUAL "xapian")
if (${_arg_lower} STREQUAL "readline")
get_readline (${_arg_version})
endif (${_arg_lower} STREQUAL "readline")
if (${_arg_lower} STREQUAL "curses")
get_curses (${_arg_version})
endif (${_arg_lower} STREQUAL "curses")
if (${_arg_lower} STREQUAL "mysql")
get_mysql (${_arg_version})
endif (${_arg_lower} STREQUAL "mysql")
if (${_arg_lower} STREQUAL "soci")
get_soci (${_arg_version})
endif (${_arg_lower} STREQUAL "soci")
if (${_arg_lower} STREQUAL "stdair")
get_stdair (${_arg_version})
endif (${_arg_lower} STREQUAL "stdair")
if (${_arg_lower} STREQUAL "sevmgr")
get_sevmgr (${_arg_version})
endif (${_arg_lower} STREQUAL "sevmgr")
if (${_arg_lower} STREQUAL "trademgen")
get_trademgen (${_arg_version})
endif (${_arg_lower} STREQUAL "trademgen")
if (${_arg_lower} STREQUAL "travelccm")
get_travelccm (${_arg_version})
endif (${_arg_lower} STREQUAL "travelccm")
if (${_arg_lower} STREQUAL "airsched")
get_airsched (${_arg_version})
endif (${_arg_lower} STREQUAL "airsched")
if (${_arg_lower} STREQUAL "airrac")
get_airrac (${_arg_version})
endif (${_arg_lower} STREQUAL "airrac")
if (${_arg_lower} STREQUAL "rmol")
get_rmol (${_arg_version})
endif (${_arg_lower} STREQUAL "rmol")
if (${_arg_lower} STREQUAL "airinv")
get_airinv (${_arg_version})
endif (${_arg_lower} STREQUAL "airinv")
if (${_arg_lower} STREQUAL "avlcal")
get_avlcal (${_arg_version})
endif (${_arg_lower} STREQUAL "avlcal")
if (${_arg_lower} STREQUAL "simfqt")
get_simfqt (${_arg_version})
endif (${_arg_lower} STREQUAL "simfqt")
if (${_arg_lower} STREQUAL "simlfs")
get_simlfs (${_arg_version})
endif (${_arg_lower} STREQUAL "simlfs")
if (${_arg_lower} STREQUAL "simcrs")
get_simcrs (${_arg_version})
endif (${_arg_lower} STREQUAL "simcrs")
if (${_arg_lower} STREQUAL "tvlsim")
get_tvlsim (${_arg_version})
endif (${_arg_lower} STREQUAL "tvlsim")
if (${_arg_lower} STREQUAL "doxygen")
get_doxygen (${_arg_version})
endif (${_arg_lower} STREQUAL "doxygen")
endforeach (_arg)
endmacro (get_external_libs)
# ~~~~~~~~~~ Git ~~~~~~~~~~
macro (get_git)
message (STATUS "Requires Git without specifying any version")
find_package (Git)
if (Git_FOUND)
Git_WC_INFO (${CMAKE_CURRENT_SOURCE_DIR} PROJ)
set (GIT_REVISION ${PROJ_WC_REVISION_HASH})
message (STATUS "Current Git revision name: ${PROJ_WC_REVISION_NAME}")
endif (Git_FOUND)
endmacro (get_git)
# ~~~~~~~~~~ Gcov ~~~~~~~~~~
macro (get_gcov)
if (${RUN_GCOV} STREQUAL "ON")
message (STATUS "Requires gcov without specifying any version")
find_package (GCOV)
if (GCOV_FOUND)
GCOV_WC_INFO (${CMAKE_CURRENT_SOURCE_DIR} PROJ)
set (GCOV_REVISION ${PROJ_WC_REVISION_HASH})
message (STATUS "Current gcov revision name: ${PROJ_WC_REVISION_NAME}")
endif (GCOV_FOUND)
endif (${RUN_GCOV} STREQUAL "ON")
endmacro (get_gcov)
# ~~~~~~~~~~ Lcov ~~~~~~~~~~
macro (get_lcov)
if (${RUN_GCOV} STREQUAL "ON")
message (STATUS "Requires lcov without specifying any version")
find_package (LCOV)
if (LCOV_FOUND)
LCOV_WC_INFO (${CMAKE_CURRENT_SOURCE_DIR} PROJ)
set (LCOV_REVISION ${PROJ_WC_REVISION_HASH})
message (STATUS "Current lcov revision name: ${PROJ_WC_REVISION_NAME}")
endif (LCOV_FOUND)
endif (${RUN_GCOV} STREQUAL "ON")
endmacro (get_lcov)
# ~~~~~~~~~~ Python ~~~~~~~~~
macro (get_python)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires PythonLibs-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires PythonLibs without specifying any version")
endif (${ARGC} GREATER 0)
# The first check searches for the libraries and include paths.
# However, on some older versions (e.g., on RedHat/CentOS 5.x),
# only the static library is searched.
find_package (PythonLibs ${_required_version} REQUIRED)
# The second check is to get the dynamic library for sure.
find_package (PythonLibsWrapper ${_required_version} REQUIRED)
if (PYTHONLIBS_FOUND)
# Derive the version of Python (for whatever reason, FindPythonLibs
# does not seem to provide that version variable.
get_filename_component (PYTHONLIBS_LIB_FILENAME ${PYTHON_LIBRARIES} NAME)
string (REGEX REPLACE "^libpython([0-9]+.[0-9]+).*$" "\\1"
PYTHONLIBS_VERSION "${PYTHONLIBS_LIB_FILENAME}")
message (STATUS "Found PythonLibs ${PYTHONLIBS_VERSION}")
# Update the list of include directories for the project
include_directories (${PYTHON_INCLUDE_DIRS})
# Update the list of dependencies for the project
list (APPEND PROJ_DEP_LIBS_FOR_LIB ${PYTHON_LIBRARIES})
else (PYTHONLIBS_FOUND)
message (FATAL_ERROR "Python libraries are missing. Please install them (e.g., 'python-devel' for the Fedora/RedHat package)")
endif (PYTHONLIBS_FOUND)
endmacro (get_python)
# ~~~~~~~~~~ ICU ~~~~~~~~~
macro (get_icu)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires ICU-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires ICU without specifying any version")
endif (${ARGC} GREATER 0)
#
set (ICU_REQUIRED_COMPONENTS i18n uc data)
find_package (ICU ${_required_version}
COMPONENTS ${ICU_REQUIRED_COMPONENTS} REQUIRED)
icudebug (ICU_I18N_FOUND)
if (ICU_FOUND)
#
#if (ICU_I18N_FOUND)
# icudebug (ICU_I18N_FOUND)
#endif (ICU_I18N_FOUND)
# Update the list of include directories for the project
include_directories (${ICU_INCLUDE_DIRS})
# Update the list of dependencies for the project
list (APPEND PROJ_DEP_LIBS_FOR_LIB ${ICU_LIBRARIES})
endif (ICU_FOUND)
endmacro (get_icu)
# ~~~~~~~~~~ ZeroMQ ~~~~~~~~~
macro (get_zeromq)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires ZeroMQ-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires ZeroMQ without specifying any version")
endif (${ARGC} GREATER 0)
find_package (ZeroMQ ${_required_version} REQUIRED)
if (ZEROMQ_FOUND)
# Update the list of include directories for the project
include_directories (${ZeroMQ_INCLUDE_DIR})
# Update the list of dependencies for the project
list (APPEND PROJ_DEP_LIBS_FOR_LIB ${ZeroMQ_LIBRARIES})
endif (ZEROMQ_FOUND)
endmacro (get_zeromq)
# ~~~~~~~~~~ BOOST ~~~~~~~~~~
#
macro (register_boost_lib _boost_lib_list_name _boost_lib_list)
# Update the list of library dependencies for the project
foreach (_lib_cpt ${_boost_lib_list})
string (TOUPPER ${_lib_cpt} _lib_cpt_up)
if (Boost_${_lib_cpt_up}_LIBRARY)
# Update the list of dependencies for the project
list (APPEND ${_boost_lib_list_name} ${Boost_${_lib_cpt_up}_LIBRARY})
# Update the list of libraries to be displayed
list (APPEND BOOST_REQUIRED_LIBS ${Boost_${_lib_cpt_up}_LIBRARY})
endif (Boost_${_lib_cpt_up}_LIBRARY)
endforeach (_lib_cpt ${_boost_lib_list})
endmacro (register_boost_lib _boost_lib_list_name _boost_lib_list)
#
macro (get_boost)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires Boost-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires Boost without specifying any version")
endif (${ARGC} GREATER 0)
#
# Note: ${Boost_DATE_TIME_LIBRARY} and ${Boost_PROGRAM_OPTIONS_LIBRARY}
# are already set by ${SOCIMYSQL_LIBRARIES} and/or ${SOCI_LIBRARIES}.
#
set (Boost_USE_STATIC_LIBS OFF)
set (Boost_USE_MULTITHREADED ON)
set (Boost_USE_STATIC_RUNTIME OFF)
set (BOOST_REQUIRED_COMPONENTS_FOR_LIB
date_time iostreams serialization filesystem system locale python)
set (BOOST_REQUIRED_COMPONENTS_FOR_BIN regex program_options)
set (BOOST_REQUIRED_COMPONENTS_FOR_TST unit_test_framework)
set (BOOST_REQUIRED_COMPONENTS ${BOOST_REQUIRED_COMPONENTS_FOR_LIB}
${BOOST_REQUIRED_COMPONENTS_FOR_BIN} ${BOOST_REQUIRED_COMPONENTS_FOR_TST})
# The first check is for the required components.
find_package (Boost COMPONENTS ${BOOST_REQUIRED_COMPONENTS})
# Fix a bug for some old CMake package finder scripts (e.g., on Fedora 15)
if (Boost_VERSION)
set (Boost_FOUND ON)
endif (Boost_VERSION)
# The second check is for the required version (FindBoostWrapper.cmake is
# provided by us). Indeed, the Fedora/RedHat FindBoost.cmake does not seem
# to provide version enforcement.
find_package (BoostWrapper ${_required_version} REQUIRED)
if (Boost_FOUND)
# Update the list of include directories for the project
include_directories (${Boost_INCLUDE_DIRS})
# For display purposes
set (BOOST_REQUIRED_LIBS "")
# Update the list of library dependencies for the project
register_boost_lib ("PROJ_DEP_LIBS_FOR_LIB"
"${BOOST_REQUIRED_COMPONENTS_FOR_LIB}")
# Update the list of binary dependencies for the project
register_boost_lib ("PROJ_DEP_LIBS_FOR_BIN"
"${BOOST_REQUIRED_COMPONENTS_FOR_BIN}")
# Update the list of test dependencies for the project
register_boost_lib ("PROJ_DEP_LIBS_FOR_TST"
"${BOOST_REQUIRED_COMPONENTS_FOR_TST}")
endif (Boost_FOUND)
endmacro (get_boost)
# ~~~~~~~~~~ Xapian ~~~~~~~~~
macro (get_xapian)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires Xapian-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires Xapian without specifying any version")
endif (${ARGC} GREATER 0)
# The first check is to get Xapian installation details
if (${CMAKE_VERSION} VERSION_LESS 2.8.0)
set (Xapian_DIR /usr/${LIBDIR}/cmake/xapian)
endif (${CMAKE_VERSION} VERSION_LESS 2.8.0)
find_package (Xapian)
# The second check is for the required version (FindXapianWrapper.cmake is
# provided by us). Indeed, the Fedora/RedHat xapian-config.cmake does not seem
# to provide version enforcement.
find_package (XapianWrapper ${_required_version} REQUIRED)
if (XAPIAN_FOUND)
# Update the list of include directories for the project
include_directories (${XAPIAN_INCLUDE_DIR})
# Update the list of dependencies for the project
list (APPEND PROJ_DEP_LIBS_FOR_LIB ${XAPIAN_LIBRARIES})
endif (XAPIAN_FOUND)
endmacro (get_xapian)
# ~~~~~~~~~~ Readline ~~~~~~~~~
macro (get_readline)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires Readline-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires Readline without specifying any version")
endif (${ARGC} GREATER 0)
set (READLINE_FOUND False)
find_package (Readline ${_required_version} REQUIRED)
if (READLINE_LIBRARY)
set (READLINE_FOUND True)
endif (READLINE_LIBRARY)
if (READLINE_FOUND)
# Update the list of include directories for the project
include_directories (${READLINE_INCLUDE_DIR})
# Update the list of dependencies for the project
list (APPEND PROJ_DEP_LIBS_FOR_LIB ${READLINE_LIBRARY})
endif (READLINE_FOUND)
endmacro (get_readline)
# ~~~~~~~~~~ (N)Curses ~~~~~~~~~
macro (get_curses)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires (N)Curses-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires (N)Curses without specifying any version")
endif (${ARGC} GREATER 0)
set (CURSES_FOUND False)
set (CURSES_NEED_NCURSES True)
find_package (Curses ${_required_version} REQUIRED)
if (CURSES_LIBRARY)
set (CURSES_FOUND True)
endif (CURSES_LIBRARY)
if (CURSES_FOUND)
# Update the list of include directories for the project
include_directories (${CURSES_INCLUDE_DIR})
# Update the list of dependencies for the project
list (APPEND PROJ_DEP_LIBS_FOR_LIB ${CURSES_LIBRARY})
endif (CURSES_FOUND)
endmacro (get_curses)
# ~~~~~~~~~~ MySQL ~~~~~~~~~
macro (get_mysql)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires MySQL-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires MySQL without specifying any version")
endif (${ARGC} GREATER 0)
find_package (MySQL ${_required_version} REQUIRED)
if (MYSQL_FOUND)
# Update the list of include directories for the project
include_directories (${MYSQL_INCLUDE_DIR})
# Update the list of dependencies for the project
set (PROJ_DEP_LIBS_FOR_LIB ${PROJ_DEP_LIBS_FOR_LIB} ${MYSQL_LIBRARIES})
endif (MYSQL_FOUND)
endmacro (get_mysql)
# ~~~~~~~~~~ SOCI ~~~~~~~~~~
macro (get_soci)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires SOCI-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires SOCI without specifying any version")
endif (${ARGC} GREATER 0)
find_package (SOCIMySQL ${_required_version} REQUIRED)
if (SOCIMYSQL_FOUND)
#
message (STATUS "Found SOCI with MySQL back-end support version:"
" ${SOCI_HUMAN_VERSION}")
# Update the list of include directories for the project
include_directories (${SOCI_INCLUDE_DIR})
include_directories (${SOCIMYSQL_INCLUDE_DIR})
# Update the list of dependencies for the project
list (APPEND PROJ_DEP_LIBS_FOR_LIB ${SOCI_LIBRARIES} ${SOCIMYSQL_LIBRARIES})
endif (SOCIMYSQL_FOUND)
endmacro (get_soci)
# ~~~~~~~~~~ Doxygen ~~~~~~~~~
macro (get_doxygen)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires Doxygen-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires Doxygen without specifying any version")
endif (${ARGC} GREATER 0)
# The first check is to get Doxygen installation details
find_package (Doxygen)
# The second check is for the required version (FindDoxygenWrapper.cmake is
# provided by us). Indeed, the Fedora/RedHat FindDoxygen.cmake does not seem
# to provide version enforcement.
find_package (DoxygenWrapper ${_required_version} REQUIRED)
endmacro (get_doxygen)
# ~~~~~~~~~~ StdAir ~~~~~~~~~
macro (get_stdair)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires StdAir-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires StdAir without specifying any version")
endif (${ARGC} GREATER 0)
find_package (StdAir ${_required_version} REQUIRED
HINTS ${WITH_STDAIR_PREFIX})
if (StdAir_FOUND)
#
message (STATUS "Found StdAir version: ${STDAIR_VERSION}")
# Update the list of include directories for the project
include_directories (${STDAIR_INCLUDE_DIRS})
# Update the list of dependencies for the project
set (PROJ_DEP_LIBS_FOR_LIB ${PROJ_DEP_LIBS_FOR_LIB} ${STDAIR_LIBRARIES})
else (StdAir_FOUND)
set (ERROR_MSG "The StdAir library cannot be found. If it is installed in")
set (ERROR_MSG "${ERROR_MSG} a in a non standard directory, just invoke")
set (ERROR_MSG "${ERROR_MSG} 'cmake' specifying the -DWITH_STDAIR_PREFIX=")
set (ERROR_MSG "${ERROR_MSG}<StdAir install path> variable.")
message (FATAL_ERROR "${ERROR_MSG}")
endif (StdAir_FOUND)
endmacro (get_stdair)
# ~~~~~~~~~~ SEvMgr ~~~~~~~~~
macro (get_sevmgr)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires SEvMgr-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires SEvMgr without specifying any version")
endif (${ARGC} GREATER 0)
find_package (SEvMgr ${_required_version} REQUIRED
HINTS ${WITH_SEVMGR_PREFIX})
if (SEvMgr_FOUND)
#
message (STATUS "Found SEvMgr version: ${SEVMGR_VERSION}")
# Update the list of include directories for the project
include_directories (${SEVMGR_INCLUDE_DIRS})
# Update the list of dependencies for the project
set (PROJ_DEP_LIBS_FOR_LIB ${PROJ_DEP_LIBS_FOR_LIB} ${SEVMGR_LIBRARIES})
else (SEvMgr_FOUND)
set (ERROR_MSG "The SEvMgr library cannot be found. If it is installed in")
set (ERROR_MSG "${ERROR_MSG} a in a non standard directory, just invoke")
set (ERROR_MSG "${ERROR_MSG} 'cmake' specifying the -DWITH_SEVMGR_PREFIX=")
set (ERROR_MSG "${ERROR_MSG}<SEvMgr install path> variable.")
message (FATAL_ERROR "${ERROR_MSG}")
endif (SEvMgr_FOUND)
endmacro (get_sevmgr)
# ~~~~~~~~~~ TraDemGen ~~~~~~~~~
macro (get_trademgen)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires TraDemGen-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires TraDemGen without specifying any version")
endif (${ARGC} GREATER 0)
find_package (TraDemGen ${_required_version} REQUIRED
HINTS ${WITH_TRADEMGEN_PREFIX})
if (TraDemGen_FOUND)
#
message (STATUS "Found TraDemGen version: ${TRADEMGEN_VERSION}")
# Update the list of include directories for the project
include_directories (${TRADEMGEN_INCLUDE_DIRS})
# Update the list of dependencies for the project
set (PROJ_DEP_LIBS_FOR_LIB ${PROJ_DEP_LIBS_FOR_LIB} ${TRADEMGEN_LIBRARIES})
else (TraDemGen_FOUND)
set (ERROR_MSG "The TraDemGen library cannot be found. If it is installed in")
set (ERROR_MSG "${ERROR_MSG} a in a non standard directory, just invoke")
set (ERROR_MSG "${ERROR_MSG} 'cmake' specifying the -DWITH_TRADEMGEN_PREFIX=")
set (ERROR_MSG "${ERROR_MSG}<TraDemGen install path> variable.")
message (FATAL_ERROR "${ERROR_MSG}")
endif (TraDemGen_FOUND)
endmacro (get_trademgen)
# ~~~~~~~~~~ TravelCCM ~~~~~~~~~
macro (get_travelccm)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires TravelCCM-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires TravelCCM without specifying any version")
endif (${ARGC} GREATER 0)
find_package (TravelCCM ${_required_version} REQUIRED
HINTS ${WITH_TRAVELCCM_PREFIX})
if (TravelCCM_FOUND)
#
message (STATUS "Found TravelCCM version: ${TRAVELCCM_VERSION}")
# Update the list of include directories for the project
include_directories (${TRAVELCCM_INCLUDE_DIRS})
# Update the list of dependencies for the project
set (PROJ_DEP_LIBS_FOR_LIB ${PROJ_DEP_LIBS_FOR_LIB} ${TRAVELCCM_LIBRARIES})
else (TravelCCM_FOUND)
set (ERROR_MSG "The TravelCCM library cannot be found. If it is installed in")
set (ERROR_MSG "${ERROR_MSG} a in a non standard directory, just invoke")
set (ERROR_MSG "${ERROR_MSG} 'cmake' specifying the -DWITH_TRAVELCCM_PREFIX=")
set (ERROR_MSG "${ERROR_MSG}<TravelCCM install path> variable.")
message (FATAL_ERROR "${ERROR_MSG}")
endif (TravelCCM_FOUND)
endmacro (get_travelccm)
# ~~~~~~~~~~ AirSched ~~~~~~~~~
macro (get_airsched)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires AirSched-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires AirSched without specifying any version")
endif (${ARGC} GREATER 0)
find_package (AirSched ${_required_version} REQUIRED
HINTS ${WITH_AIRSCHED_PREFIX})
if (AirSched_FOUND)
#
message (STATUS "Found AirSched version: ${AIRSCHED_VERSION}")
# Update the list of include directories for the project
include_directories (${AIRSCHED_INCLUDE_DIRS})
# Update the list of dependencies for the project
set (PROJ_DEP_LIBS_FOR_LIB ${PROJ_DEP_LIBS_FOR_LIB} ${AIRSCHED_LIBRARIES})
else (AirSched_FOUND)
set (ERROR_MSG "The AirSched library cannot be found. If it is installed")
set (ERROR_MSG "${ERROR_MSG} in a in a non standard directory, just invoke")
set (ERROR_MSG "${ERROR_MSG} 'cmake' specifying the -DWITH_AIRSCHED_PREFIX=")
set (ERROR_MSG "${ERROR_MSG}<AirSched install path> variable.")
message (FATAL_ERROR "${ERROR_MSG}")
endif (AirSched_FOUND)
endmacro (get_airsched)
# ~~~~~~~~~~ AirRAC ~~~~~~~~~
macro (get_airrac)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires AirRAC-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires AirRAC without specifying any version")
endif (${ARGC} GREATER 0)
find_package (AirRAC ${_required_version} REQUIRED
HINTS ${WITH_AIRRAC_PREFIX})
if (AirRAC_FOUND)
#
message (STATUS "Found AirRAC version: ${AIRRAC_VERSION}")
# Update the list of include directories for the project
include_directories (${AIRRAC_INCLUDE_DIRS})
# Update the list of dependencies for the project
set (PROJ_DEP_LIBS_FOR_LIB ${PROJ_DEP_LIBS_FOR_LIB} ${AIRRAC_LIBRARIES})
else (AirRAC_FOUND)
set (ERROR_MSG "The AirRAC library cannot be found. If it is installed in")
set (ERROR_MSG "${ERROR_MSG} a in a non standard directory, just invoke")
set (ERROR_MSG "${ERROR_MSG} 'cmake' specifying the -DWITH_AIRRAC_PREFIX=")
set (ERROR_MSG "${ERROR_MSG}<AirRAC install path> variable.")
message (FATAL_ERROR "${ERROR_MSG}")
endif (AirRAC_FOUND)
endmacro (get_airrac)
# ~~~~~~~~~~ RMOL ~~~~~~~~~
macro (get_rmol)
unset (_required_version)
if (${ARGC} GREATER 0)
set (_required_version ${ARGV0})
message (STATUS "Requires RMOL-${_required_version}")
else (${ARGC} GREATER 0)
message (STATUS "Requires RMOL without specifying any version")
endif (${ARGC} GREATER 0)
find_package (RMOL ${_required_version} REQUIRED
HINTS ${WITH_RMOL_PREFIX})
if (RMOL_FOUND)
#
message (STATUS "Found RMOL version: ${RMOL_VERSION}")
# Update the list of include directories for the project
include_directories (${RMOL_INCLUDE_DIRS})
# Update the list of dependencies for the project
set (PROJ_DEP_LIBS_FOR_LIB ${PROJ_DEP_LIBS_FOR_LIB} ${RMOL_LIBRARIES})
else (RMOL_FOUND)
set (ERROR_MSG "The RMOL library cannot be found. If it is installed in")
set (ERROR_MSG "${ERROR_MSG} a in a non standard directory, just invoke")
set (ERROR_MSG "${ERROR_MSG} 'cmake' specifying the -DWITH_RMOL_PREFIX=")