From f3485bb39b6b268a6e9c134d37472e6e802c05e5 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Mon, 28 Oct 2019 12:51:11 +0100 Subject: [PATCH 01/20] Throttle the DMA to give more time to other signal processing tasks. --- .../signal_source/adapters/ad9361_fpga_signal_source.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc index 007070630..908301ae0 100644 --- a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc +++ b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc @@ -48,11 +48,12 @@ #include // for write #include #include - +#include // for std::this_thread +#include // for std::chrono void run_DMA_process(const std::string &FreqBand, const std::string &Filename1, const std::string &Filename2, const bool &enable_DMA) { - const int MAX_INPUT_SAMPLES_TOTAL = 8192; + const int MAX_INPUT_SAMPLES_TOTAL = 16384; int max_value = 0; int tx_fd; // DMA descriptor std::ifstream infile1; @@ -256,6 +257,9 @@ void run_DMA_process(const std::string &FreqBand, const std::string &Filename1, { std::cerr << "Error: DMA could not send all the required samples " << std::endl; } + + // Throttle the DMA + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } if (nread_elements != MAX_INPUT_SAMPLES_TOTAL * 2) From 37f427844dd4bb770ad0b1b69cf5f16973c8b00a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 28 Oct 2019 13:00:18 +0100 Subject: [PATCH 02/20] Apply clang-format --- .../signal_source/adapters/ad9361_fpga_signal_source.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc index 908301ae0..e59ddd6cf 100644 --- a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc +++ b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc @@ -39,17 +39,17 @@ #include #include #include // for max +#include // for std::this_thread #include // for abs #include // for exceptions #include // for open, O_WRONLY #include // for std::ifstream #include // for cout, endl #include // for string manipulation +#include // for std::chrono #include // for write #include #include -#include // for std::this_thread -#include // for std::chrono void run_DMA_process(const std::string &FreqBand, const std::string &Filename1, const std::string &Filename2, const bool &enable_DMA) { From 8bb25dc6825a8dc9e81c04b4059e780c54bcb198 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Mon, 28 Oct 2019 19:16:23 +0100 Subject: [PATCH 03/20] removed the messages related to the fft blk exponent --- .../acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 494c137c4..f1e6e06f1 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -195,7 +195,6 @@ void pcps_acquisition_fpga::acquisition_core(uint32_t num_doppler_bins, uint32_t if (total_block_exp > d_total_block_exp) { // if the attenuation factor of the FPGA FFT-IFFT is smaller than the reference attenuation factor then we need to update the reference attenuation factor - std::cout << "changing blk exp..... d_total_block_exp = " << d_total_block_exp << " total_block_exp = " << total_block_exp << " chan = " << d_channel << std::endl; d_total_block_exp = total_block_exp; d_test_statistics = 0; } From 58af2dc2beb74e9b7dbbfb75e561ceab0febae4c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 29 Oct 2019 20:56:02 +0100 Subject: [PATCH 04/20] Add Catalina as most recent macOS version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8fc927993..22c7d4c76 100644 --- a/README.md +++ b/README.md @@ -571,7 +571,7 @@ More details can be found in our tutorial about [GNSS-SDR configuration options macOS and Mac OS X --------- -GNSS-SDR can be built on MacOS or Mac OS X, starting from 10.9 (Mavericks) and including 10.14 (Mojave). If you still have not installed [Xcode](https://developer.apple.com/xcode/ "Xcode"), do it now from the App Store (it's free). You will also need the Xcode Command Line Tools. Launch the Terminal, found in /Applications/Utilities/, and type: +GNSS-SDR can be built on MacOS or Mac OS X, starting from 10.9 (Mavericks) and including 10.15 (Catalina). If you still have not installed [Xcode](https://developer.apple.com/xcode/ "Xcode"), do it now from the App Store (it's free). You will also need the Xcode Command Line Tools. Launch the Terminal, found in /Applications/Utilities/, and type: ~~~~~~ $ xcode-select --install From f25fa45f21aad785f73ddc30800fdd922f8c7e59 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 30 Oct 2019 11:50:02 +0100 Subject: [PATCH 05/20] Now GPSTk supports C++20 --- CMakeLists.txt | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a73c0932..74c539020 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -631,22 +631,20 @@ set(FILESYSTEM_FOUND FALSE) if(NOT (GNURADIO_VERSION VERSION_LESS 3.8) AND LOG4CPP_READY_FOR_CXX17) # Check if we have std::filesystem if(NOT (CMAKE_VERSION VERSION_LESS 3.8)) - if((NOT ENABLE_UNIT_TESTING_EXTRA) AND (NOT ENABLE_SYSTEM_TESTING_EXTRA) AND (NOT ENABLE_FPGA)) # Workaround for GPSTk - find_package(FILESYSTEM COMPONENTS Final Experimental) - set_package_properties(FILESYSTEM PROPERTIES - URL "https://en.cppreference.com/w/cpp/filesystem" - DESCRIPTION "Provides facilities for performing operations on file systems and their components" - PURPOSE "Work with paths, regular files, and directories." - TYPE OPTIONAL - ) - if(${FILESYSTEM_FOUND}) - if(CMAKE_VERSION VERSION_LESS 3.12) - set(CMAKE_CXX_STANDARD 17) - else() - set(CMAKE_CXX_STANDARD 20) - endif() - set(CMAKE_CXX_STANDARD_REQUIRED ON) + find_package(FILESYSTEM COMPONENTS Final Experimental) + set_package_properties(FILESYSTEM PROPERTIES + URL "https://en.cppreference.com/w/cpp/filesystem" + DESCRIPTION "Provides facilities for performing operations on file systems and their components" + PURPOSE "Work with paths, regular files, and directories." + TYPE OPTIONAL + ) + if(${FILESYSTEM_FOUND}) + if(CMAKE_VERSION VERSION_LESS 3.12) + set(CMAKE_CXX_STANDARD 17) + else() + set(CMAKE_CXX_STANDARD 20) endif() + set(CMAKE_CXX_STANDARD_REQUIRED ON) endif() endif() endif() From 9ca639ee4c7c6198a94c97662c16d67a7c87207c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 30 Oct 2019 16:09:43 +0100 Subject: [PATCH 06/20] Update list of Macports dependencies --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 22c7d4c76..710f17e3b 100644 --- a/README.md +++ b/README.md @@ -594,6 +594,7 @@ In a terminal, type: ~~~~~~ $ sudo port selfupdate $ sudo port upgrade outdated +$ sudo port install pkgconfig $ sudo port install gnuradio $ sudo port install lapack $ sudo port install armadillo @@ -602,8 +603,10 @@ $ sudo port install google-glog +gflags $ sudo port install matio $ sudo port install pugixml $ sudo port install protobuf3-cpp -$ sudo port install py27-mako -$ sudo port install py27-six +$ sudo port install libiio +$ sudo port install libad9361-iio +$ sudo port install py37-mako +$ sudo port install py37-six $ sudo port install doxygen +docs ~~~~~~ @@ -616,7 +619,7 @@ $ port select --list python and you can activate a certain version by typing: ~~~~~~ -$ sudo port select --set python python27 +$ sudo port select --set python python37 ~~~~~~ #### Homebrew @@ -639,6 +642,7 @@ Install the required dependencies: ~~~~~~ $ brew install cmake +$ brew install pkg-config $ brew install hdf5 $ brew install lapack $ brew install armadillo From 6f278bdf94a88053c47fab13b5ee6fd0ddf6b347 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 30 Oct 2019 16:10:22 +0100 Subject: [PATCH 07/20] Replace HINTS by PATHS --- cmake/Modules/FindGPSTK.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/FindGPSTK.cmake b/cmake/Modules/FindGPSTK.cmake index cf61cb2ff..abf26ebdb 100644 --- a/cmake/Modules/FindGPSTK.cmake +++ b/cmake/Modules/FindGPSTK.cmake @@ -27,7 +27,7 @@ if(NOT COMMAND feature_summary) endif() find_path(GPSTK_INCLUDE_DIR gpstk/Rinex3ObsBase.hpp - HINTS /usr/include + PATHS /usr/include /usr/local/include /opt/local/include ${GPSTK_ROOT}/include @@ -39,7 +39,7 @@ set(GPSTK_NAMES ${GPSTK_NAMES} gpstk libgpstk) include(GNUInstallDirs) find_library(GPSTK_LIBRARY NAMES ${GPSTK_NAMES} - HINTS /usr/lib + PATHS /usr/lib /usr/local/lib /usr/${CMAKE_INSTALL_LIBDIR} /usr/local/${CMAKE_INSTALL_LIBDIR} From 6419c879c809e89e575caa4bac8be1f945cf04e2 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 30 Oct 2019 16:47:16 +0100 Subject: [PATCH 08/20] Update ProtocolBuffers version to 3.10.1 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74c539020..5173456b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -407,7 +407,7 @@ set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") set(GNSSSDR_GPSTK_LOCAL_VERSION "2.12") set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.17") set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.10") -set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "3.10.0") +set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "3.10.1") if(CMAKE_VERSION VERSION_LESS "3.0.2") # Fix for CentOS 7 set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.1") From d14111c85de8cc8d7d2c60ad981228011633064b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 30 Oct 2019 21:27:57 +0100 Subject: [PATCH 09/20] Improve license text wording Fix for AppleClang compiler >= 11 --- cmake/Modules/FindFILESYSTEM.cmake | 8 ++++++-- .../volk_gnsssdr/cmake/Modules/FindFILESYSTEM.cmake | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmake/Modules/FindFILESYSTEM.cmake b/cmake/Modules/FindFILESYSTEM.cmake index c4ae39556..a670d0fde 100644 --- a/cmake/Modules/FindFILESYSTEM.cmake +++ b/cmake/Modules/FindFILESYSTEM.cmake @@ -15,8 +15,9 @@ # You should have received a copy of the GNU General Public License # along with GNSS-SDR. If not, see . -# Original Source: https://github.com/vector-of-bool/CMakeCM -# Modified by C. Fernandez-Prades. +# Original code from https://github.com/vector-of-bool/CMakeCM and modified +# by C. Fernandez. The original code is distributed under the OSI-approved +# BSD 3-Clause License. See https://cmake.org/licensing for details. #[=======================================================================[.rst: @@ -136,6 +137,9 @@ endif() if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.99")) set(CMAKE_REQUIRED_FLAGS "-std=c++17") endif() +if((CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11")) + set(CMAKE_REQUIRED_FLAGS "-std=c++17") +endif() # Normalize and check the component list we were given set(want_components ${FILESYSTEM_FIND_COMPONENTS}) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/FindFILESYSTEM.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/FindFILESYSTEM.cmake index 1359615e4..7bc06a9b1 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/FindFILESYSTEM.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/FindFILESYSTEM.cmake @@ -15,8 +15,9 @@ # You should have received a copy of the GNU General Public License # along with GNSS-SDR. If not, see . -# Original Source: https://github.com/vector-of-bool/CMakeCM -# Modified by C. Fernandez-Prades. +# Original code from https://github.com/vector-of-bool/CMakeCM and modified +# by C. Fernandez. The original code is distributed under the OSI-approved +# BSD 3-Clause License. See https://cmake.org/licensing for details. #[=======================================================================[.rst: @@ -135,6 +136,9 @@ endif() if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.99")) set(CMAKE_REQUIRED_FLAGS "-std=c++17") endif() +if((CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11")) + set(CMAKE_REQUIRED_FLAGS "-std=c++17") +endif() # Normalize and check the component list we were given set(want_components ${FILESYSTEM_FIND_COMPONENTS}) From ef8c03cd8c99596440b6dceca7a5ee796c65150a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 30 Oct 2019 21:31:41 +0100 Subject: [PATCH 10/20] Replace HINTS by PATHS --- cmake/Modules/FindGFLAGS.cmake | 4 ++-- cmake/Modules/FindGPERFTOOLS.cmake | 8 ++++---- cmake/Modules/FindMATIO.cmake | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmake/Modules/FindGFLAGS.cmake b/cmake/Modules/FindGFLAGS.cmake index 1dbce8b89..15a5522a1 100644 --- a/cmake/Modules/FindGFLAGS.cmake +++ b/cmake/Modules/FindGFLAGS.cmake @@ -48,7 +48,7 @@ if(APPLE) else() find_path(GFlags_ROOT_DIR libgflags.so - HINTS + PATHS /usr/lib /usr/lib64 /usr/lib/x86_64-linux-gnu @@ -89,7 +89,7 @@ if(GFlags_ROOT_DIR) # We are testing only a couple of files in the include directories find_path(GFlags_INCLUDE_DIRS gflags/gflags.h - HINTS + PATHS /usr/include /usr/local/include /opt/local/include diff --git a/cmake/Modules/FindGPERFTOOLS.cmake b/cmake/Modules/FindGPERFTOOLS.cmake index bdc1d683f..57b2e01d2 100644 --- a/cmake/Modules/FindGPERFTOOLS.cmake +++ b/cmake/Modules/FindGPERFTOOLS.cmake @@ -46,7 +46,7 @@ endif() find_library(GPERFTOOLS_TCMALLOC NAMES tcmalloc - HINTS /usr/lib + PATHS /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64 @@ -61,7 +61,7 @@ find_library(GPERFTOOLS_TCMALLOC find_library(GPERFTOOLS_PROFILER NAMES profiler - HINTS /usr/lib + PATHS /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64 @@ -75,7 +75,7 @@ find_library(GPERFTOOLS_PROFILER find_library(GPERFTOOLS_TCMALLOC_AND_PROFILER NAMES tcmalloc_and_profiler - HINTS /usr/lib + PATHS /usr/lib /usr/lib64 ${Gperftools_ROOT_DIR}/lib ${GPERFTOOLS_ROOT}/lib @@ -89,7 +89,7 @@ find_library(GPERFTOOLS_TCMALLOC_AND_PROFILER find_path(GPERFTOOLS_INCLUDE_DIR NAMES gperftools/heap-profiler.h - HINTS /usr/include + PATHS /usr/include /usr/local/include /opt/local/include ${Gperftools_ROOT_DIR}/include diff --git a/cmake/Modules/FindMATIO.cmake b/cmake/Modules/FindMATIO.cmake index 7c586c972..d2d143567 100644 --- a/cmake/Modules/FindMATIO.cmake +++ b/cmake/Modules/FindMATIO.cmake @@ -69,7 +69,7 @@ endif() # Look for the header file. find_path(MATIO_INCLUDE_DIR NAMES matio.h - HINTS + PATHS /usr/include /usr/local/include /opt/local/include @@ -81,7 +81,7 @@ find_path(MATIO_INCLUDE_DIR # Look for the library. find_library(MATIO_LIBRARY NAMES matio - HINTS + PATHS /usr/lib /usr/lib64 /usr/lib/alpha-linux-gnu From 62ace8d9e4a7bdc372610f58afedd6dc746a0d71 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 1 Nov 2019 11:17:52 +0100 Subject: [PATCH 11/20] Move CMAKE_ASM_FLAGS to arm toolchain files --- .../cmake/Toolchains/aarch64-linux-gnu.cmake | 50 +++++++++++++++++ .../Toolchains/arm-linux-gnueabihf.cmake | 53 +++++++++++++++++++ .../arm_cortex_a15_hardfp_native.cmake | 5 +- .../arm_cortex_a53_hardfp_native.cmake | 26 +++++++++ .../arm_cortex_a72_hardfp_native.cmake | 20 ++++++- .../arm_cortex_a8_hardfp_native.cmake | 26 +++++++++ .../arm_cortex_a8_softfp_native.cmake | 26 +++++++++ .../arm_cortex_a9_hardfp_native.cmake | 5 +- .../cmake/Toolchains/oe-sdk_cross.cmake | 30 +++++++++++ .../volk_gnsssdr/lib/CMakeLists.txt | 4 +- 10 files changed, 237 insertions(+), 8 deletions(-) create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/aarch64-linux-gnu.cmake create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm-linux-gnueabihf.cmake create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/oe-sdk_cross.cmake diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/aarch64-linux-gnu.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/aarch64-linux-gnu.cmake new file mode 100644 index 000000000..610fde597 --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/aarch64-linux-gnu.cmake @@ -0,0 +1,50 @@ +# 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 . + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR ARM) + +if(MINGW OR CYGWIN OR WIN32) + set(UTIL_SEARCH_CMD where) +elseif(UNIX OR APPLE) + set(UTIL_SEARCH_CMD which) +endif() + +set(TOOLCHAIN_PREFIX aarch64-linux-gnu-) + +execute_process( + COMMAND ${UTIL_SEARCH_CMD} ${TOOLCHAIN_PREFIX}gcc + OUTPUT_VARIABLE BINUTILS_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +get_filename_component(ARM_TOOLCHAIN_DIR ${BINUTILS_PATH} DIRECTORY) + +# The following is not needed on debian +# Without that flag CMake is not able to pass test compilation check +#set(CMAKE_EXE_LINKER_FLAGS_INIT "--specs=nosys.specs") + +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc) +set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++) + +set(CMAKE_OBJCOPY ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy CACHE INTERNAL "objcopy tool") +set(CMAKE_SIZE_UTIL ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size CACHE INTERNAL "size tool") + +set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH}) + +set(CMAKE_CROSSCOMPILING_EMULATOR "qemu-aarch64 -L /usr/aarch64-linux-gnu/") diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm-linux-gnueabihf.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm-linux-gnueabihf.cmake new file mode 100644 index 000000000..8c1d0144b --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm-linux-gnueabihf.cmake @@ -0,0 +1,53 @@ +# 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 . + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR ARM) + +if(MINGW OR CYGWIN OR WIN32) + set(UTIL_SEARCH_CMD where) +elseif(UNIX OR APPLE) + set(UTIL_SEARCH_CMD which) +endif() + +set(TOOLCHAIN_PREFIX arm-linux-gnueabihf-) + +execute_process( + COMMAND ${UTIL_SEARCH_CMD} ${TOOLCHAIN_PREFIX}gcc + OUTPUT_VARIABLE BINUTILS_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +get_filename_component(ARM_TOOLCHAIN_DIR ${BINUTILS_PATH} DIRECTORY) + +# The following is not needed on debian +# Without that flag CMake is not able to pass test compilation check +#set(CMAKE_EXE_LINKER_FLAGS_INIT "--specs=nosys.specs") + +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc) +set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++) +## the following is needed for CheckCSourceCompiles used in lib/CMakeLists.txt +set(CMAKE_C_FLAGS "-mfpu=neon" CACHE STRING "" FORCE) +set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "" FORCE) + +set(CMAKE_OBJCOPY ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy CACHE INTERNAL "objcopy tool") +set(CMAKE_SIZE_UTIL ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size CACHE INTERNAL "size tool") + +set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH}) + +set(CMAKE_CROSSCOMPILING_EMULATOR "qemu-arm -L /usr/arm-linux-gnueabihf/") diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake index bbe2f262e..9a461f21d 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -22,4 +22,5 @@ set(CMAKE_CXX_COMPILER g++) set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_FLAGS "-march=armv7-a -mtune=cortex-a15 -mfpu=neon -mfloat-abi=hard" CACHE STRING "" FORCE) -set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) #same flags for C sources +set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake new file mode 100644 index 000000000..ebaa10bce --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake @@ -0,0 +1,26 @@ +# 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 . + +######################################################################## +# Toolchain file for building native on a ARM Cortex A72 w/ NEON +# Usage: cmake -DCMAKE_TOOLCHAIN_FILE= +######################################################################## +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS "-march=armv8-a -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -mthumb -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake index a5eeb74da..ea4c0dc25 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake @@ -1,3 +1,20 @@ +# 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 . + ######################################################################## # Toolchain file for building native on a ARM Cortex A72 w/ NEON # Usage: cmake -DCMAKE_TOOLCHAIN_FILE= @@ -5,4 +22,5 @@ set(CMAKE_CXX_COMPILER g++) set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_FLAGS "-march=armv8-a -mtune=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard" CACHE STRING "" FORCE) -set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) #same flags for C sources +set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -mthumb -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake new file mode 100644 index 000000000..0bd2b13cc --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake @@ -0,0 +1,26 @@ +# 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 . + +######################################################################## +# Toolchain file for building native on a ARM Cortex A8 w/ NEON +# Usage: cmake -DCMAKE_TOOLCHAIN_FILE= +######################################################################## +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS "-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=hard" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake new file mode 100644 index 000000000..f870f5034 --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake @@ -0,0 +1,26 @@ +# 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 . + +######################################################################## +# Toolchain file for building native on a ARM Cortex A8 w/ NEON +# Usage: cmake -DCMAKE_TOOLCHAIN_FILE= +######################################################################## +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS "-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake index 87bfae005..7880d5e24 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors) +# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors) # # This file is part of GNSS-SDR. # @@ -22,4 +22,5 @@ set(CMAKE_CXX_COMPILER g++) set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_FLAGS "-march=armv7-a -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard" CACHE STRING "" FORCE) -set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) #same flags for C sources +set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/oe-sdk_cross.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/oe-sdk_cross.cmake new file mode 100644 index 000000000..0ff9dd22e --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/oe-sdk_cross.cmake @@ -0,0 +1,30 @@ +# 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 . + +set(CMAKE_SYSTEM_NAME Linux) +string(REGEX MATCH "sysroots/([a-zA-Z0-9]+)" CMAKE_SYSTEM_PROCESSOR $ENV{SDKTARGETSYSROOT}) +string(REGEX REPLACE "sysroots/" "" CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}) +set(CMAKE_CXX_FLAGS $ENV{CXXFLAGS} CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS $ENV{CFLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_LDFLAGS_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_LIBRARY_PATH ${OECORE_TARGET_SYSROOT}/usr/lib) +set(CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} $ENV{OECORE_NATIVE_SYSROOT}) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(ORC_INCLUDE_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/include/orc-0.4) +set(ORC_LIBRARY_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/lib) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt index a1616a9b8..7af889751 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt @@ -470,8 +470,7 @@ if(${CMAKE_VERSION} VERSION_GREATER "2.8.9") if(ASM_ARCH STREQUAL "neonv7") message(STATUS "---- Adding ASM files") # we always use ATT syntax message(STATUS "-- Detected neon architecture; enabling ASM") - # setup architecture specific assembler flags - set(ARCH_ASM_FLAGS "-mfpu=neon -g") + # architecture specific assembler flags are now set in the cmake toolchain file # then add the files include_directories(${PROJECT_SOURCE_DIR}/kernels/volk_gnsssdr/asm/neon) file(GLOB asm_files ${PROJECT_SOURCE_DIR}/kernels/volk_gnsssdr/asm/neon/*.s) @@ -482,7 +481,6 @@ if(${CMAKE_VERSION} VERSION_GREATER "2.8.9") endforeach() endif() enable_language(ASM) - set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${ARCH_ASM_FLAGS}") message(STATUS "c flags: ${FULL_C_FLAGS}") message(STATUS "asm flags: ${CMAKE_ASM_FLAGS}") endforeach() From 4816ae64f7ca9957ba2da766c96fd4e725487693 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 1 Nov 2019 19:29:28 +0100 Subject: [PATCH 12/20] Add toolchain files for ARM processors --- CMakeLists.txt | 38 +++++++------ cmake/Modules/TestForARM.cmake | 19 ++++--- cmake/Toolchains/aarch64-linux-gnu.cmake | 50 +++++++++++++++++ cmake/Toolchains/arm-linux-gnueabihf.cmake | 53 +++++++++++++++++++ .../arm_cortex_a15_hardfp_native.cmake | 26 +++++++++ .../arm_cortex_a53_hardfp_native.cmake | 26 +++++++++ .../arm_cortex_a72_hardfp_native.cmake | 26 +++++++++ .../arm_cortex_a8_hardfp_native.cmake | 26 +++++++++ .../arm_cortex_a8_softfp_native.cmake | 26 +++++++++ .../arm_cortex_a9_hardfp_native.cmake | 26 +++++++++ cmake/Toolchains/raspi3.cmake | 26 +++++++++ cmake/Toolchains/raspi4.cmake | 26 +++++++++ .../arm_cortex_a15_hardfp_native.cmake | 2 +- .../arm_cortex_a53_hardfp_native.cmake | 2 +- .../arm_cortex_a72_hardfp_native.cmake | 2 +- .../arm_cortex_a8_hardfp_native.cmake | 2 +- .../arm_cortex_a8_softfp_native.cmake | 2 +- .../arm_cortex_a9_hardfp_native.cmake | 2 +- src/tests/CMakeLists.txt | 3 ++ 19 files changed, 354 insertions(+), 29 deletions(-) create mode 100644 cmake/Toolchains/aarch64-linux-gnu.cmake create mode 100644 cmake/Toolchains/arm-linux-gnueabihf.cmake create mode 100644 cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake create mode 100644 cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake create mode 100644 cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake create mode 100644 cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake create mode 100644 cmake/Toolchains/arm_cortex_a8_softfp_native.cmake create mode 100644 cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake create mode 100644 cmake/Toolchains/raspi3.cmake create mode 100644 cmake/Toolchains/raspi4.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 5173456b2..c4d1542be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -978,6 +978,12 @@ if(NOT VOLKGNSSSDR_FOUND) -DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/Toolchains/oe-sdk_cross.cmake -DCROSSCOMPILE_MULTILIB=TRUE ) + else() + if(CMAKE_TOOLCHAIN_FILE) + set(VOLK_GNSSSDR_CMAKE_ARGS ${VOLK_GNSSSDR_CMAKE_ARGS} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + ) + endif() endif() if(CMAKE_VERSION VERSION_LESS 3.2) ExternalProject_Add(volk_gnsssdr_module @@ -1770,6 +1776,10 @@ if(NOT PUGIXML_FOUND) if(DEFINED ENV{OECORE_TARGET_SYSROOT}) set(PUGIXML_COMPILER "") set(TOOLCHAIN_ARG "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/Toolchains/oe-sdk_cross.cmake") + else() + if(CMAKE_TOOLCHAIN_FILE) + set(TOOLCHAIN_ARG "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") + endif() endif() if(CMAKE_VERSION VERSION_LESS 3.2) ExternalProject_Add(pugixml-${GNSSSDR_PUGIXML_LOCAL_VERSION} @@ -2486,9 +2496,14 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0") add_compile_options(-Wno-missing-field-initializers) endif() - if(CMAKE_CROSSCOMPILING) + if(CMAKE_CROSSCOMPILING OR NOT ENABLE_PACKAGING) add_compile_options(-Wno-psabi) endif() + if(IS_ARM) + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.1.0") + add_compile_options(-faligned-new) + endif() + endif() endif() if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(NOT (CMAKE_VERSION VERSION_LESS "3.3")) @@ -2501,22 +2516,11 @@ endif() # Processor-architecture related flags # See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) - if(OS_IS_MACOSX) - add_compile_options(-march=corei7 -mfpmath=sse) - else() - if(NOT ENABLE_GENERIC_ARCH) - if(IS_ARM) - # ARM-specific options - # See https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html - if(NOT CMAKE_CROSSCOMPILING) - if(ARM_VERSION STREQUAL "arm") - # Unknown arm version - try our best to detect - add_compile_options(-mcpu=native) - else() - add_compile_options(-march=${ARM_VERSION}) - endif() - endif() - else() + if(NOT ENABLE_GENERIC_ARCH) + if(OS_IS_MACOSX) + add_compile_options(-march=corei7 -mfpmath=sse) + else() + if(NOT IS_ARM) add_compile_options(-march=native -mfpmath=sse) endif() endif() diff --git a/cmake/Modules/TestForARM.cmake b/cmake/Modules/TestForARM.cmake index 05a5c172e..1bc65eb42 100644 --- a/cmake/Modules/TestForARM.cmake +++ b/cmake/Modules/TestForARM.cmake @@ -38,12 +38,18 @@ endfunction() message(STATUS "Checking for ARM") -set(IS_ARM NO) +set(IS_ARM FALSE) set(ARM_VERSION "") +if(ENABLE_PACKAGING) + set(VERBOSE_BUILDING "-v") +else() + set(VERBOSE_BUILDING "") +endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") execute_process(COMMAND echo "int main(){}" - COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -dM -E - + COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -dM ${VERBOSE_BUILDING} -E - OUTPUT_VARIABLE TEST_FOR_ARM_RESULTS) string(REGEX MATCH "__arm" ARM_FOUND "${TEST_FOR_ARM_RESULTS}") @@ -52,7 +58,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") endif() if(NOT ARM_FOUND STREQUAL "") - set(IS_ARM YES) + set(IS_ARM TRUE) message(STATUS "ARM system detected") # detect the version @@ -92,10 +98,11 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") else() message(STATUS "System is not ARM") endif() - +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "ARMClang") + set(IS_ARM TRUE) + set(ARM_VERSION "arm") else() - # TODO: Other compilers - message(STATUS "Not detecting ARM on non-GNUCXX compiler. Defaulting to false") + message(STATUS "Not detecting ARM on non-GNUCXX or non-ARMClang compiler. Defaulting to false") message(STATUS "If you are compiling for ARM, set IS_ARM=ON manually") endif() diff --git a/cmake/Toolchains/aarch64-linux-gnu.cmake b/cmake/Toolchains/aarch64-linux-gnu.cmake new file mode 100644 index 000000000..610fde597 --- /dev/null +++ b/cmake/Toolchains/aarch64-linux-gnu.cmake @@ -0,0 +1,50 @@ +# 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 . + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR ARM) + +if(MINGW OR CYGWIN OR WIN32) + set(UTIL_SEARCH_CMD where) +elseif(UNIX OR APPLE) + set(UTIL_SEARCH_CMD which) +endif() + +set(TOOLCHAIN_PREFIX aarch64-linux-gnu-) + +execute_process( + COMMAND ${UTIL_SEARCH_CMD} ${TOOLCHAIN_PREFIX}gcc + OUTPUT_VARIABLE BINUTILS_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +get_filename_component(ARM_TOOLCHAIN_DIR ${BINUTILS_PATH} DIRECTORY) + +# The following is not needed on debian +# Without that flag CMake is not able to pass test compilation check +#set(CMAKE_EXE_LINKER_FLAGS_INIT "--specs=nosys.specs") + +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc) +set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++) + +set(CMAKE_OBJCOPY ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy CACHE INTERNAL "objcopy tool") +set(CMAKE_SIZE_UTIL ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size CACHE INTERNAL "size tool") + +set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH}) + +set(CMAKE_CROSSCOMPILING_EMULATOR "qemu-aarch64 -L /usr/aarch64-linux-gnu/") diff --git a/cmake/Toolchains/arm-linux-gnueabihf.cmake b/cmake/Toolchains/arm-linux-gnueabihf.cmake new file mode 100644 index 000000000..8c1d0144b --- /dev/null +++ b/cmake/Toolchains/arm-linux-gnueabihf.cmake @@ -0,0 +1,53 @@ +# 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 . + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR ARM) + +if(MINGW OR CYGWIN OR WIN32) + set(UTIL_SEARCH_CMD where) +elseif(UNIX OR APPLE) + set(UTIL_SEARCH_CMD which) +endif() + +set(TOOLCHAIN_PREFIX arm-linux-gnueabihf-) + +execute_process( + COMMAND ${UTIL_SEARCH_CMD} ${TOOLCHAIN_PREFIX}gcc + OUTPUT_VARIABLE BINUTILS_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +get_filename_component(ARM_TOOLCHAIN_DIR ${BINUTILS_PATH} DIRECTORY) + +# The following is not needed on debian +# Without that flag CMake is not able to pass test compilation check +#set(CMAKE_EXE_LINKER_FLAGS_INIT "--specs=nosys.specs") + +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc) +set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++) +## the following is needed for CheckCSourceCompiles used in lib/CMakeLists.txt +set(CMAKE_C_FLAGS "-mfpu=neon" CACHE STRING "" FORCE) +set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "" FORCE) + +set(CMAKE_OBJCOPY ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy CACHE INTERNAL "objcopy tool") +set(CMAKE_SIZE_UTIL ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size CACHE INTERNAL "size tool") + +set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH}) + +set(CMAKE_CROSSCOMPILING_EMULATOR "qemu-arm -L /usr/arm-linux-gnueabihf/") diff --git a/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake b/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake new file mode 100644 index 000000000..d629f8c11 --- /dev/null +++ b/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake @@ -0,0 +1,26 @@ +# 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 . + +######################################################################## +# Toolchain file for building native on a ARM Cortex A8 w/ NEON +# Usage: cmake -DCMAKE_TOOLCHAIN_FILE= +######################################################################## +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS "-march=armv7-a -mtune=cortex-a15 -mfpu=neon -mfloat-abi=hard" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake b/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake new file mode 100644 index 000000000..3c33a042d --- /dev/null +++ b/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake @@ -0,0 +1,26 @@ +# 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 . + +######################################################################## +# Toolchain file for building native on a ARM Cortex A72 w/ NEON +# Usage: cmake -DCMAKE_TOOLCHAIN_FILE= +######################################################################## +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS "-march=armv8-a -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -mthumb -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake b/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake new file mode 100644 index 000000000..581d72a80 --- /dev/null +++ b/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake @@ -0,0 +1,26 @@ +# 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 . + +######################################################################## +# Toolchain file for building native on a ARM Cortex A72 w/ NEON +# Usage: cmake -DCMAKE_TOOLCHAIN_FILE= +######################################################################## +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS "-march=armv8-a -mtune=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -mthumb -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake b/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake new file mode 100644 index 000000000..3b69f9b88 --- /dev/null +++ b/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake @@ -0,0 +1,26 @@ +# 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 . + +######################################################################## +# Toolchain file for building native on a ARM Cortex A8 w/ NEON +# Usage: cmake -DCMAKE_TOOLCHAIN_FILE= +######################################################################## +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS "-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=hard" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake b/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake new file mode 100644 index 000000000..2aa09caf4 --- /dev/null +++ b/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake @@ -0,0 +1,26 @@ +# 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 . + +######################################################################## +# Toolchain file for building native on a ARM Cortex A8 w/ NEON +# Usage: cmake -DCMAKE_TOOLCHAIN_FILE= +######################################################################## +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS "-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake b/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake new file mode 100644 index 000000000..2ebeb69ea --- /dev/null +++ b/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake @@ -0,0 +1,26 @@ +# 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 . + +######################################################################## +# Toolchain file for building native on a ARM Cortex A8 w/ NEON +# Usage: cmake -DCMAKE_TOOLCHAIN_FILE= +######################################################################## +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS "-march=armv7-a -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/cmake/Toolchains/raspi3.cmake b/cmake/Toolchains/raspi3.cmake new file mode 100644 index 000000000..3c33a042d --- /dev/null +++ b/cmake/Toolchains/raspi3.cmake @@ -0,0 +1,26 @@ +# 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 . + +######################################################################## +# Toolchain file for building native on a ARM Cortex A72 w/ NEON +# Usage: cmake -DCMAKE_TOOLCHAIN_FILE= +######################################################################## +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS "-march=armv8-a -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -mthumb -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/cmake/Toolchains/raspi4.cmake b/cmake/Toolchains/raspi4.cmake new file mode 100644 index 000000000..581d72a80 --- /dev/null +++ b/cmake/Toolchains/raspi4.cmake @@ -0,0 +1,26 @@ +# 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 . + +######################################################################## +# Toolchain file for building native on a ARM Cortex A72 w/ NEON +# Usage: cmake -DCMAKE_TOOLCHAIN_FILE= +######################################################################## +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS "-march=armv8-a -mtune=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources +set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -mthumb -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake index 9a461f21d..d629f8c11 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a15_hardfp_native.cmake @@ -20,7 +20,7 @@ # Usage: cmake -DCMAKE_TOOLCHAIN_FILE= ######################################################################## set(CMAKE_CXX_COMPILER g++) -set(CMAKE_C_COMPILER gcc) +set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_FLAGS "-march=armv7-a -mtune=cortex-a15 -mfpu=neon -mfloat-abi=hard" CACHE STRING "" FORCE) set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake index ebaa10bce..3c33a042d 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a53_hardfp_native.cmake @@ -20,7 +20,7 @@ # Usage: cmake -DCMAKE_TOOLCHAIN_FILE= ######################################################################## set(CMAKE_CXX_COMPILER g++) -set(CMAKE_C_COMPILER gcc) +set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_FLAGS "-march=armv8-a -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard" CACHE STRING "" FORCE) set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -mthumb -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake index ea4c0dc25..581d72a80 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a72_hardfp_native.cmake @@ -20,7 +20,7 @@ # Usage: cmake -DCMAKE_TOOLCHAIN_FILE= ######################################################################## set(CMAKE_CXX_COMPILER g++) -set(CMAKE_C_COMPILER gcc) +set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_FLAGS "-march=armv8-a -mtune=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard" CACHE STRING "" FORCE) set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -mthumb -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake index 0bd2b13cc..3b69f9b88 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a8_hardfp_native.cmake @@ -20,7 +20,7 @@ # Usage: cmake -DCMAKE_TOOLCHAIN_FILE= ######################################################################## set(CMAKE_CXX_COMPILER g++) -set(CMAKE_C_COMPILER gcc) +set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_FLAGS "-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=hard" CACHE STRING "" FORCE) set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake index f870f5034..2aa09caf4 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a8_softfp_native.cmake @@ -20,7 +20,7 @@ # Usage: cmake -DCMAKE_TOOLCHAIN_FILE= ######################################################################## set(CMAKE_CXX_COMPILER g++) -set(CMAKE_C_COMPILER gcc) +set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_FLAGS "-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp" CACHE STRING "" FORCE) set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake index 7880d5e24..2ebeb69ea 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/arm_cortex_a9_hardfp_native.cmake @@ -20,7 +20,7 @@ # Usage: cmake -DCMAKE_TOOLCHAIN_FILE= ######################################################################## set(CMAKE_CXX_COMPILER g++) -set(CMAKE_C_COMPILER gcc) +set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_FLAGS "-march=armv7-a -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard" CACHE STRING "" FORCE) set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) # same flags for C sources set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -g" CACHE STRING "" FORCE) # same flags for asm sources diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index db4c32e24..8d733e8f2 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -29,6 +29,9 @@ if(DEFINED ENV{OECORE_TARGET_SYSROOT}) set(GTEST_COMPILER "") set(TOOLCHAIN_ARG "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Toolchains/oe-sdk_cross.cmake") else() + if(CMAKE_TOOLCHAIN_FILE) + set(TOOLCHAIN_ARG "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") + endif() if(ENABLE_PACKAGING) set(TOOLCHAIN_ARG "-DCMAKE_VERBOSE_MAKEFILE=ON") endif() From 8bfc0b80857dfa35b933f1bb8c5960de74273912 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 1 Nov 2019 19:35:47 +0100 Subject: [PATCH 13/20] Fix compiler flag --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4d1542be..2f85a621e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2501,7 +2501,12 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) endif() if(IS_ARM) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.1.0") - add_compile_options(-faligned-new) + set(CXX_ALIGN_FLAG -faligned-new) + if(NOT (CMAKE_VERSION VERSION_LESS "3.3")) + add_compile_options("$<$:${CXX_ALIGN_FLAG}>") + else() + add_compile_options("$<$,CXX>:${CXX_ALIGN_FLAG}>") + endif() endif() endif() endif() From c92e0cb5c07b6c85942a1cb0bba1f763d4e16d84 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 1 Nov 2019 20:16:21 +0100 Subject: [PATCH 14/20] Add work on compiler flags --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f85a621e..dd97b7508 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2525,7 +2525,13 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) if(OS_IS_MACOSX) add_compile_options(-march=corei7 -mfpmath=sse) else() - if(NOT IS_ARM) + if(IS_ARM) + # ARM-specific options + # See https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html + if(NOT CMAKE_CROSSCOMPILING) + add_compile_options(-mcpu=native) + endif() + else() add_compile_options(-march=native -mfpmath=sse) endif() endif() From a0da65ed8a8b741b3a7377d1dbbaa06a78fd96ac Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 1 Nov 2019 20:24:39 +0100 Subject: [PATCH 15/20] Fix compiler flags when using CMAKE_TOOLCHAIN_FILE in ARM processors --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd97b7508..9f604de06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2528,7 +2528,7 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) if(IS_ARM) # ARM-specific options # See https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html - if(NOT CMAKE_CROSSCOMPILING) + if(NOT CMAKE_CROSSCOMPILING AND NOT CMAKE_TOOLCHAIN_FILE) add_compile_options(-mcpu=native) endif() else() From 75c2dcc9298cd44d4779897fd2602be1c99f90e2 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 1 Nov 2019 21:02:43 +0100 Subject: [PATCH 16/20] Remove unused variable --- CMakeLists.txt | 1 - .../libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f604de06..c22408b72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -968,7 +968,6 @@ if(NOT VOLKGNSSSDR_FOUND) -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install -DENABLE_STATIC_LIBS=ON -DENABLE_PROFILING=${ENABLE_PROFILING} - -DCMAKE_INCLUDE_PATH=${Boost_INCLUDE_DIR} -DENABLE_ORC=OFF ${STRIP_VOLK_GNSSSDR_PROFILE} ${USE_THIS_PYTHON} diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index 26b6bcf59..ca3c05aca 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -255,7 +255,6 @@ endif() if(${FILESYSTEM_FOUND}) set(Boost_LIBRARIES "") set(Boost_INCLUDE_DIRS "") - set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH}) else() include(VolkBoost) if(NOT Boost_FOUND) From 87974a9456a5ffbf109e6f2ba47b55a45a865ef6 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 1 Nov 2019 23:05:31 +0100 Subject: [PATCH 17/20] Add compiler flags for clang --- CMakeLists.txt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c22408b72..04adcc66d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2520,18 +2520,30 @@ endif() # Processor-architecture related flags # See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) + if(NOT ENABLE_GENERIC_ARCH) + if(IS_ARM) + # ARM-specific options + # See https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html + if(NOT CMAKE_CROSSCOMPILING AND NOT CMAKE_TOOLCHAIN_FILE) + add_compile_options(-mtune=native) + endif() + else() + add_compile_options(-march=native) + endif() + endif() +endif() +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(NOT ENABLE_GENERIC_ARCH) if(OS_IS_MACOSX) - add_compile_options(-march=corei7 -mfpmath=sse) + add_compile_options(-march=native) else() if(IS_ARM) # ARM-specific options - # See https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html if(NOT CMAKE_CROSSCOMPILING AND NOT CMAKE_TOOLCHAIN_FILE) add_compile_options(-mcpu=native) endif() else() - add_compile_options(-march=native -mfpmath=sse) + add_compile_options(-march=native) endif() endif() endif() From 681022b9c9bdc4ad8593b02d62a12fee37acce7d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 1 Nov 2019 23:27:10 +0100 Subject: [PATCH 18/20] Allow to specify IS_ARM manually --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04adcc66d..3da74db4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -515,7 +515,9 @@ if(NOT OS_IS_MACOSX) set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE) endif() else() - include(TestForARM) + if(NOT IS_ARM) + include(TestForARM) + endif() endif() endif() From d6b4ba4fc33777f08fc8102f70adfd58f63e66ee Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 2 Nov 2019 00:12:47 +0100 Subject: [PATCH 19/20] Detect ARM processors when using clang --- cmake/Modules/TestForARM.cmake | 130 ++++++++++++++++++--------------- 1 file changed, 73 insertions(+), 57 deletions(-) diff --git a/cmake/Modules/TestForARM.cmake b/cmake/Modules/TestForARM.cmake index 1bc65eb42..e6a82674e 100644 --- a/cmake/Modules/TestForARM.cmake +++ b/cmake/Modules/TestForARM.cmake @@ -23,17 +23,17 @@ ############################################################################## if(__TEST_FOR_ARM_INCLUDED) - return() + return() endif() set(__TEST_FOR_ARM_INCLUDED TRUE) # Function checks if the input string defines ARM version and sets the # output variable if found. function(check_arm_version ppdef input_string version output_var) - string(REGEX MATCH "${ppdef}" _VERSION_MATCH "${input_string}") - if(NOT _VERSION_MATCH STREQUAL "") - set(${output_var} "${version}" PARENT_SCOPE) - endif() + string(REGEX MATCH "${ppdef}" _VERSION_MATCH "${input_string}") + if(NOT _VERSION_MATCH STREQUAL "") + set(${output_var} "${version}" PARENT_SCOPE) + endif() endfunction() message(STATUS "Checking for ARM") @@ -48,62 +48,78 @@ else() endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - execute_process(COMMAND echo "int main(){}" - COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -dM ${VERBOSE_BUILDING} -E - - OUTPUT_VARIABLE TEST_FOR_ARM_RESULTS) + execute_process(COMMAND echo "int main(){}" + COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -dM ${VERBOSE_BUILDING} -E - + OUTPUT_VARIABLE TEST_FOR_ARM_RESULTS + ) - string(REGEX MATCH "__arm" ARM_FOUND "${TEST_FOR_ARM_RESULTS}") - if(ARM_FOUND STREQUAL "") - string(REGEX MATCH "__aarch64" ARM_FOUND "${TEST_FOR_ARM_RESULTS}") - endif() - - if(NOT ARM_FOUND STREQUAL "") - set(IS_ARM TRUE) - message(STATUS "ARM system detected") - - # detect the version - check_arm_version("__ARM_ARCH_2__" ${TEST_FOR_ARM_RESULTS} "armv2" ARM_VERSION) - check_arm_version("__ARM_ARCH_2A__" ${TEST_FOR_ARM_RESULTS} "armv2a" ARM_VERSION) - check_arm_version("__ARM_ARCH_3__" ${TEST_FOR_ARM_RESULTS} "armv3" ARM_VERSION) - check_arm_version("__ARM_ARCH_3M__" ${TEST_FOR_ARM_RESULTS} "armv3m" ARM_VERSION) - check_arm_version("__ARM_ARCH_4__" ${TEST_FOR_ARM_RESULTS} "armv4" ARM_VERSION) - check_arm_version("__ARM_ARCH_4T__" ${TEST_FOR_ARM_RESULTS} "armv4t" ARM_VERSION) - check_arm_version("__ARM_ARCH_5__" ${TEST_FOR_ARM_RESULTS} "armv5" ARM_VERSION) - check_arm_version("__ARM_ARCH_5T__" ${TEST_FOR_ARM_RESULTS} "armv5t" ARM_VERSION) - check_arm_version("__ARM_ARCH_5E__" ${TEST_FOR_ARM_RESULTS} "armv5e" ARM_VERSION) - check_arm_version("__ARM_ARCH_5TE__" ${TEST_FOR_ARM_RESULTS} "armv5te" ARM_VERSION) - check_arm_version("__ARM_ARCH_6__" ${TEST_FOR_ARM_RESULTS} "armv6" ARM_VERSION) - check_arm_version("__ARM_ARCH_6J__" ${TEST_FOR_ARM_RESULTS} "armv6j" ARM_VERSION) - check_arm_version("__ARM_ARCH_6K__" ${TEST_FOR_ARM_RESULTS} "armv6k" ARM_VERSION) - check_arm_version("__ARM_ARCH_6T2__" ${TEST_FOR_ARM_RESULTS} "armv6t2" ARM_VERSION) - check_arm_version("__ARM_ARCH_6Z__" ${TEST_FOR_ARM_RESULTS} "armv6z" ARM_VERSION) - check_arm_version("__ARM_ARCH_6ZK__" ${TEST_FOR_ARM_RESULTS} "armv6zk" ARM_VERSION) - check_arm_version("__ARM_ARCH_6M__" ${TEST_FOR_ARM_RESULTS} "armv6-m" ARM_VERSION) - check_arm_version("__ARM_ARCH_7__" ${TEST_FOR_ARM_RESULTS} "armv7" ARM_VERSION) - check_arm_version("__ARM_ARCH_7A__" ${TEST_FOR_ARM_RESULTS} "armv7-a" ARM_VERSION) - check_arm_version("__ARM_ARCH_7M__" ${TEST_FOR_ARM_RESULTS} "armv7-m" ARM_VERSION) - check_arm_version("__ARM_ARCH_7R__" ${TEST_FOR_ARM_RESULTS} "armv7-r" ARM_VERSION) - check_arm_version("__ARM_ARCH_7EM_" ${TEST_FOR_ARM_RESULTS} "armv7e-m" ARM_VERSION) - check_arm_version("__ARM_ARCH_7VE__" ${TEST_FOR_ARM_RESULTS} "armv7ve" ARM_VERSION) - check_arm_version("__ARM_ARCH_8A__" ${TEST_FOR_ARM_RESULTS} "armv8-a" ARM_VERSION) - check_arm_version("__ARM_ARCH_8A" ${TEST_FOR_ARM_RESULTS} "armv8-a" ARM_VERSION) - - # anything else just define as arm - if(ARM_VERSION STREQUAL "") - message(STATUS "Couldn't detect ARM version. Setting to 'arm'") - set(ARM_VERSION "arm") - else() - message(STATUS "ARM version ${ARM_VERSION} detected") + string(REGEX MATCH "__arm" ARM_FOUND "${TEST_FOR_ARM_RESULTS}") + if(ARM_FOUND STREQUAL "") + string(REGEX MATCH "__aarch64" ARM_FOUND "${TEST_FOR_ARM_RESULTS}") + endif() + if(ARM_FOUND STREQUAL "") + if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm") + set(ARM_FOUND ${CMAKE_HOST_SYSTEM_PROCESSOR}) + endif() + endif() + + if(NOT ARM_FOUND STREQUAL "") + set(IS_ARM TRUE) + message(STATUS "ARM system detected.") + + # detect the version + check_arm_version("__ARM_ARCH_2__" ${TEST_FOR_ARM_RESULTS} "armv2" ARM_VERSION) + check_arm_version("__ARM_ARCH_2A__" ${TEST_FOR_ARM_RESULTS} "armv2a" ARM_VERSION) + check_arm_version("__ARM_ARCH_3__" ${TEST_FOR_ARM_RESULTS} "armv3" ARM_VERSION) + check_arm_version("__ARM_ARCH_3M__" ${TEST_FOR_ARM_RESULTS} "armv3m" ARM_VERSION) + check_arm_version("__ARM_ARCH_4__" ${TEST_FOR_ARM_RESULTS} "armv4" ARM_VERSION) + check_arm_version("__ARM_ARCH_4T__" ${TEST_FOR_ARM_RESULTS} "armv4t" ARM_VERSION) + check_arm_version("__ARM_ARCH_5__" ${TEST_FOR_ARM_RESULTS} "armv5" ARM_VERSION) + check_arm_version("__ARM_ARCH_5T__" ${TEST_FOR_ARM_RESULTS} "armv5t" ARM_VERSION) + check_arm_version("__ARM_ARCH_5E__" ${TEST_FOR_ARM_RESULTS} "armv5e" ARM_VERSION) + check_arm_version("__ARM_ARCH_5TE__" ${TEST_FOR_ARM_RESULTS} "armv5te" ARM_VERSION) + check_arm_version("__ARM_ARCH_6__" ${TEST_FOR_ARM_RESULTS} "armv6" ARM_VERSION) + check_arm_version("__ARM_ARCH_6J__" ${TEST_FOR_ARM_RESULTS} "armv6j" ARM_VERSION) + check_arm_version("__ARM_ARCH_6K__" ${TEST_FOR_ARM_RESULTS} "armv6k" ARM_VERSION) + check_arm_version("__ARM_ARCH_6T2__" ${TEST_FOR_ARM_RESULTS} "armv6t2" ARM_VERSION) + check_arm_version("__ARM_ARCH_6Z__" ${TEST_FOR_ARM_RESULTS} "armv6z" ARM_VERSION) + check_arm_version("__ARM_ARCH_6ZK__" ${TEST_FOR_ARM_RESULTS} "armv6zk" ARM_VERSION) + check_arm_version("__ARM_ARCH_6M__" ${TEST_FOR_ARM_RESULTS} "armv6-m" ARM_VERSION) + check_arm_version("__ARM_ARCH_7__" ${TEST_FOR_ARM_RESULTS} "armv7" ARM_VERSION) + check_arm_version("__ARM_ARCH_7A__" ${TEST_FOR_ARM_RESULTS} "armv7-a" ARM_VERSION) + check_arm_version("__ARM_ARCH_7M__" ${TEST_FOR_ARM_RESULTS} "armv7-m" ARM_VERSION) + check_arm_version("__ARM_ARCH_7R__" ${TEST_FOR_ARM_RESULTS} "armv7-r" ARM_VERSION) + check_arm_version("__ARM_ARCH_7EM_" ${TEST_FOR_ARM_RESULTS} "armv7e-m" ARM_VERSION) + check_arm_version("__ARM_ARCH_7VE__" ${TEST_FOR_ARM_RESULTS} "armv7ve" ARM_VERSION) + check_arm_version("__ARM_ARCH_8A__" ${TEST_FOR_ARM_RESULTS} "armv8-a" ARM_VERSION) + check_arm_version("__ARM_ARCH_8A" ${TEST_FOR_ARM_RESULTS} "armv8-a" ARM_VERSION) + + # anything else just define as unknown + if(ARM_VERSION STREQUAL "") + message(STATUS "Couldn't detect ARM version.") + set(ARM_VERSION "unknown") + else() + message(STATUS "ARM version ${ARM_VERSION} detected.") + endif() + else() + message(STATUS "System is not ARM.") + endif() +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm") + set(IS_ARM TRUE) + set(ARM_VERSION ${CMAKE_HOST_SYSTEM_PROCESSOR}) + message(STATUS "ARM version ${ARM_VERSION} detected.") endif() - else() - message(STATUS "System is not ARM") - endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "ARMClang") - set(IS_ARM TRUE) - set(ARM_VERSION "arm") + set(IS_ARM TRUE) + set(ARM_VERSION "arm") + if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm") + set(ARM_VERSION ${CMAKE_HOST_SYSTEM_PROCESSOR}) + message(STATUS "ARM version ${ARM_VERSION} detected.") + endif() else() - message(STATUS "Not detecting ARM on non-GNUCXX or non-ARMClang compiler. Defaulting to false") - message(STATUS "If you are compiling for ARM, set IS_ARM=ON manually") + message(STATUS "Not detecting ARM on non-GNUCXX or non-Clang compiler. Defaulting to false.") + message(STATUS "If you are compiling for ARM, set -DIS_ARM=ON manually.") endif() set(IS_ARM ${IS_ARM} CACHE BOOL "Compiling for ARM") From 6a21f232fff4050294ae88d0e60a4dce6472dbf4 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 2 Nov 2019 10:22:35 +0100 Subject: [PATCH 20/20] Use -faligned-new compiler flag only if needed --- CMakeLists.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3da74db4e..59768d8b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2501,12 +2501,14 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) add_compile_options(-Wno-psabi) endif() if(IS_ARM) - if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.1.0") - set(CXX_ALIGN_FLAG -faligned-new) - if(NOT (CMAKE_VERSION VERSION_LESS "3.3")) - add_compile_options("$<$:${CXX_ALIGN_FLAG}>") - else() - add_compile_options("$<$,CXX>:${CXX_ALIGN_FLAG}>") + if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.1.0") AND (CMAKE_VERSION VERSION_GREATER "3.1")) + if(CMAKE_CXX_STANDARD VERSION_LESS 17) + set(CXX_ALIGN_FLAG -faligned-new) + if(NOT (CMAKE_VERSION VERSION_LESS "3.3")) + add_compile_options("$<$:${CXX_ALIGN_FLAG}>") + else() + add_compile_options("$<$,CXX>:${CXX_ALIGN_FLAG}>") + endif() endif() endif() endif()