1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-12 19:20:32 +00:00

Improve detection of Gnuplot and gnss_sim when cross-compiling

This commit is contained in:
Carles Fernandez 2021-08-02 09:33:16 +02:00
parent 75eafeb44c
commit b4b9c31182
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
4 changed files with 66 additions and 5 deletions

View File

@ -1,7 +1,7 @@
# GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
# This file is part of GNSS-SDR.
#
# SPDX-FileCopyrightText: 2011-2020 C. Fernandez-Prades cfernandez(at)cttc.es
# SPDX-FileCopyrightText: 2011-2021 C. Fernandez-Prades cfernandez(at)cttc.es
# SPDX-License-Identifier: BSD-3-Clause
if(GNSSSIMULATOR_ROOT)
@ -27,8 +27,17 @@ find_program(SW_GENERATOR_BIN gnss_sim
/usr/local
/opt/local
PATH_SUFFIXES bin
ONLY_CMAKE_FIND_ROOT_PATH
)
if(SW_GENERATOR_BIN AND CMAKE_CROSSCOMPILING)
if(CMAKE_SYSROOT)
string(REGEX REPLACE "${CMAKE_SYSROOT}" "" SW_GENERATOR_BIN "${SW_GENERATOR_BIN}")
elseif(DEFINED ENV{OECORE_TARGET_SYSROOT})
string(REGEX REPLACE "$ENV{OECORE_TARGET_SYSROOT}" "" SW_GENERATOR_BIN "${SW_GENERATOR_BIN}")
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GNSSSIMULATOR DEFAULT_MSG SW_GENERATOR_BIN)
mark_as_advanced(SW_GENERATOR_BIN)

View File

@ -0,0 +1,45 @@
# GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
# This file is part of GNSS-SDR.
#
# SPDX-FileCopyrightText: 2021 C. Fernandez-Prades cfernandez(at)cttc.es
# SPDX-License-Identifier: BSD-3-Clause
find_program(GNUPLOT_EXECUTABLE
NAMES
gnuplot
pgnuplot
PATHS
/usr/bin
/usr/local/bin
/opt/local/bin
ONLY_CMAKE_FIND_ROOT_PATH
)
if(NOT CMAKE_CROSSCOMPILING)
if(GNUPLOT_EXECUTABLE)
execute_process(COMMAND "${GNUPLOT_EXECUTABLE}" --version
OUTPUT_VARIABLE GNUPLOT_OUTPUT_VARIABLE
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REGEX REPLACE "^gnuplot ([0-9\\.]+)( patchlevel )?" "\\1." GNUPLOT_VERSION_STRING "${GNUPLOT_OUTPUT_VARIABLE}")
string(REGEX REPLACE "\\.$" "" GNUPLOT_VERSION_STRING "${GNUPLOT_VERSION_STRING}")
unset(GNUPLOT_OUTPUT_VARIABLE)
endif()
else()
if(GNUPLOT_EXECUTABLE)
if(CMAKE_SYSROOT)
string(REGEX REPLACE "${CMAKE_SYSROOT}" "" GNUPLOT_EXECUTABLE "${GNUPLOT_EXECUTABLE}")
elseif(DEFINED ENV{OECORE_TARGET_SYSROOT})
string(REGEX REPLACE "$ENV{OECORE_TARGET_SYSROOT}" "" GNUPLOT_EXECUTABLE "${GNUPLOT_EXECUTABLE}")
endif()
else()
message(STATUS "Warning: Gnuplot is not found, you can install it later.")
message(STATUS " Setting default path to /usr/bin/gnuplot")
set(GNUPLOT_EXECUTABLE "/usr/bin/gnuplot")
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GNUPLOT DEFAULT_MSG GNUPLOT_EXECUTABLE)

View File

@ -74,6 +74,7 @@ All notable changes to GNSS-SDR will be documented in this file.
- Added support for Apple M1 AArch64 architecture processor and for FreeBSD on
x86, improved AMD microarchitecture detection.
- CMake now selects the C++23 standard if the environment allows for it.
- Improved detection of Gnuplot and `gnss_sim` when cross-compiling.
### Improvements in Reliability

View File

@ -248,21 +248,21 @@ if(has_std_plus_void)
add_definitions(-DCOMPILER_HAS_STD_PLUS_VOID=1)
endif()
find_package(Gnuplot)
find_package(GNUPLOT)
if(GNUPLOT_FOUND)
add_definitions(-DGNUPLOT_EXECUTABLE="${GNUPLOT_EXECUTABLE}")
endif()
set_package_properties(Gnuplot PROPERTIES
set_package_properties(GNUPLOT PROPERTIES
URL "http://www.gnuplot.info"
PURPOSE "Used to generate plots in some tests."
TYPE OPTIONAL
)
if(GNUPLOT_FOUND AND GNUPLOT_VERSION_STRING)
set_package_properties(Gnuplot PROPERTIES
set_package_properties(GNUPLOT PROPERTIES
DESCRIPTION "A portable command-line driven graphing utility (found: v${GNUPLOT_VERSION_STRING})"
)
else()
set_package_properties(Gnuplot PROPERTIES
set_package_properties(GNUPLOT PROPERTIES
DESCRIPTION "A portable command-line driven graphing utility"
)
endif()
@ -287,6 +287,12 @@ if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA)
endif()
find_package(GNSSSIMULATOR QUIET)
if(GNSSSIMULATOR_FOUND OR NOT ENABLE_GNSS_SIM_INSTALL)
if(NOT GNSSSIMULATOR_FOUND)
message(STATUS "Warning: gnss_sim has not been found, you can install it later.")
message(STATUS " See https://bitbucket.org/jarribas/gnss-simulator")
message(STATUS " It is expected at /usr/bin/gnss_sim")
set(SW_GENERATOR_BIN "/usr/bin/gnss_sim")
endif()
add_definitions(-DSW_GENERATOR_BIN="${SW_GENERATOR_BIN}")
add_definitions(-DDEFAULT_RINEX_NAV="${CMAKE_INSTALL_PREFIX}/share/gnss-sim/brdc3540.14n")
add_definitions(-DDEFAULT_POSITION_FILE="${CMAKE_INSTALL_PREFIX}/share/gnss-sim/circle.csv")