From 9db6f55b3cf49faef9732fd15c77c5f57abb332f Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 5 Jul 2022 17:37:21 +0200 Subject: [PATCH] Fix when building for GNSSTk 12.1.0 or older --- cmake/Modules/FindGNSSTK.cmake | 33 +++++++++++++++++++-------- src/tests/CMakeLists.txt | 2 +- src/utils/rinex-tools/CMakeLists.txt | 14 +++++++----- src/utils/rinex-tools/obsdiff.cc | 14 ++++++------ src/utils/rinex2assist/CMakeLists.txt | 6 ++--- 5 files changed, 41 insertions(+), 28 deletions(-) diff --git a/cmake/Modules/FindGNSSTK.cmake b/cmake/Modules/FindGNSSTK.cmake index ba0accb6e..310afe0b7 100644 --- a/cmake/Modules/FindGNSSTK.cmake +++ b/cmake/Modules/FindGNSSTK.cmake @@ -32,7 +32,7 @@ if(DEFINED ENV{GNSSTK_ROOT}) endif() unset(GNSSTK_INCLUDE_DIR CACHE) -set(GNSSTK_USES_GPSTK_NAMESPACE FALSE) +unset(GNSSTK_USES_GPSTK_NAMESPACE CACHE) find_path(GNSSTK_INCLUDE_DIR gnsstk/Rinex3ObsBase.hpp PATHS ${GNSSTK_ROOT_USER_DEFINED}/include /usr/include @@ -40,16 +40,18 @@ find_path(GNSSTK_INCLUDE_DIR gnsstk/Rinex3ObsBase.hpp /opt/local/include ) set(GNSSTK_NAMES ${CMAKE_FIND_LIBRARY_PREFIXES}gnsstk${CMAKE_SHARED_LIBRARY_SUFFIX}) -if(NOT GNSSTK_INCLUDE_DIR) +if(NOT GNSSTK_INCLUDE_DIR_FOUND) find_path(GNSSTK_INCLUDE_DIR gpstk/Rinex3ObsBase.hpp PATHS ${GNSSTK_ROOT_USER_DEFINED}/include /usr/include /usr/local/include /opt/local/include ) - if(GNSSTK_INCLUDE_DIR) + if(GNSSTK_INCLUDE_DIR_FOUND) set(GNSSTK_NAMES gpstk ${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_SHARED_LIBRARY_SUFFIX}) set(GNSSTK_USES_GPSTK_NAMESPACE TRUE) + set(GNSSTK_OLDER_THAN_8 TRUE) + #set(GNSSTK_OLDER_THAN_9 TRUE) endif() endif() @@ -64,12 +66,7 @@ find_library(GNSSTK_LIBRARY NAMES ${GNSSTK_NAMES} /opt/local/lib ) -# handle the QUIET and REQUIRED arguments and set GNSSTK_FOUND to TRUE if -# all listed variables are TRUE -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GNSSTK DEFAULT_MSG GNSSTK_LIBRARY GNSSTK_INCLUDE_DIR) - -if(GNSSTK_FOUND) +if(GNSSTK_LIBRARY AND GNSSTK_INCLUDE_DIR) set(OLD_PACKAGE_VERSION ${PACKAGE_VERSION}) unset(PACKAGE_VERSION) if(EXISTS ${CMAKE_INSTALL_FULL_DATADIR}/cmake/GNSSTK/GNSSTKConfigVersion.cmake) @@ -85,6 +82,17 @@ if(GNSSTK_FOUND) set(PACKAGE_VERSION ${OLD_PACKAGE_VERSION}) endif() +if(GNSSTK_VERSION) + if(GNSSTK_VERSION VERSION_GREATER ${GNSSSDR_GNSSTK_LOCAL_VERSION}) + unset(GNSSTK_LIBRARY CACHE) + unset(GNSSTK_INCLUDE_DIR CACHE) + endif() +endif() +# handle the QUIET and REQUIRED arguments and set GNSSTK_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GNSSTK DEFAULT_MSG GNSSTK_LIBRARY GNSSTK_INCLUDE_DIR) + if(GNSSTK_FOUND AND GNSSTK_VERSION) set_package_properties(GNSSTK PROPERTIES DESCRIPTION "The GNSSTk C++ Library (found: v${GNSSTK_VERSION})" @@ -123,4 +131,9 @@ if(GNSSTK_FOUND AND NOT ENABLE_OWN_GNSSTK AND NOT TARGET Gnsstk::gnsstk) endif() endif() -mark_as_advanced(GNSSTK_LIBRARY GNSSTK_INCLUDE_DIR GNSSTK_USES_GPSTK_NAMESPACE GNSSTK_OLDER_THAN_8) +mark_as_advanced(GNSSTK_LIBRARY + GNSSTK_INCLUDE_DIR + GNSSTK_USES_GPSTK_NAMESPACE + GNSSTK_OLDER_THAN_8 + GNSSTK_OLDER_THAN_9 +) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 9c0e34762..cc4ec78a8 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -355,7 +355,7 @@ if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA) include(GNUInstallDirs) find_program(Patch_EXECUTABLE NAME patch PATHS ENV PATH) if(NOT Patch_EXECUTABLE) - message(FATAL_ERROR "The patch command is not found. It is required to build GPSTk. Please check your OS documentation and install the patch command.") + message(FATAL_ERROR "The patch command is not found. It is required to build GNSSTk. Please check your OS documentation and install the patch command.") endif() set(GNSSTK_PATCH_COMMAND cd ${CMAKE_BINARY_DIR}/thirdparty/gnsstk-${GNSSSDR_GNSSTK_LOCAL_VERSION} && diff --git a/src/utils/rinex-tools/CMakeLists.txt b/src/utils/rinex-tools/CMakeLists.txt index 0071bf3dc..46c90bd6f 100644 --- a/src/utils/rinex-tools/CMakeLists.txt +++ b/src/utils/rinex-tools/CMakeLists.txt @@ -11,11 +11,11 @@ if("${ARMADILLO_VERSION_STRING}" VERSION_GREATER "9.800" OR (NOT ARMADILLO_FOUND if(NOT GNSSTK_FOUND OR ENABLE_OWN_GNSSTK) include(GNUInstallDirs) if(GNSSTK_USES_GPSTK_NAMESPACE) - set(GNSSTK_LIBRARY ${CMAKE_BINARY_DIR}/gnsstk-${GNSSSDR_GNSSTK_LOCAL_VERSION}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gnsstk${CMAKE_STATIC_LIBRARY_SUFFIX}) + set(GNSSTK_LIBRARY ${CMAKE_BINARY_DIR}/gnsstk-${GNSSSDR_GNSSTK_LOCAL_VERSION}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_STATIC_LIBRARY_SUFFIX}) set(GNSSTK_INCLUDE_DIR ${CMAKE_BINARY_DIR}/gnsstk-${GNSSSDR_GNSSTK_LOCAL_VERSION}/install/include) else() - set(GNSSTK_LIBRARY ${CMAKE_BINARY_DIR}/gpstk-${GNSSSDR_GNSSTK_LOCAL_VERSION}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gnsstk${CMAKE_STATIC_LIBRARY_SUFFIX}) - set(GNSSTK_INCLUDE_DIR ${CMAKE_BINARY_DIR}/gpstk-${GNSSSDR_GNSSTK_LOCAL_VERSION}/install/include) + set(GNSSTK_LIBRARY ${CMAKE_BINARY_DIR}/gnsstk-${GNSSSDR_GNSSTK_LOCAL_VERSION}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gnsstk${CMAKE_STATIC_LIBRARY_SUFFIX}) + set(GNSSTK_INCLUDE_DIR ${CMAKE_BINARY_DIR}/gnsstk-${GNSSSDR_GNSSTK_LOCAL_VERSION}/install/include) endif() endif() @@ -60,12 +60,14 @@ if("${ARMADILLO_VERSION_STRING}" VERSION_GREATER "9.800" OR (NOT ARMADILLO_FOUND add_dependencies(obsdiff matio-${GNSSSDR_MATIO_LOCAL_VERSION}) endif() if(GNSSTK_USES_GPSTK_NAMESPACE) - target_compile_definitions(obsdiff PUBLIC -DGNSSTK_USES_GPSTK_NAMESPACE=1) + target_compile_definitions(obsdiff PRIVATE -DGNSSTK_USES_GPSTK_NAMESPACE=1) endif() if(GNSSTK_OLDER_THAN_8) - target_compile_definitions(obsdiff PUBLIC -DOLD_GPSTK=1) + target_compile_definitions(obsdiff PRIVATE -DOLD_GPSTK=1) + endif() + if(GNSSTK_OLDER_THAN_9) + target_compile_definitions(obsdiff PRIVATE -DGNSSTK_OLDER_THAN_9=1) endif() - if(NOT TARGET Gnsstk::gnsstk) if(GNSSTK_USES_GPSTK_NAMESPACE) file(MAKE_DIRECTORY ${GNSSTK_INCLUDE_DIR}/gpstk) diff --git a/src/utils/rinex-tools/obsdiff.cc b/src/utils/rinex-tools/obsdiff.cc index c44817551..f24a6c4cf 100644 --- a/src/utils/rinex-tools/obsdiff.cc +++ b/src/utils/rinex-tools/obsdiff.cc @@ -131,25 +131,25 @@ std::map ReadRinexObs(const std::string& rinex_file, char system { case 'G': #if OLD_GPSTK - prn.system = gpstk::SatID::systemGPS; + prn.system = gnsstk::SatID::systemGPS; #else - prn.system = gpstk::SatelliteSystem::GPS; + prn.system = gnsstk::SatelliteSystem::GPS; #endif PRN_set = available_gps_prn; break; case 'E': #if OLD_GPSTK - prn.system = gpstk::SatID::systemGalileo; + prn.system = gnsstk::SatID::systemGalileo; #else - prn.system = gpstk::SatelliteSystem::Galileo; + prn.system = gnsstk::SatelliteSystem::Galileo; #endif PRN_set = available_galileo_prn; break; default: #if OLD_GPSTK - prn.system = gpstk::SatID::systemGPS; + prn.system = gnsstk::SatID::systemGPS; #else - prn.system = gpstk::SatelliteSystem::GPS; + prn.system = gnsstk::SatelliteSystem::GPS; #endif PRN_set = available_gps_prn; } @@ -1273,7 +1273,7 @@ double compute_rx_clock_error(const std::string& rinex_nav_filename, const std:: #if OLD_GPSTK std::vector Syss; #endif - gpstk::Matrix invMC; + gnsstk::Matrix invMC; int iret; // Call RAIMCompute #if OLD_GPSTK diff --git a/src/utils/rinex2assist/CMakeLists.txt b/src/utils/rinex2assist/CMakeLists.txt index d788109c7..d53df14df 100644 --- a/src/utils/rinex2assist/CMakeLists.txt +++ b/src/utils/rinex2assist/CMakeLists.txt @@ -17,7 +17,6 @@ if(NOT GNSSTK_FOUND OR ENABLE_OWN_GNSSTK) endif() endif() - find_package(Boost COMPONENTS iostreams serialization QUIET) if(CMAKE_VERSION VERSION_LESS 3.5) if(NOT TARGET Boost::iostreams) @@ -40,7 +39,6 @@ if(CMAKE_VERSION VERSION_LESS 3.5) endif() endif() - find_program(UNCOMPRESS_EXECUTABLE uncompress PATHS /bin /usr/bin @@ -70,7 +68,7 @@ if(Boost_FOUND) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") target_compile_options(rinex2assist PRIVATE - -Wno-deprecated -Wno-unused-parameter -Wno-sign-compare + -Wno-deprecated -Wno-unused-parameter -Wno-sign-compare -Wno-switch -Wno-inconsistent-missing-override ) endif() @@ -100,7 +98,7 @@ if(Boost_FOUND) endif() if(GNSSTK_VERSION) if(GNSSTK_VERSION VERSION_LESS "9.0.0") - target_compile_definitions(rinex2assist PUBLIC -DGNSSTK_OLDER_THAN_9=1) + target_compile_definitions(rinex2assist PRIVATE -DGNSSTK_OLDER_THAN_9=1) endif() endif()