From d40e3427d423324f96d6f394698d62f3e63a08af Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 16 Sep 2024 18:13:12 +0200 Subject: [PATCH] Add install and uninstall targets to nav_msg_listener --- docs/CHANGELOG.md | 1 + src/utils/nav-listener/CMakeLists.txt | 16 +++++++++ src/utils/nav-listener/README.md | 12 +++++++ .../cmake/cmake_uninstall.cmake.in | 35 +++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 src/utils/nav-listener/cmake/cmake_uninstall.cmake.in diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 1f067e6d6..aa7bef842 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -85,6 +85,7 @@ All notable changes to GNSS-SDR will be documented in this file. ### Improvements in Usability: - Tidy up the `conf/` folder. +- Add `install` and `uninstall` targets to the `nav_msg_listener` utility. See the definitions of concepts and metrics at https://gnss-sdr.org/design-forces/ diff --git a/src/utils/nav-listener/CMakeLists.txt b/src/utils/nav-listener/CMakeLists.txt index cc86a7bf4..ea9c5d36e 100644 --- a/src/utils/nav-listener/CMakeLists.txt +++ b/src/utils/nav-listener/CMakeLists.txt @@ -39,3 +39,19 @@ target_include_directories(navmsg_lib add_executable(nav_msg_listener ${NAVLISTENER_SOURCE_DIR}/main.cc) target_link_libraries(nav_msg_listener PUBLIC navmsg_lib) + +install(TARGETS nav_msg_listener + RUNTIME DESTINATION bin + COMPONENT "nav_msg_listener" +) + +if(NOT TARGET uninstall) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY + ) + add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake + ) +endif() diff --git a/src/utils/nav-listener/README.md b/src/utils/nav-listener/README.md index 76b2aedaf..4bd90658e 100644 --- a/src/utils/nav-listener/README.md +++ b/src/utils/nav-listener/README.md @@ -27,6 +27,18 @@ $ cmake .. $ make ``` +Optionally, you can install it: + +``` +$ sudo make install +``` + +and uninstall it later with: + +``` +$ sudo make uninstall +``` + ## Usage In order to tell GNSS-SDR to generate those messages, you need to include the diff --git a/src/utils/nav-listener/cmake/cmake_uninstall.cmake.in b/src/utils/nav-listener/cmake/cmake_uninstall.cmake.in new file mode 100644 index 000000000..fc57491c4 --- /dev/null +++ b/src/utils/nav-listener/cmake/cmake_uninstall.cmake.in @@ -0,0 +1,35 @@ +# 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-License-Identifier: BSD-3-Clause + +if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") +endif() + +file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +foreach(file ${files}) + message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + if(CMAKE_VERSION VERSION_LESS 3.17) + execute_process( + COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}" + OUTPUT_VARIABLE rm_out + RESULT_VARIABLE rm_retval + ) + else() + execute_process( + COMMAND @CMAKE_COMMAND@ -E rm "$ENV{DESTDIR}${file}" + OUTPUT_VARIABLE rm_out + RESULT_VARIABLE rm_retval + ) + endif() + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + endif() + else() + message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") + endif() +endforeach()