From c2917939bad742811b365eeb8784cad4ce623460 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 22 Mar 2019 09:33:29 +0100 Subject: [PATCH 1/3] Update glog vesion to 0.4.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9a035feb..547772040 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -408,7 +408,7 @@ set(GNSSSDR_MATIO_MIN_VERSION "1.5.3") # Versions to download and build (but not installed) if not found ################################################################################ set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2") -set(GNSSSDR_GLOG_LOCAL_VERSION "0.3.5") +set(GNSSSDR_GLOG_LOCAL_VERSION "0.4.0") set(GNSSSDR_ARMADILLO_LOCAL_VERSION "9.200.x") set(GNSSSDR_GTEST_LOCAL_VERSION "1.8.1") set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") From cb59c1cc83b089ec5092cbfd5eb46fb88214c226 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 22 Mar 2019 11:00:13 +0100 Subject: [PATCH 2/3] Fix bug in MacOS when BeiDou was enabled in rtklib.h The BLAS and LAPACK implementations that come with the Accelerate Framework (soft-linked in /usr/bin) caused a random crash when exiting the program, only if the variable ENABDS was set. This bug disappears when linking to the libraries that Homebrew or Macports install, or when manually downloaded, built and installed by the user --- CMakeLists.txt | 40 ++++++++++++---- README.md | 5 +- cmake/Modules/AvoidAccelerate.cmake | 58 +++++++++++++++++++++++ src/algorithms/libs/rtklib/CMakeLists.txt | 8 +--- src/algorithms/libs/rtklib/rtklib.h | 2 - 5 files changed, 96 insertions(+), 17 deletions(-) create mode 100644 cmake/Modules/AvoidAccelerate.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 547772040..005286a12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1331,14 +1331,30 @@ endif() # Check that BLAS (Basic Linear Algebra Subprograms) is found in the system # See http://www.netlib.org/blas/ ################################################################################ -find_library(BLAS blas) -if(NOT BLAS) +if(OS_IS_MACOSX) + # Avoid using the implementation that comes with the Accelerate framework + include(AvoidAccelerate) +else() + find_package(BLAS) + set_package_properties(BLAS PROPERTIES + URL "http://www.netlib.org/blas/" + DESCRIPTION "Basic Linear Algebra Subprograms" + PURPOSE "Used for matrix algebra computations." + TYPE REQUIRED + ) +endif() +if(NOT BLAS_FOUND) 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") + if(OS_IS_MACOSX) + message(" 'sudo port install lapack' if you are using Macports, or") + message(" 'brew install lapack' if you are using Homebrew.") else() - message(" sudo apt-get install libblas-dev") + if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + message(" sudo yum install blas-devel") + else() + message(" sudo apt-get install libblas-dev") + endif() endif() message(FATAL_ERROR "BLAS is required to build gnss-sdr") endif() @@ -1349,8 +1365,16 @@ endif() # Check that LAPACK (Linear Algebra PACKage) is found in the system # See http://www.netlib.org/lapack/ ################################################################################ -find_library(LAPACK lapack) -if(NOT LAPACK) +if(NOT OS_IS_MACOSX) + find_package(LAPACK) + set_package_properties(LAPACK PROPERTIES + URL "http://www.netlib.org/lapack/" + DESCRIPTION "Linear Algebra PACKage" + PURPOSE "Used for matrix algebra computations." + TYPE REQUIRED + ) +endif() +if(NOT LAPACK_FOUND) 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") @@ -1457,7 +1481,7 @@ if(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO) if(NOT GFORTRAN) set(GFORTRAN "") endif() - set(ARMADILLO_LIBRARIES ${BLAS} ${LAPACK} ${GFORTRAN} ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX}) + set(ARMADILLO_LIBRARIES ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} ${GFORTRAN} ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX}) set(LOCAL_ARMADILLO true CACHE STRING "Armadillo downloaded and built automatically" FORCE) set(ARMADILLO_VERSION_STRING ${armadillo_RELEASE}) file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/armadillo/armadillo-${armadillo_RELEASE}/include) diff --git a/README.md b/README.md index 4e6e0b11c..0cec356ac 100644 --- a/README.md +++ b/README.md @@ -545,6 +545,7 @@ $ sudo port selfupdate $ sudo port upgrade outdated $ sudo port install doxygen +docs $ sudo port install gnuradio +$ sudo port install lapack $ sudo port install armadillo $ sudo port install gnutls $ sudo port install google-glog +gflags @@ -586,7 +587,9 @@ Install the required dependencies: ~~~~~~ $ brew install cmake -$ brew install hdf5 arpack superlu armadillo +$ brew install hdf5 +$ brew install lapack +$ brew install arpack superlu armadillo $ brew install glog gflags $ brew install gnuradio $ brew install libmatio diff --git a/cmake/Modules/AvoidAccelerate.cmake b/cmake/Modules/AvoidAccelerate.cmake new file mode 100644 index 000000000..ab6e54cde --- /dev/null +++ b/cmake/Modules/AvoidAccelerate.cmake @@ -0,0 +1,58 @@ +# Copyright (C) 2011-2019 (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 . + +# Avoid using the BLAS and LAPACK implementations that comes with the Accelerate +# framework, which causes a bug when the BeiDou constellation is enabled + +find_library(BLAS_LIBRARIES + libblas.dylib + PATHS + /opt/local/lib/lapack + /usr/local/opt/lapack/lib + /usr/local/lib + ${BLAS_ROOT}/lib + $ENV{BLAS_ROOT}/lib + NO_DEFAULT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH +) + +if(BLAS_LIBRARIES) + set(BLAS_FOUND TRUE) +endif() + + +find_library(LAPACK_LIBRARIES + liblapack.dylib + PATHS + /opt/local/lib/lapack + /usr/local/opt/lapack/lib + /usr/local/lib + ${BLAS_ROOT}/lib + $ENV{BLAS_ROOT}/lib + NO_DEFAULT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH +) + +if(LAPACK_LIBRARIES) + set(LAPACK_FOUND TRUE) +endif() diff --git a/src/algorithms/libs/rtklib/CMakeLists.txt b/src/algorithms/libs/rtklib/CMakeLists.txt index f15c1c074..814ad6eaf 100644 --- a/src/algorithms/libs/rtklib/CMakeLists.txt +++ b/src/algorithms/libs/rtklib/CMakeLists.txt @@ -70,14 +70,10 @@ target_link_libraries(algorithms_libs_rtklib core_system_parameters Gflags::gflags Glog::glog + ${LAPACK_LIBRARIES} + ${BLAS_LIBRARIES} ) -if(OS_IS_MACOSX) - target_link_libraries(algorithms_libs_rtklib PRIVATE "-framework Accelerate") -else() - target_link_libraries(algorithms_libs_rtklib PRIVATE ${LAPACK} ${BLAS}) -endif() - set_property(TARGET algorithms_libs_rtklib APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ diff --git a/src/algorithms/libs/rtklib/rtklib.h b/src/algorithms/libs/rtklib/rtklib.h index 1b8cd9cbe..0f8cf61b7 100644 --- a/src/algorithms/libs/rtklib/rtklib.h +++ b/src/algorithms/libs/rtklib/rtklib.h @@ -215,9 +215,7 @@ const int NSATQZS = 0; const int NSYSQZS = 0; #endif -#ifndef __APPLE__ #define ENABDS -#endif #ifdef ENABDS const int MINPRNBDS = 1; //!< min satellite sat number of BeiDou const int MAXPRNBDS = 37; //!< max satellite sat number of BeiDou From 52aa4290d8f4a0ed82c8d0c801923641e5f49b40 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 22 Mar 2019 13:45:52 +0100 Subject: [PATCH 3/3] Update suggested glog and armadillo versions if built manually --- CMakeLists.txt | 2 +- README.md | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 005286a12..356eec9db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -409,7 +409,7 @@ set(GNSSSDR_MATIO_MIN_VERSION "1.5.3") ################################################################################ set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2") set(GNSSSDR_GLOG_LOCAL_VERSION "0.4.0") -set(GNSSSDR_ARMADILLO_LOCAL_VERSION "9.200.x") +set(GNSSSDR_ARMADILLO_LOCAL_VERSION "9.300.x") set(GNSSSDR_GTEST_LOCAL_VERSION "1.8.1") set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") set(GNSSSDR_GPSTK_LOCAL_VERSION "2.10.6") diff --git a/README.md b/README.md index 0cec356ac..3cc77bcdc 100644 --- a/README.md +++ b/README.md @@ -190,9 +190,9 @@ $ sudo apt-get install libblas-dev liblapack-dev # For Debian/Ubuntu/Linux $ sudo yum install lapack-devel blas-devel # For Fedora/CentOS/RHEL $ sudo zypper install lapack-devel blas-devel # For OpenSUSE $ sudo pacman -S blas lapack # For Arch Linux -$ wget https://sourceforge.net/projects/arma/files/armadillo-9.200.7.tar.xz -$ tar xvfz armadillo-9.200.7.tar.xz -$ cd armadillo-9.200.7 +$ wget https://sourceforge.net/projects/arma/files/armadillo-9.300.2.tar.xz +$ tar xvfz armadillo-9.300.2.tar.xz +$ cd armadillo-9.300.2 $ cmake . $ make $ sudo make install @@ -219,9 +219,10 @@ $ sudo ldconfig #### Install [Glog](https://github.com/google/glog "Glog's Homepage"), a library that implements application-level logging: ~~~~~~ -$ wget https://github.com/google/glog/archive/v0.3.5.tar.gz -$ tar xvfz v0.3.5.tar.gz -$ cd glog-0.3.5 +$ wget https://github.com/google/glog/archive/v0.4.0.tar.gz +$ tar xvfz v0.4.0.tar.gz +$ cd glog-0.4.0 +$ ./autogen.sh $ ./configure $ make $ sudo make install