forked from gnss-sdr/gnss-sdr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
1304 lines (1167 loc) · 60.5 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
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
# Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
#
# This file is part of GNSS-SDR.
#
# GNSS-SDR is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GNSS-SDR is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
#
########################################################################
# Project setup
########################################################################
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(WARNING "In-tree build is bad practice. Try 'cd build && cmake ../' ")
endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
cmake_minimum_required(VERSION 2.8)
project(gnss-sdr CXX C)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
file(RELATIVE_PATH RELATIVE_CMAKE_CALL ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT CMAKE_PREFIX_PATH)
if(DEFINED ENV{PYBOMBS_PREFIX})
set(CMAKE_PREFIX_PATH $ENV{PYBOMBS_PREFIX})
endif(DEFINED ENV{PYBOMBS_PREFIX})
if(DEFINED ENV{SNAP})
set(CMAKE_PREFIX_PATH $ENV{SNAP})
endif(DEFINED ENV{SNAP})
endif(NOT CMAKE_PREFIX_PATH)
########################################################################
# Determine optional blocks/libraries to be built (default: not built)
# Enable them here or at the command line by doing 'cmake -DENABLE_XXX=ON ../'
########################################################################
# Support of optional RF front-ends
option(ENABLE_OSMOSDR "Enable the use of OsmoSDR and other front-ends (RTL-based dongles, HackRF, bladeRF, etc.) as signal source (experimental)" OFF)
option(ENABLE_FLEXIBAND "Enable the use of the signal source adater for the Teleorbit Flexiband GNURadio driver" OFF)
option(ENABLE_ARRAY "Enable the use of CTTC's antenna array front-end as signal source (experimental)" OFF)
option(ENABLE_GN3S "Enable the use of the GN3S dongle as signal source (experimental)" OFF)
# Performance analysis tools
option(ENABLE_GPERFTOOLS "Enable linking to Gperftools libraries (tcmalloc and profiler)" OFF)
option(ENABLE_GPROF "Enable the use of the GNU profiler tool 'gprof'" OFF)
# Acceleration
option(ENABLE_PROFILING "Enable execution of volk_gnsssdr_profile at the end of the building" OFF)
option(ENABLE_OPENCL "Enable building of processing blocks implemented with OpenCL (experimental)" OFF)
option(ENABLE_CUDA "Enable building of processing blocks implemented with CUDA (experimental, requires CUDA SDK)" OFF)
# Building and packaging options
option(ENABLE_GENERIC_ARCH "Builds a portable binary" OFF)
option(ENABLE_PACKAGING "Enable software packaging" OFF)
option(ENABLE_OWN_GLOG "Download glog and link it to gflags" OFF)
option(ENABLE_OWN_ARMADILLO "Download and build Armadillo locally" OFF)
option(ENABLE_LOG "Enable logging" ON)
if(ENABLE_PACKAGING)
set(ENABLE_GENERIC_ARCH ON)
endif(ENABLE_PACKAGING)
# Testing
option(ENABLE_UNIT_TESTING "Build unit tests" ON)
option(ENABLE_UNIT_TESTING_EXTRA "Download external files and build extra unit tests" OFF)
option(ENABLE_SYSTEM_TESTING "Build system tests" OFF)
option(ENABLE_SYSTEM_TESTING_EXTRA "Download external tools and build extra system tests" OFF)
if(ENABLE_SYSTEM_TESTING_EXTRA)
set(ENABLE_SYSTEM_TESTING ON)
endif(ENABLE_SYSTEM_TESTING_EXTRA)
option(ENABLE_OWN_GPSTK "Force to download, build and link GPSTk for system tests, even if it is already installed" OFF)
###############################
# GNSS-SDR version information
###############################
set(THIS_IS_A_RELEASE ON) # only related to version name, no further implications.
if(NOT ${THIS_IS_A_RELEASE})
# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif(NOT ${THIS_IS_A_RELEASE})
set(VERSION_INFO_MAJOR_VERSION 0)
set(VERSION_INFO_API_COMPAT 0)
if(${THIS_IS_A_RELEASE})
set(VERSION_INFO_MINOR_VERSION 9)
else(${THIS_IS_A_RELEASE})
set(VERSION_INFO_MINOR_VERSION 9.git-${GIT_BRANCH}-${GIT_COMMIT_HASH})
endif(${THIS_IS_A_RELEASE})
set(VERSION ${VERSION_INFO_MAJOR_VERSION}.${VERSION_INFO_API_COMPAT}.${VERSION_INFO_MINOR_VERSION})
########################################################################
# Environment setup
########################################################################
include(ExternalProject)
# Detect 64-bits machine
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set(ARCH_64BITS TRUE)
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set(OS_IS_MACOSX "")
set(OS_IS_LINUX "")
# Detect Linux Distribution
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(OperatingSystem "Linux")
set(OS_IS_LINUX TRUE)
if(ARCH_64BITS)
set(ARCH_ "(64 bits)")
else(ARCH_64BITS)
set(ARCH_ "(32 bits)")
endif(ARCH_64BITS)
if(EXISTS "/etc/lsb-release")
execute_process(COMMAND cat /etc/lsb-release
COMMAND grep DISTRIB_ID
COMMAND awk -F= "{ print $2 }"
COMMAND tr "\n" " "
COMMAND sed "s/ //"
OUTPUT_VARIABLE LINUX_DISTRIBUTION
RESULT_VARIABLE LINUX_ID_RESULT
)
execute_process(COMMAND cat /etc/lsb-release
COMMAND grep DISTRIB_RELEASE
COMMAND awk -F= "{ print $2 }"
COMMAND tr "\n" " "
COMMAND sed "s/ //"
OUTPUT_VARIABLE LINUX_VER
RESULT_VARIABLE LINUX_VER_RESULT
)
endif(EXISTS "/etc/lsb-release")
if(NOT LINUX_DISTRIBUTION)
if(EXISTS "/etc/linuxmint/info")
set(LINUX_DISTRIBUTION "LinuxMint")
execute_process(COMMAND cat /etc/linuxmint/info
COMMAND grep -m1 RELEASE
COMMAND awk -F= "{ print $2 }"
COMMAND tr "\n" " "
COMMAND sed "s/ //"
OUTPUT_VARIABLE LINUX_VER
RESULT_VARIABLE LINUX_VER_RESULT
)
endif(EXISTS "/etc/linuxmint/info")
endif(NOT LINUX_DISTRIBUTION)
if(NOT LINUX_DISTRIBUTION)
if(EXISTS "/etc/os-release")
execute_process(COMMAND cat /etc/os-release
COMMAND grep -m1 NAME
COMMAND awk -F= "{ print $2 }"
COMMAND tr "\n" " "
COMMAND sed "s/ //"
OUTPUT_VARIABLE LINUX_DISTRIBUTION
RESULT_VARIABLE LINUX_ID_RESULT
)
execute_process(COMMAND cat /etc/os-release
COMMAND grep VERSION_ID
COMMAND awk -F= "{ print $2 }"
COMMAND tr "\n" " "
COMMAND sed "s/ //"
OUTPUT_VARIABLE LINUX_VER
RESULT_VARIABLE LINUX_VER_RESULT
)
if(${LINUX_DISTRIBUTION} MATCHES "Debian")
set(LINUX_DISTRIBUTION "Debian")
file(READ /etc/debian_version LINUX_VER)
endif(${LINUX_DISTRIBUTION} MATCHES "Debian")
endif(EXISTS "/etc/os-release")
endif(NOT LINUX_DISTRIBUTION)
if(NOT LINUX_DISTRIBUTION)
if(EXISTS "/etc/redhat-release")
set(LINUX_DISTRIBUTION "Red Hat")
file (READ /etc/redhat-release LINUX_VER)
endif(EXISTS "/etc/redhat-release")
endif(NOT LINUX_DISTRIBUTION)
if(NOT LINUX_DISTRIBUTION)
if(EXISTS "/etc/debian_version")
set(LINUX_DISTRIBUTION "Debian")
file (READ /etc/debian_version LINUX_VER)
endif(EXISTS "/etc/debian_version")
endif(NOT LINUX_DISTRIBUTION)
if(NOT LINUX_DISTRIBUTION)
set(LINUX_DISTRIBUTION "Generic")
set(LINUX_VER "Unknown")
endif(NOT LINUX_DISTRIBUTION)
message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on ${LINUX_DISTRIBUTION} GNU/Linux Release ${LINUX_VER} ${ARCH_}")
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# Detect Mac OS X Version
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(OperatingSystem "Mac OS X")
set(OS_IS_MACOSX TRUE)
exec_program(uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION)
string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
if(${DARWIN_VERSION} MATCHES "16")
set(MACOS_SIERRA TRUE)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on macOS Sierra 10.12")
endif(${DARWIN_VERSION} MATCHES "16")
if(${DARWIN_VERSION} MATCHES "15")
set(MACOSX_EL_CAPITAN TRUE)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.11 El Capitan")
endif(${DARWIN_VERSION} MATCHES "15")
if(${DARWIN_VERSION} MATCHES "14")
set(MACOSX_YOSEMITE TRUE)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.10 Yosemite")
endif(${DARWIN_VERSION} MATCHES "14")
if(${DARWIN_VERSION} MATCHES "13")
set(MACOSX_MAVERICKS TRUE)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION="com.apple.compilers.llvm.clang.1_0")
message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.9 Mavericks")
endif(${DARWIN_VERSION} MATCHES "13")
if(${DARWIN_VERSION} MATCHES "12")
message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.8 Mountain Lion")
endif(${DARWIN_VERSION} MATCHES "12")
if(${DARWIN_VERSION} MATCHES "11")
message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.7 Lion")
endif(${DARWIN_VERSION} MATCHES "11")
if(${DARWIN_VERSION} MATCHES "10")
message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on Mac OS X 10.6 Snow Leopard")
endif(${DARWIN_VERSION} MATCHES "10")
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
#select the release build type by default to get optimization flags
if(NOT CMAKE_BUILD_TYPE)
if(ENABLE_GPERFTOOLS OR ENABLE_GPROF)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
message(STATUS "Build type not specified: defaulting to RelWithDebInfo.")
else(ENABLE_GPERFTOOLS OR ENABLE_GPROF)
set(CMAKE_BUILD_TYPE "Release")
message(STATUS "Build type not specified: defaulting to Release.")
endif(ENABLE_GPERFTOOLS OR ENABLE_GPROF)
else(NOT CMAKE_BUILD_TYPE)
message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}.")
endif(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
# Append -O2 optimization flag for Debug builds
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O2")
################################################################################
# Checkout cmake version
################################################################################
if(CMAKE_VERSION VERSION_LESS 2.8.8)
message(STATUS "Your CMake version is too old and does not support some features required by GNSS-SDR. CMake version must be at least 2.8.8. For more information check https://github.com/joakimkarlsson/bandit/issues/40")
message(FATAL_ERROR "Fatal error: CMake >= 2.8.8 required.")
endif(CMAKE_VERSION VERSION_LESS 2.8.8)
################################################################################
# Checkout compiler version
################################################################################
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
message(STATUS "Your GCC version is too old and does not support some C++11 features required by GNSS-SDR. GCC version must be at least 4.7")
if(${LINUX_DISTRIBUTION} MATCHES "Ubuntu")
if(${LINUX_VER} MATCHES "12.04")
message(STATUS "For instructions on how to upgrade GCC, check http://askubuntu.com/a/271561")
endif(${LINUX_VER} MATCHES "12.04")
endif(${LINUX_DISTRIBUTION} MATCHES "Ubuntu")
message(FATAL_ERROR "Fatal error: GCC >= 4.7 required.")
endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
################################################################################
# Check if the compiler defines the architecture as ARM
################################################################################
if(NOT OS_IS_MACOSX)
if(CMAKE_CROSSCOMPILING)
set(IS_ARM TRUE)
else(CMAKE_CROSSCOMPILING)
include(TestForARM)
endif(CMAKE_CROSSCOMPILING)
endif(NOT OS_IS_MACOSX)
################################################################################
# Check for availability of SSE
################################################################################
if(NOT ENABLE_GENERIC_ARCH)
include(TestForSSE)
endif(NOT ENABLE_GENERIC_ARCH)
###############################
# Find a thread library
###############################
if(OS_IS_LINUX)
find_package(Threads REQUIRED)
link_libraries(${CMAKE_THREAD_LIBS_INIT})
endif(OS_IS_LINUX)
################################################################################
# Googletest - https://github.com/google/googletest
################################################################################
enable_testing()
if(ENABLE_UNIT_TESTING OR ENABLE_SYSTEM_TESTING)
if(EXISTS $ENV{GTEST_DIR})
set(GTEST_DIR $ENV{GTEST_DIR})
endif(EXISTS $ENV{GTEST_DIR})
if(GTEST_DIR)
message(STATUS "Googletest root folder set at ${GTEST_DIR}")
find_path(LIBGTEST_DEV_DIR NAMES src/gtest-all.cc PATHS ${GTEST_DIR})
if(LIBGTEST_DEV_DIR)
message (STATUS "Googletest has been found.")
else(LIBGTEST_DEV_DIR)
message (FATAL_ERROR " Googletest source code has not been found at ${GTEST_DIR}.")
endif(LIBGTEST_DEV_DIR)
find_path(GTEST_INCLUDE_DIRS NAMES gtest/gtest.h PATHS ${GTEST_DIR}/include)
else(GTEST_DIR)
find_path(LIBGTEST_DEV_DIR NAMES src/gtest-all.cc PATHS /usr/src/gtest /opt/local/src/gtest-1.7.0)
find_path(GTEST_INCLUDE_DIRS NAMES gtest/gtest.h PATHS /usr/include /opt/local/src/gtest-1.7.0/include)
if(LIBGTEST_DEV_DIR)
message (STATUS "Googletest (libgtest-dev package) has been found.")
else(LIBGTEST_DEV_DIR)
message (STATUS " Googletest has not been found.")
message (STATUS " Googletest will be downloaded and built automatically ")
message (STATUS " when doing 'make'. ")
endif(LIBGTEST_DEV_DIR)
endif(GTEST_DIR)
endif(ENABLE_UNIT_TESTING OR ENABLE_SYSTEM_TESTING)
################################################################################
# Boost - http://www.boost.org
################################################################################
if(UNIX AND EXISTS "/usr/lib64")
list(APPEND BOOST_LIBRARYDIR "/usr/lib64") # Fedora 64-bit fix
endif(UNIX AND EXISTS "/usr/lib64")
set(Boost_ADDITIONAL_VERSIONS
"1.45.0" "1.45" "1.46.0" "1.46" "1.48.0" "1.48" "1.49.0" "1.49"
"1.50.0" "1.50" "1.51.0" "1.51" "1.53.0" "1.53" "1.54.0" "1.54"
"1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59"
"1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64"
"1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69"
"1.70.0" "1.70" "1.71.0" "1.71" "1.72.0" "1.72" "1.73.0" "1.73" "1.74.0" "1.74"
)
set(Boost_USE_MULTITHREAD ON)
set(Boost_USE_STATIC_LIBS OFF)
find_package(Boost COMPONENTS date_time system filesystem thread serialization chrono unit_test_framework program_options REQUIRED)
if(NOT Boost_FOUND)
message(FATAL_ERROR "Fatal error: Boost (version >=1.45.0) required.")
endif(NOT Boost_FOUND)
################################################################################
# GNU Radio - http://gnuradio.org
################################################################################
set(GR_REQUIRED_COMPONENTS RUNTIME ANALOG BLOCKS FFT FILTER PMT)
find_package(Gnuradio)
if(PC_GNURADIO_RUNTIME_VERSION)
if(PC_GNURADIO_RUNTIME_VERSION VERSION_LESS 3.7.3)
set(GNURADIO_RUNTIME_FOUND)
message(STATUS "The GNU Radio version installed in your system is too old.")
endif(PC_GNURADIO_RUNTIME_VERSION VERSION_LESS 3.7.3)
endif(PC_GNURADIO_RUNTIME_VERSION)
if(NOT GNURADIO_RUNTIME_FOUND)
message(STATUS "CMake cannot find GNU Radio >= 3.7.3")
if(OS_IS_LINUX)
message("Go to https://github.com/gnuradio/pybombs")
message("and follow the instructions to install GNU Radio in your system.")
message(FATAL_ERROR "GNU Radio 3.7.3 or later is required to build gnss-sdr")
endif(OS_IS_LINUX)
if(OS_IS_MACOSX)
message("You can install it easily via Macports:")
message(" sudo port install gnuradio ")
message("Alternatively, you can use homebrew:")
message(" brew tap odrisci/gnuradio")
message(" brew install gnuradio" )
message(FATAL_ERROR "GNU Radio 3.7.3 or later is required to build gnss-sdr")
endif(OS_IS_MACOSX)
endif(NOT GNURADIO_RUNTIME_FOUND)
if(NOT GNURADIO_ANALOG_FOUND)
message(FATAL_ERROR "*** The gnuradio-analog library v3.7.3 or later is required to build gnss-sdr")
endif()
if(NOT GNURADIO_BLOCKS_FOUND)
message(FATAL_ERROR "*** The gnuradio-blocks library v3.7.3 or later is required to build gnss-sdr")
endif()
if(NOT GNURADIO_FILTER_FOUND)
message(FATAL_ERROR "*** The gnuradio-filter library v3.7.3 or later is required to build gnss-sdr")
endif()
if(NOT GNURADIO_FFT_FOUND)
message(FATAL_ERROR "*** The gnuradio-fft library v3.7.3 or later is required to build gnss-sdr")
endif()
if(NOT GNURADIO_PMT_FOUND)
message(FATAL_ERROR "*** The gnuradio-pmt library v3.7.3 or later is required to build gnss-sdr")
endif()
################################################################################
# VOLK - Vector-Optimized Library of Kernels
################################################################################
find_package(Volk)
if(NOT VOLK_FOUND)
message(FATAL_ERROR "*** VOLK is required to build gnss-sdr")
endif()
################################################################################
# volk_gnsssdr module - GNSS-SDR's own VOLK library
################################################################################
find_package(VolkGnssSdr)
if(NOT VOLK_GNSSSDR_FOUND)
message(STATUS " volk_gnsssdr will be built along with gnss-sdr when doing 'make'")
###############################
# Find Python required modules
###############################
include(SetupPython) #sets PYTHON_EXECUTABLE and PYTHON_DASH_B
GNSSSDR_PYTHON_CHECK_MODULE("python >= 2.7" sys "sys.version.split()[0] >= '2.7'" PYTHON_MIN_VER_FOUND)
GNSSSDR_PYTHON_CHECK_MODULE("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND)
GNSSSDR_PYTHON_CHECK_MODULE("six - python 2 and 3 compatibility library" six "True" SIX_FOUND)
if(NOT PYTHON_MIN_VER_FOUND)
message(FATAL_ERROR "Python 2.7 or greater required to build VOLK_GNSSSDR")
endif()
# Mako
if(NOT MAKO_FOUND)
message(STATUS "Mako templates not found. See http://www.makotemplates.org/ ")
message(STATUS " You can try to install it by typing:")
if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(STATUS " sudo yum install python-mako")
elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE")
message(STATUS " sudo zypper install python-Mako")
else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(STATUS " sudo apt-get install python-mako")
endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(FATAL_ERROR "Mako templates required to build VOLK_GNSSSDR")
endif(NOT MAKO_FOUND)
# Six
if(NOT SIX_FOUND)
message(STATUS "python-six not found. See https://pythonhosted.org/six/ ")
message(STATUS " You can try to install it by typing:")
if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(STATUS " sudo yum install python-six")
elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE")
message(STATUS " sudo zypper install python-six")
else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(STATUS " sudo apt-get install python-six")
endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(FATAL_ERROR "six - python 2 and 3 compatibility library required to build VOLK_GNSSSDR")
endif(NOT SIX_FOUND)
if(ENABLE_PACKAGING)
if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
set(STRIP_VOLK_GNSSSDR_PROFILE "-DENABLE_STRIP=ON")
endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
endif(ENABLE_PACKAGING)
set(VOLK_GNSSSDR_BUILD_COMMAND "make")
if(PYTHON_EXECUTABLE)
set(USE_THIS_PYTHON "-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}")
endif(PYTHON_EXECUTABLE)
if(OS_IS_MACOSX)
if(CMAKE_GENERATOR STREQUAL Xcode)
set(VOLK_GNSSSDR_BUILD_COMMAND "xcodebuild" "-configuration" "Debug" "-target")
endif(CMAKE_GENERATOR STREQUAL Xcode)
endif(OS_IS_MACOSX)
set(CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
if(CMAKE_CROSSCOMPILING)
set(VOLK_GNSSSDR_COMPILER "")
else(CMAKE_CROSSCOMPILING)
set(VOLK_GNSSSDR_COMPILER -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER})
endif(CMAKE_CROSSCOMPILING)
set(VOLK_GNSSSDR_CMAKE_ARGS ${VOLK_GNSSSDR_COMPILER}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install
-DENABLE_STATIC_LIBS=ON
-DENABLE_PROFILING=${ENABLE_PROFILING}
-DCMAKE_CXX_FLAGS=${CXX_FLAGS}
-DCMAKE_C_FLAGS=${C_FLAGS}
-DCMAKE_INCLUDE_PATH=${Boost_INCLUDE_DIR}
${STRIP_VOLK_GNSSSDR_PROFILE}
${USE_THIS_PYTHON} )
if(EXISTS $ENV{OECORE_TARGET_SYSROOT})
set(VOLK_GNSSSDR_CMAKE_ARGS ${VOLK_GNSSSDR_CMAKE_ARGS}
-DENABLE_ORC=OFF
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/Toolchains/oe-sdk_cross.cmake
-DCROSSCOMPILE_MULTILIB=TRUE )
endif(EXISTS $ENV{OECORE_TARGET_SYSROOT})
ExternalProject_Add(volk_gnsssdr_module
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/build
CMAKE_ARGS ${VOLK_GNSSSDR_CMAKE_ARGS}
DOWNLOAD_COMMAND ""
UPDATE_COMMAND ""
PATCH_COMMAND ""
BUILD_COMMAND ${VOLK_GNSSSDR_BUILD_COMMAND} volk_gnsssdr_profile
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install
)
find_package(ORC)
if(NOT ORC_FOUND)
set(ORC_LIBRARIES "")
set(ORC_INCLUDE_DIRS "")
endif(NOT ORC_FOUND)
add_library(volk_gnsssdr UNKNOWN IMPORTED)
set_property(TARGET volk_gnsssdr PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install/lib/libvolk_gnsssdr.a)
set(VOLK_GNSSSDR_INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/build/include/;${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include;${ORC_INCLUDE_DIRS}")
set(VOLK_GNSSSDR_LIBRARIES volk_gnsssdr ${ORC_LIBRARIES})
add_custom_command(TARGET volk_gnsssdr_module POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install/bin/volk_gnsssdr_profile
${CMAKE_SOURCE_DIR}/install/volk_gnsssdr_profile)
add_custom_command(TARGET volk_gnsssdr_module POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install/bin/volk_gnsssdr-config-info
${CMAKE_SOURCE_DIR}/install/volk_gnsssdr-config-info)
endif(NOT VOLK_GNSSSDR_FOUND)
################################################################################
# gflags - https://github.com/gflags/gflags
################################################################################
set(LOCAL_GFLAGS false)
set(gflags_RELEASE 2.2.0)
find_package(GFlags)
if (NOT GFlags_FOUND)
message (STATUS " gflags library has not been found.")
message (STATUS " gflags will be downloaded and built automatically ")
message (STATUS " when doing 'make'. ")
ExternalProject_Add(
gflags-${gflags_RELEASE}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}
GIT_REPOSITORY git://github.com/gflags/gflags.git
GIT_TAG v${gflags_RELEASE}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${gflags_RELEASE}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}
CMAKE_ARGS -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_nothreads_LIB=OFF -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
BUILD_COMMAND make
UPDATE_COMMAND ""
PATCH_COMMAND ""
INSTALL_COMMAND ""
)
set(GFlags_INCLUDE_DIRS
${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/include CACHE PATH "Local Gflags headers"
)
add_library(gflags UNKNOWN IMPORTED)
set_property(TARGET gflags PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags.a)
add_dependencies(gflags gflags-${gflags_RELEASE})
set(GFlags_LIBS gflags)
file(GLOB GFlags_SHARED_LIBS "${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_SHARED_LIBRARY_SUFFIX}*")
set(GFlags_LIBRARY gflags-${gflags_RELEASE})
set(GFlags_LIBRARY_PATH ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/lib )
link_directories(${GFlags_LIBRARY_PATH})
set(GFlags_lib ${GFlags_LIBS} CACHE FILEPATH "Local Gflags library")
set(GFlags_LIBRARY_PATH ${GFlags_LIBS})
set(LOCAL_GFLAGS true CACHE STRING "GFlags downloaded and built automatically" FORCE)
endif(NOT GFlags_FOUND)
################################################################################
# glog - https://github.com/google/glog
################################################################################
if(NOT ${ENABLE_OWN_GLOG})
find_package(GLOG)
if(GLOG_INCLUDE_DIRS)
set(GLOG_FOUND ON)
endif(GLOG_INCLUDE_DIRS)
endif(NOT ${ENABLE_OWN_GLOG})
set(glog_RELEASE 0.3.4)
if (NOT GLOG_FOUND OR ${LOCAL_GFLAGS})
message (STATUS " glog library has not been found")
if(NOT GFlags_FOUND)
message(STATUS " or it is likely not linked to gflags.")
endif(NOT GFlags_FOUND)
message (STATUS " glog will be downloaded and built automatically ")
message (STATUS " when doing 'make'. ")
if(NOT ${LOCAL_GFLAGS})
add_library(gflags-${gflags_RELEASE} UNKNOWN IMPORTED)
set_property(TARGET gflags-${gflags_RELEASE} PROPERTY IMPORTED_LOCATION "${GFlags_LIBS}")
endif(NOT ${LOCAL_GFLAGS})
set(TARGET_GFLAGS gflags-${gflags_RELEASE})
if(${LOCAL_GFLAGS})
set(GFLAGS_LIBRARIES_TO_LINK ${GFlags_SHARED_LIBS})
set(GFLAGS_LIBRARY_DIR_TO_LINK ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/lib)
else(${LOCAL_GFLAGS})
set(GFLAGS_LIBRARIES_TO_LINK ${GFlags_LIBS})
set(GFLAGS_LIBRARY_DIR_TO_LINK ${GFlags_LIBRARY_DIRS})
endif(${LOCAL_GFLAGS})
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/tmp/configure_with_gflags
"#!/bin/sh
export CPPFLAGS=-I${GFlags_INCLUDE_DIRS}
export LDFLAGS=-L${GFLAGS_LIBRARY_DIR_TO_LINK}
export LIBS=\"${GFLAGS_LIBRARIES_TO_LINK} -lc++\"
export CXXFLAGS=\"-stdlib=libc++\"
export CC=clang
export CXX=clang++
cd ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/
aclocal
automake --add-missing
autoreconf -vfi
cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/configure")
else("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/tmp/configure_with_gflags
"#!/bin/sh
export CPPFLAGS=-I${GFlags_INCLUDE_DIRS}
export LDFLAGS=-L${GFLAGS_LIBRARY_DIR_TO_LINK}
export LIBS=${GFLAGS_LIBRARIES_TO_LINK}
cd ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/
aclocal
automake --add-missing
autoreconf -vfi
cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/configure")
endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/tmp/configure_with_gflags
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
set(GLOG_CONFIGURE ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/configure_with_gflags)
# Ensure that aclocal and libtool are present
if(OS_IS_LINUX)
if(EXISTS "/usr/bin/libtoolize")
if(EXISTS "/usr/bin/aclocal-1.15" OR EXISTS "/usr/bin/aclocal-1.14" OR EXISTS "/usr/bin/aclocal-1.11" OR EXISTS "/usr/bin/aclocal-1.10")
# Everything ok, we can move on
else(EXISTS "/usr/bin/aclocal-1.15" OR EXISTS "/usr/bin/aclocal-1.14" OR EXISTS "/usr/bin/aclocal-1.11" OR EXISTS "/usr/bin/aclocal-1.10")
message(" aclocal has not been found.")
message(" You can try to install it by typing:")
if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(" sudo yum groupinstall 'Development Tools'")
elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE")
message(" sudo zypper install automake")
else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(" sudo apt-get install automake")
endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(FATAL_ERROR "aclocal is required to build glog from source")
endif(EXISTS "/usr/bin/aclocal-1.15" OR EXISTS "/usr/bin/aclocal-1.14" OR EXISTS "/usr/bin/aclocal-1.11" OR EXISTS "/usr/bin/aclocal-1.10")
else(EXISTS "/usr/bin/libtoolize")
message(" libtool has not been found.")
message(" You can try to install it by typing:")
if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(" sudo yum groupinstall 'Development Tools'")
elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE")
message(" sudo zypper install libtoool")
else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(" sudo apt-get install libtool")
endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(FATAL_ERROR "libtool is required to build glog from source")
endif(EXISTS "/usr/bin/libtoolize")
endif(OS_IS_LINUX)
ExternalProject_Add(
glog-${glog_RELEASE}
DEPENDS ${TARGET_GFLAGS}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}
GIT_REPOSITORY https://github.com/google/glog/
GIT_TAG v${glog_RELEASE}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}
CONFIGURE_COMMAND ${GLOG_CONFIGURE} --prefix=<INSTALL_DIR>
BUILD_COMMAND make
UPDATE_COMMAND ""
PATCH_COMMAND ""
INSTALL_COMMAND ""
)
# Set up variables
set(GLOG_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/src/
${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/src
)
set(GLOG_LIBRARIES
${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog.a
)
set(LOCAL_GLOG true CACHE STRING "Glog downloaded and built automatically" FORCE)
else(NOT GLOG_FOUND OR ${LOCAL_GFLAGS})
add_library(glog-${glog_RELEASE} UNKNOWN IMPORTED)
set_property(TARGET glog-${glog_RELEASE} PROPERTY IMPORTED_LOCATION "${GLOG_LIBRARIES}")
endif(NOT GLOG_FOUND OR ${LOCAL_GFLAGS})
if(NOT ENABLE_LOG)
message(STATUS "Logging is not enabled")
add_definitions(-DGOOGLE_STRIP_LOG=1)
endif(NOT ENABLE_LOG)
################################################################################
# Armadillo - http://arma.sourceforge.net/
################################################################################
if(OS_IS_LINUX)
#############################################################################
# Check that LAPACK is found in the system
# LAPACK is required for matrix decompositions (eg. SVD) and matrix inverse.
#############################################################################
find_library(LAPACK lapack)
if(NOT LAPACK)
message(" The LAPACK library has not been found.")
message(" You can try to install it by typing:")
if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(" sudo yum install lapack-devel")
elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE")
message(" sudo zypper install lapack-devel")
else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(" sudo apt-get install liblapack-dev")
endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
if(IS_ARM)
message(WARNING "LAPACK is recommended to build gnss-sdr")
set(LAPACK "")
else(IS_ARM)
message(FATAL_ERROR "LAPACK is required to build gnss-sdr")
endif(IS_ARM)
endif(NOT LAPACK)
#############################################################################
# Check that BLAS is found in the system
# BLAS is used for matrix multiplication.
# Without BLAS, matrix multiplication will still work, but might be slower.
#############################################################################
find_library(BLAS blas)
if(NOT BLAS)
message(" The BLAS library has not been found.")
message(" You can try to install it by typing:")
if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(" sudo yum install blas-devel")
else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(" sudo apt-get install libopenblas-dev")
endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
if(IS_ARM)
message(WARNING "BLAS is recommended to build gnss-sdr")
set(BLAS "")
else(IS_ARM)
message(FATAL_ERROR "BLAS is required to build gnss-sdr")
endif(IS_ARM)
endif(NOT BLAS)
#############################################
# Check if GFORTRAN is found in the system
#############################################
find_library(GFORTRAN NAMES gfortran
PATHS /usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib/i386
/usr/lib/gcc/x86_64-linux-gnu
/usr/lib/gcc/i686-linux-gnu
/usr/lib/gcc/i386-linux-gnu
/usr/lib/gcc/x86_64-linux-gnu/4.6 # Ubuntu 12.04
/usr/lib/gcc/i686-linux-gnu/4.6
/usr/lib/gcc/x86_64-linux-gnu/4.7
/usr/lib/gcc/i686-linux-gnu/4.7
/usr/lib/gcc/x86_64-linux-gnu/4.8
/usr/lib/gcc/i686-linux-gnu/4.8
/usr/lib/gcc/x86_64-linux-gnu/4.9
/usr/lib/gcc/i686-linux-gnu/4.9
/usr/lib/gcc/x86_64-redhat-linux/4.7.2 # Fedora 18
/usr/lib/gcc/i686-redhat-linux/4.7.2
/usr/lib/gcc/x86_64-redhat-linux/4.8.1 # Fedora 19
/usr/lib/gcc/x86_64-redhat-linux/4.8.3 # Fedora 20
/usr/lib/gcc/x86_64-redhat-linux/4.9.1 # Fedora 21
/usr/lib/gcc/i686-redhat-linux/4.8.1
/usr/lib/gcc/i686-redhat-linux/4.8.3
/usr/lib/gcc/i686-redhat-linux/4.9.1
/usr/lib/gcc/x86_64-redhat-linux/4.4.4 # CentOS 6
/usr/lib/gcc/i686-redhat-linux/4.4.4
/usr/lib/gcc/x86_64-redhat-linux/4.8.2
/usr/lib/gcc/i686-redhat-linux/4.8.2
/usr/lib/gcc/i586-suse-linux/4.8 # OpenSUSE 13.1
/usr/lib/gcc/i586-suse-linux/4.9
/usr/lib/gcc/x86_64-suse-linux/4.8
/usr/lib/gcc/x86_64-suse-linux/4.9
/usr/lib/gcc/i486-linux-gnu # Debian 7
/usr/lib/gcc/i486-linux-gnu/4.4
/usr/lib/gcc/i486-linux-gnu/4.6
/usr/lib/gcc/i486-linux-gnu/4.7
/usr/lib/gcc/i486-linux-gnu/4.8
/usr/lib/gcc/i486-linux-gnu/4.9
/usr/lib/gcc/i586-linux-gnu/4.9
/usr/lib/gcc/arm-linux-gnueabihf/4.4 # Debian armhf
/usr/lib/gcc/arm-linux-gnueabihf/4.5
/usr/lib/gcc/arm-linux-gnueabihf/4.6
/usr/lib/gcc/arm-linux-gnueabihf/4.7
/usr/lib/gcc/arm-linux-gnueabihf/4.8
/usr/lib/gcc/arm-linux-gnueabihf/4.9
/usr/lib/gcc/aarch64-linux-gnu/4.9 # Debian arm64
/usr/lib/gcc/arm-linux-gnueabi/4.7 # Debian armel
/usr/lib/gcc/arm-linux-gnueabi/4.9
/usr/lib/gcc/x86_64-linux-gnu/5
/usr/lib/gcc/i686-linux-gnu/5
/usr/lib/gcc/arm-linux-gnueabi/5
/usr/lib/gcc/arm-linux-gnueabihf/5
/usr/lib/gcc/aarch64-linux-gnu/5
/usr/lib/gcc/x86_64-linux-gnu/6 # Ubuntu 16.10
/usr/lib/gcc/alpha-linux-gnu/6
/usr/lib/gcc/aarch64-linux-gnu/6
/usr/lib/gcc/arm-linux-gnueabi/6
/usr/lib/gcc/arm-linux-gnueabihf/6
/usr/lib/gcc/hppa-linux-gnu/6
/usr/lib/gcc/i686-gnu/6
/usr/lib/gcc/i686-linux-gnu/6
/usr/lib/gcc/x86_64-kfreebsd-gnu/6
/usr/lib/gcc/i686-kfreebsd-gnu/6
/usr/lib/gcc/m68k-linux-gnu/6
/usr/lib/gcc/mips-linux-gnu/6
/usr/lib/gcc/mips64el-linux-gnuabi64/6
/usr/lib/gcc/mipsel-linux-gnu/6
/usr/lib/gcc/powerpc-linux-gnu/6
/usr/lib/gcc/powerpc-linux-gnuspe/6
/usr/lib/gcc/powerpc64-linux-gnu/6
/usr/lib/gcc/powerpc64le-linux-gnu/6
/usr/lib/gcc/s390x-linux-gnu/6
/usr/lib/gcc/sparc64-linux-gnu/6
/usr/lib/gcc/x86_64-linux-gnux32/6
/usr/lib/gcc/sh4-linux-gnu/6
)
if(NOT GFORTRAN)
message(STATUS "The gfortran library has not been found.")
message(STATUS " You can try to install it by typing:")
if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(STATUS " sudo yum install gcc-fortran")
elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE")
message(STATUS " sudo zypper install gcc-fortran")
else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(STATUS " sudo apt-get install gfortran")
endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
endif(NOT GFORTRAN)
endif(OS_IS_LINUX)
find_package(Armadillo)
if(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO)
message(STATUS " Armadillo has not been found.")
message(STATUS " Armadillo will be downloaded and built automatically ")
message(STATUS " when doing 'make'. ")
if(CMAKE_VERSION VERSION_LESS 3.1)
# ExternalProject in CMake > 3.1 cannot open .xz files
set(armadillo_RELEASE 6.700.7)
set(armadillo_MD5 "8116185e1d7391eed3bf6c500f81b4d8")
set(ARMA_FILE_EXTENSION "gz")
else(CMAKE_VERSION VERSION_LESS 3.1)
set(armadillo_RELEASE 7.600.2)
set(armadillo_MD5 "8dee8bc37f7cb29323c20c4104126b5c")
set(ARMA_FILE_EXTENSION "xz")
endif(CMAKE_VERSION VERSION_LESS 3.1)
ExternalProject_Add(
armadillo-${armadillo_RELEASE}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/armadillo-${armadillo_RELEASE}
URL http://sourceforge.net/projects/arma/files/armadillo-${armadillo_RELEASE}.tar.${ARMA_FILE_EXTENSION}
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/download/armadillo-${armadillo_RELEASE}
URL_MD5 ${armadillo_MD5}
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DBUILD_SHARED_LIBS=OFF
BUILD_IN_SOURCE 1
BUILD_COMMAND make
UPDATE_COMMAND ""
INSTALL_COMMAND ""
)
# Set up variables
ExternalProject_Get_Property(armadillo-${armadillo_RELEASE} binary_dir)
set(ARMADILLO_INCLUDE_DIRS ${binary_dir}/include )
find_library(LAPACK NAMES lapack HINTS /usr/lib /usr/local/lib /usr/lib64)
if(OS_IS_MACOSX)
find_library(BLAS blas)
endif(OS_IS_MACOSX)
find_package(OpenBLAS)
if(OPENBLAS_FOUND)
set(BLAS ${OPENBLAS})
endif(OPENBLAS_FOUND)
if(NOT GFORTRAN)
set(GFORTRAN "")
endif(NOT GFORTRAN)
set(ARMADILLO_LIBRARIES ${BLAS} ${LAPACK} ${GFORTRAN} ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo.a)
set(LOCAL_ARMADILLO true CACHE STRING "Armadillo downloaded and built automatically" FORCE)
# Save a copy at the thirdparty folder
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/armadillo-${armadillo_RELEASE}
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/armadillo
)
set(ARMADILLO_VERSION_STRING ${armadillo_RELEASE})
else(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO)
set(armadillo_RELEASE ${ARMADILLO_VERSION_STRING})
add_library(armadillo-${armadillo_RELEASE} UNKNOWN IMPORTED)
set_property(TARGET armadillo-${armadillo_RELEASE} PROPERTY IMPORTED_LOCATION "${ARMADILLO_LIBRARIES}")
endif(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO)
################################################################################
# GnuTLS - http://www.gnutls.org/
################################################################################
find_package(GnuTLS)
find_library(GNUTLS_OPENSSL_LIBRARY NAMES gnutls-openssl libgnutls-openssl.so.27
HINTS /usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/opt/local/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/aarch64-linux-gnu
/usr/lib/arm-linux-gnueabihf
/usr/lib/arm-linux-gnueabi
/usr/lib/i386-linux-gnu
/usr/lib/alpha-linux-gnu
/usr/lib/hppa-linux-gnu
/usr/lib/i686-gnu
/usr/lib/i686-linux-gnu
/usr/lib/x86_64-kfreebsd-gnu
/usr/lib/i686-kfreebsd-gnu
/usr/lib/m68k-linux-gnu
/usr/lib/mips-linux-gnu
/usr/lib/mips64el-linux-gnuabi64
/usr/lib/mipsel-linux-gnu
/usr/lib/powerpc-linux-gnu
/usr/lib/powerpc-linux-gnuspe
/usr/lib/powerpc64-linux-gnu
/usr/lib/powerpc64le-linux-gnu
/usr/lib/s390x-linux-gnu
/usr/lib/sparc64-linux-gnu
/usr/lib/x86_64-linux-gnux32
/usr/lib/sh4-linux-gnu
)
if(NOT GNUTLS_OPENSSL_LIBRARY)
message(STATUS "Looking for OpenSSL instead...")
find_package(OpenSSL)
if(OPENSSL_FOUND)
set(GNUTLS_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR})
set(GNUTLS_LIBRARIES "")
set(GNUTLS_OPENSSL_LIBRARY ${OPENSSL_SSL_LIBRARY})
else(OPENSSL_FOUND)
message(" The GnuTLS library with openssl compatibility enabled has not been found.")
message(" You can try to install the required libraries by typing:")
if(OS_IS_LINUX)
if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(" sudo yum install openssl-devel")
else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(" sudo apt-get install libgnutls-openssl-dev")
endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
endif(OS_IS_LINUX)
if(OS_IS_MACOSX)
message(" sudo port install gnutls")
endif(OS_IS_MACOSX)
message(FATAL_ERROR "GnuTLS libraries with openssl compatibility are required to build gnss-sdr")
endif(OPENSSL_FOUND)
endif(NOT GNUTLS_OPENSSL_LIBRARY)
################################################################################
# USRP Hardware Driver (UHD) - OPTIONAL
################################################################################