From 4c68fe6e6e408a2feebbc90cad77c90f4f116c14 Mon Sep 17 00:00:00 2001 From: Mabel Zhang Date: Sat, 30 Apr 2022 02:06:11 -0400 Subject: [PATCH 01/14] bash completion for flags Signed-off-by: Mabel Zhang --- src/cmd/gui.bash_completion.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/cmd/gui.bash_completion.sh diff --git a/src/cmd/gui.bash_completion.sh b/src/cmd/gui.bash_completion.sh new file mode 100644 index 000000000..c3a8e4ee6 --- /dev/null +++ b/src/cmd/gui.bash_completion.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# bash tab-completion + +# This is a per-library function definition, used in conjunction with the +# top-level entry point in ign-tools. + +function _ign_gui +{ + if [[ ${COMP_WORDS[COMP_CWORD]} == -* ]]; then + # Specify options (-*) word list for this subcommand + COMPREPLY=($(compgen -W " + -l --list + -s --standalone + -c --config + -v --verbose + -h --help + --force-version + --versions + " -- "${COMP_WORDS[COMP_CWORD]}" )) + return + else + # Just use bash default auto-complete, because we never have two + # subcommands in the same line. If that is ever needed, change here to + # detect subsequent subcommands + COMPREPLY=($(compgen -o default -- "${COMP_WORDS[COMP_CWORD]}")) + return + fi +} From 26449001a58abd51aad7521eddf8465693dd9780 Mon Sep 17 00:00:00 2001 From: Mabel Zhang Date: Sat, 30 Apr 2022 02:47:26 -0400 Subject: [PATCH 02/14] rename functions ign->gz Signed-off-by: Mabel Zhang --- src/cmd/gui.bash_completion.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/gui.bash_completion.sh b/src/cmd/gui.bash_completion.sh index c3a8e4ee6..71fff20fb 100644 --- a/src/cmd/gui.bash_completion.sh +++ b/src/cmd/gui.bash_completion.sh @@ -5,7 +5,7 @@ # This is a per-library function definition, used in conjunction with the # top-level entry point in ign-tools. -function _ign_gui +function _gz_gui { if [[ ${COMP_WORDS[COMP_CWORD]} == -* ]]; then # Specify options (-*) word list for this subcommand From 8c634be8c7775b73d39a38d9457cb5d262aca90d Mon Sep 17 00:00:00 2001 From: Mabel Zhang Date: Tue, 3 May 2022 04:17:52 -0400 Subject: [PATCH 03/14] add installation Signed-off-by: Mabel Zhang --- src/cmd/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt index 45245a12e..b0fb603a9 100644 --- a/src/cmd/CMakeLists.txt +++ b/src/cmd/CMakeLists.txt @@ -1,4 +1,4 @@ -# Generate a the ruby script. +# Generate the ruby script. # Note that the major version of the library is included in the name. if (APPLE) set(IGN_LIBRARY_NAME lib${PROJECT_NAME_LOWER}.dylib) @@ -11,3 +11,6 @@ configure_file( # Install the ruby command line library in an unversioned location. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmdgui${PROJECT_VERSION_MAJOR}.rb DESTINATION lib/ruby/ignition) + +# Install the bash completion script in an unversioned location. +install(FILES gui.bash_completion.sh DESTINATION share/ignition/ignition.completion.d) From 5e1edfc10a39fef5105a98a86f87a7632c9f6d70 Mon Sep 17 00:00:00 2001 From: Mabel Zhang Date: Tue, 10 May 2022 23:39:25 -0400 Subject: [PATCH 04/14] ign->gz Signed-off-by: Mabel Zhang --- src/cmd/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt index b0fb603a9..06903c9e2 100644 --- a/src/cmd/CMakeLists.txt +++ b/src/cmd/CMakeLists.txt @@ -13,4 +13,4 @@ configure_file( install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmdgui${PROJECT_VERSION_MAJOR}.rb DESTINATION lib/ruby/ignition) # Install the bash completion script in an unversioned location. -install(FILES gui.bash_completion.sh DESTINATION share/ignition/ignition.completion.d) +install(FILES gui.bash_completion.sh DESTINATION share/gz/gz.completion.d) From 15e2f53b5734ed976ee228e09f768c34f96083c1 Mon Sep 17 00:00:00 2001 From: Mabel Zhang Date: Thu, 12 May 2022 04:11:59 -0400 Subject: [PATCH 05/14] add test Signed-off-by: Mabel Zhang --- src/CMakeLists.txt | 7 +++++++ src/ign_TEST.cc | 31 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 61f278399..e62c1b562 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -46,7 +46,14 @@ ign_build_tests(TYPE UNIT LIB_DEPS ${IGNITION-MATH_LIBRARIES} TINYXML2::TINYXML2 + TEST_LIST + gtest_targets ) +foreach(test ${gtest_targets}) + target_compile_definitions(${test} PRIVATE + "IGN_GUI_SOURCE_DIR=\"${PROJECT_SOURCE_DIR}\"") +endforeach() + add_subdirectory(cmd) add_subdirectory(plugins) diff --git a/src/ign_TEST.cc b/src/ign_TEST.cc index cf3ba5ea7..1f02739a6 100644 --- a/src/ign_TEST.cc +++ b/src/ign_TEST.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -96,3 +97,33 @@ TEST_F(CmdLine, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(list)) EXPECT_TRUE(common::exists(common::joinPaths(this->kFakeHome, ".ignition", "gui"))); } + +////////////////////////////////////////////////// +/// \brief Check --help message and bash completion script for consistent flags +TEST(ignTest, GuiHelpVsCompletionFlags) +{ + // Flags in help message + std::string output = custom_exec_str("ign gui --help"); + EXPECT_NE(std::string::npos, output.find("--list")) << output; + EXPECT_NE(std::string::npos, output.find("--standalone")) << output; + EXPECT_NE(std::string::npos, output.find("--config")) << output; + EXPECT_NE(std::string::npos, output.find("--verbose")) << output; + EXPECT_NE(std::string::npos, output.find("--help")) << output; + EXPECT_NE(std::string::npos, output.find("--force-version")) << output; + EXPECT_NE(std::string::npos, output.find("--versions")) << output; + + // Flags in bash completion + std::string scriptPath = common::joinPaths(std::string(IGN_GUI_SOURCE_DIR), + "src", "cmd", "gui.bash_completion.sh"); + std::ifstream scriptFile(scriptPath); + std::string script((std::istreambuf_iterator(scriptFile)), + std::istreambuf_iterator()); + + EXPECT_NE(std::string::npos, script.find("--list")) << script; + EXPECT_NE(std::string::npos, script.find("--standalone")) << script; + EXPECT_NE(std::string::npos, script.find("--config")) << script; + EXPECT_NE(std::string::npos, script.find("--verbose")) << script; + EXPECT_NE(std::string::npos, script.find("--help")) << script; + EXPECT_NE(std::string::npos, script.find("--force-version")) << script; + EXPECT_NE(std::string::npos, script.find("--versions")) << script; +} From 3aeac4721f0b11b53635f00a7eb83663fb5f8523 Mon Sep 17 00:00:00 2001 From: Mabel Zhang Date: Thu, 19 May 2022 22:08:18 -0400 Subject: [PATCH 06/14] install to versioned place Signed-off-by: Mabel Zhang --- CMakeLists.txt | 3 +++ src/cmd/CMakeLists.txt | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c76b84f8..2c4c9f8bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,9 @@ set(IGN_MSGS_VER ${ignition-msgs5_VERSION_MAJOR}) #-------------------------------------- # Find if ign command is available find_program(HAVE_IGN_TOOLS ign) +if (HAVE_IGN_TOOLS) + set(IGN_TOOLS_VER 1) +endif() #-------------------------------------- # Find QT diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt index 06903c9e2..e3c4cc97a 100644 --- a/src/cmd/CMakeLists.txt +++ b/src/cmd/CMakeLists.txt @@ -12,5 +12,14 @@ configure_file( # Install the ruby command line library in an unversioned location. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmdgui${PROJECT_VERSION_MAJOR}.rb DESTINATION lib/ruby/ignition) -# Install the bash completion script in an unversioned location. -install(FILES gui.bash_completion.sh DESTINATION share/gz/gz.completion.d) +# Tack version onto and install the bash completion script +configure_file( + "gui.bash_completion.sh" + "${CMAKE_CURRENT_BINARY_DIR}/gui${PROJECT_VERSION_MAJOR}.bash_completion.sh" @ONLY) +if (HAVE_IGN_TOOLS) + install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/gui${PROJECT_VERSION_MAJOR}.bash_completion.sh + DESTINATION + ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/gz/gz${IGN_TOOLS_VER}.completion.d) +endif() From 5944868b75ffc0bf9f6dbeae5a129925778873d3 Mon Sep 17 00:00:00 2001 From: Mabel Zhang Date: Fri, 3 Jun 2022 00:36:05 -0400 Subject: [PATCH 07/14] license; var name Signed-off-by: Mabel Zhang --- src/CMakeLists.txt | 2 +- src/cmd/gui.bash_completion.sh | 15 +++++++++++++++ src/ign_TEST.cc | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e62c1b562..b67d08630 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -52,7 +52,7 @@ ign_build_tests(TYPE UNIT foreach(test ${gtest_targets}) target_compile_definitions(${test} PRIVATE - "IGN_GUI_SOURCE_DIR=\"${PROJECT_SOURCE_DIR}\"") + "GZ_GUI_SOURCE_DIR=\"${PROJECT_SOURCE_DIR}\"") endforeach() add_subdirectory(cmd) diff --git a/src/cmd/gui.bash_completion.sh b/src/cmd/gui.bash_completion.sh index 71fff20fb..3b7604e5a 100644 --- a/src/cmd/gui.bash_completion.sh +++ b/src/cmd/gui.bash_completion.sh @@ -1,4 +1,19 @@ #!/usr/bin/env bash +# +# Copyright (C) 2022 Open Source Robotics Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # bash tab-completion diff --git a/src/ign_TEST.cc b/src/ign_TEST.cc index 1f02739a6..197d6c1b1 100644 --- a/src/ign_TEST.cc +++ b/src/ign_TEST.cc @@ -113,7 +113,7 @@ TEST(ignTest, GuiHelpVsCompletionFlags) EXPECT_NE(std::string::npos, output.find("--versions")) << output; // Flags in bash completion - std::string scriptPath = common::joinPaths(std::string(IGN_GUI_SOURCE_DIR), + std::string scriptPath = common::joinPaths(std::string(GZ_GUI_SOURCE_DIR), "src", "cmd", "gui.bash_completion.sh"); std::ifstream scriptFile(scriptPath); std::string script((std::istreambuf_iterator(scriptFile)), From 4318a7788e1f3e7c01670a67cf9c6741da439964 Mon Sep 17 00:00:00 2001 From: Mabel Zhang Date: Fri, 3 Jun 2022 04:21:26 -0400 Subject: [PATCH 08/14] change var name to align with existing test Signed-off-by: Mabel Zhang --- src/CMakeLists.txt | 2 +- src/ign_TEST.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b67d08630..cc8c32b64 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -52,7 +52,7 @@ ign_build_tests(TYPE UNIT foreach(test ${gtest_targets}) target_compile_definitions(${test} PRIVATE - "GZ_GUI_SOURCE_DIR=\"${PROJECT_SOURCE_DIR}\"") + "PROJECT_SOURCE_DIR=\"${PROJECT_SOURCE_DIR}\"") endforeach() add_subdirectory(cmd) diff --git a/src/ign_TEST.cc b/src/ign_TEST.cc index 197d6c1b1..d3d49f8f2 100644 --- a/src/ign_TEST.cc +++ b/src/ign_TEST.cc @@ -113,7 +113,7 @@ TEST(ignTest, GuiHelpVsCompletionFlags) EXPECT_NE(std::string::npos, output.find("--versions")) << output; // Flags in bash completion - std::string scriptPath = common::joinPaths(std::string(GZ_GUI_SOURCE_DIR), + std::string scriptPath = common::joinPaths(std::string(PROJECT_SOURCE_DIR), "src", "cmd", "gui.bash_completion.sh"); std::ifstream scriptFile(scriptPath); std::string script((std::istreambuf_iterator(scriptFile)), From 6f7291bf3b06f9c71f5aa3eff7fc3c919b69209d Mon Sep 17 00:00:00 2001 From: Mabel Zhang Date: Tue, 7 Jun 2022 02:44:28 -0400 Subject: [PATCH 09/14] do not hard code flags in test Signed-off-by: Mabel Zhang --- src/cmd/gui.bash_completion.sh | 28 +++++++++++++++------- src/ign_TEST.cc | 43 +++++++++++++++++----------------- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/src/cmd/gui.bash_completion.sh b/src/cmd/gui.bash_completion.sh index 3b7604e5a..69b68b24d 100644 --- a/src/cmd/gui.bash_completion.sh +++ b/src/cmd/gui.bash_completion.sh @@ -20,19 +20,22 @@ # This is a per-library function definition, used in conjunction with the # top-level entry point in ign-tools. +GZ_GUI_COMPLETION_LIST=" + -l --list + -s --standalone + -c --config + -v --verbose + -h --help + --force-version + --versions +" + function _gz_gui { if [[ ${COMP_WORDS[COMP_CWORD]} == -* ]]; then # Specify options (-*) word list for this subcommand - COMPREPLY=($(compgen -W " - -l --list - -s --standalone - -c --config - -v --verbose - -h --help - --force-version - --versions - " -- "${COMP_WORDS[COMP_CWORD]}" )) + COMPREPLY=($(compgen -W "$GZ_GUI_COMPLETION_LIST" \ + -- "${COMP_WORDS[COMP_CWORD]}" )) return else # Just use bash default auto-complete, because we never have two @@ -42,3 +45,10 @@ function _gz_gui return fi } + +function _gz_gui_flags +{ + for word in $GZ_GUI_COMPLETION_LIST; do + echo "$word" + done +} diff --git a/src/ign_TEST.cc b/src/ign_TEST.cc index d3d49f8f2..d65745988 100644 --- a/src/ign_TEST.cc +++ b/src/ign_TEST.cc @@ -103,27 +103,28 @@ TEST_F(CmdLine, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(list)) TEST(ignTest, GuiHelpVsCompletionFlags) { // Flags in help message - std::string output = custom_exec_str("ign gui --help"); - EXPECT_NE(std::string::npos, output.find("--list")) << output; - EXPECT_NE(std::string::npos, output.find("--standalone")) << output; - EXPECT_NE(std::string::npos, output.find("--config")) << output; - EXPECT_NE(std::string::npos, output.find("--verbose")) << output; - EXPECT_NE(std::string::npos, output.find("--help")) << output; - EXPECT_NE(std::string::npos, output.find("--force-version")) << output; - EXPECT_NE(std::string::npos, output.find("--versions")) << output; - - // Flags in bash completion + std::string helpOutput = custom_exec_str("ign gui --help"); + + // Call the output function in the bash completion script std::string scriptPath = common::joinPaths(std::string(PROJECT_SOURCE_DIR), "src", "cmd", "gui.bash_completion.sh"); - std::ifstream scriptFile(scriptPath); - std::string script((std::istreambuf_iterator(scriptFile)), - std::istreambuf_iterator()); - - EXPECT_NE(std::string::npos, script.find("--list")) << script; - EXPECT_NE(std::string::npos, script.find("--standalone")) << script; - EXPECT_NE(std::string::npos, script.find("--config")) << script; - EXPECT_NE(std::string::npos, script.find("--verbose")) << script; - EXPECT_NE(std::string::npos, script.find("--help")) << script; - EXPECT_NE(std::string::npos, script.find("--force-version")) << script; - EXPECT_NE(std::string::npos, script.find("--versions")) << script; + + // Equivalent to: + // sh -c "bash -c \". /path/to/gui.bash_completion.sh; _gz_gui_flags\"" + std::string cmd = "bash -c \". " + scriptPath + "; _gz_gui_flags\""; + std::cout << "Running command [" << cmd << "]" << std::endl; + std::string scriptOutput = custom_exec_str(cmd); + + // Tokenize script output + std::istringstream iss(scriptOutput); + std::vector flags((std::istream_iterator(iss)), + std::istream_iterator()); + + EXPECT_GT(flags.size(), 0u); + + // Match each flag in script output with help message + for (std::string flag : flags) + { + EXPECT_NE(std::string::npos, helpOutput.find(flag)) << helpOutput; + } } From f3e255066ca0f1c90b9521bc53d85d163c3e0a3c Mon Sep 17 00:00:00 2001 From: Mabel Zhang Date: Tue, 7 Jun 2022 03:10:16 -0400 Subject: [PATCH 10/14] do not print Signed-off-by: Mabel Zhang --- src/ign_TEST.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ign_TEST.cc b/src/ign_TEST.cc index d65745988..9aabd62b1 100644 --- a/src/ign_TEST.cc +++ b/src/ign_TEST.cc @@ -112,7 +112,6 @@ TEST(ignTest, GuiHelpVsCompletionFlags) // Equivalent to: // sh -c "bash -c \". /path/to/gui.bash_completion.sh; _gz_gui_flags\"" std::string cmd = "bash -c \". " + scriptPath + "; _gz_gui_flags\""; - std::cout << "Running command [" << cmd << "]" << std::endl; std::string scriptOutput = custom_exec_str(cmd); // Tokenize script output From e7211eba4d1ba99d90d29a83063bec0d273c8be6 Mon Sep 17 00:00:00 2001 From: Mabel Zhang Date: Tue, 7 Jun 2022 18:40:01 -0400 Subject: [PATCH 11/14] add env var for apple Signed-off-by: Mabel Zhang --- src/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cc8c32b64..fdda31eaa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,5 +55,13 @@ foreach(test ${gtest_targets}) "PROJECT_SOURCE_DIR=\"${PROJECT_SOURCE_DIR}\"") endforeach() +if(TARGET UNIT_ign_TEST) + set(_env_vars) + list(APPEND _env_vars "IGN_CONFIG_PATH=${CMAKE_BINARY_DIR}/test/conf/$") + + set_tests_properties(UNIT_ign_TEST PROPERTIES + ENVIRONMENT "${_env_vars}") +endif() + add_subdirectory(cmd) add_subdirectory(plugins) From bab25418c44d2c447ef61ae99144fdeb93e4e5aa Mon Sep 17 00:00:00 2001 From: Mabel Zhang Date: Tue, 7 Jun 2022 21:10:50 -0400 Subject: [PATCH 12/14] add env vars for apple Signed-off-by: Mabel Zhang --- CMakeLists.txt | 8 +++++--- src/CMakeLists.txt | 15 ++++++++++++++- src/ign_TEST.cc | 5 ++++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c4c9f8bc..68152d8c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,9 +69,11 @@ set(IGN_MSGS_VER ${ignition-msgs5_VERSION_MAJOR}) #-------------------------------------- # Find if ign command is available -find_program(HAVE_IGN_TOOLS ign) -if (HAVE_IGN_TOOLS) - set(IGN_TOOLS_VER 1) + +ign_find_package(ignition-tools QUIET) +if (ignition-tools_FOUND) + set (HAVE_IGN_TOOLS TRUE) + set (IGN_TOOLS_VER 1) endif() #-------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fdda31eaa..ae08332a8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -56,8 +56,21 @@ foreach(test ${gtest_targets}) endforeach() if(TARGET UNIT_ign_TEST) + # Running `ign gazebo` on macOS has problems when run with /usr/bin/ruby + # due to System Integrity Protection (SIP). Try to find ruby from + # homebrew as a workaround. + if (APPLE) + find_program(BREW_RUBY ruby HINTS /usr/local/opt/ruby/bin) + endif() + + target_compile_definitions(UNIT_ign_TEST PRIVATE + "BREW_RUBY=\"${BREW_RUBY} \"") + + target_compile_definitions(UNIT_ign_TEST PRIVATE + "IGN_PATH=\"${IGNITION-TOOLS_BINARY_DIRS}\"") + set(_env_vars) - list(APPEND _env_vars "IGN_CONFIG_PATH=${CMAKE_BINARY_DIR}/test/conf/$") + list(APPEND _env_vars "IGN_CONFIG_PATH=${CMAKE_BINARY_DIR}/test/conf") set_tests_properties(UNIT_ign_TEST PROPERTIES ENVIRONMENT "${_env_vars}") diff --git a/src/ign_TEST.cc b/src/ign_TEST.cc index 9aabd62b1..51859225c 100644 --- a/src/ign_TEST.cc +++ b/src/ign_TEST.cc @@ -33,6 +33,9 @@ # define pclose _pclose #endif +static const std::string kIgnCommand( + std::string(BREW_RUBY) + std::string(IGN_PATH) + "/ign "); + ///////////////////////////////////////////////// std::string custom_exec_str(std::string _cmd) { @@ -103,7 +106,7 @@ TEST_F(CmdLine, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(list)) TEST(ignTest, GuiHelpVsCompletionFlags) { // Flags in help message - std::string helpOutput = custom_exec_str("ign gui --help"); + std::string helpOutput = custom_exec_str(kIgnCommand + " gui --help"); // Call the output function in the bash completion script std::string scriptPath = common::joinPaths(std::string(PROJECT_SOURCE_DIR), From fe2be11e57bf2c3cc2b838f9d5144167a43e3aef Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Tue, 14 Jun 2022 15:18:44 -0700 Subject: [PATCH 13/14] Restore logic introduced in PR 240 Signed-off-by: Louise Poubel --- CMakeLists.txt | 12 +++++------- src/cmd/CMakeLists.txt | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68152d8c4..046d1bc55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,13 +68,11 @@ ign_find_package(ignition-msgs5 REQUIRED) set(IGN_MSGS_VER ${ignition-msgs5_VERSION_MAJOR}) #-------------------------------------- -# Find if ign command is available - -ign_find_package(ignition-tools QUIET) -if (ignition-tools_FOUND) - set (HAVE_IGN_TOOLS TRUE) - set (IGN_TOOLS_VER 1) -endif() +# Find if command is available. This is used to enable tests. +# Note that CLI files are installed regardless of whether the dependency is +# available during build time +find_program(HAVE_IGN_TOOLS ign) +set (IGN_TOOLS_VER 1) #-------------------------------------- # Find QT diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt index e3c4cc97a..25e6c9d58 100644 --- a/src/cmd/CMakeLists.txt +++ b/src/cmd/CMakeLists.txt @@ -16,10 +16,8 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmdgui${PROJECT_VERSION_MAJOR}.rb DEST configure_file( "gui.bash_completion.sh" "${CMAKE_CURRENT_BINARY_DIR}/gui${PROJECT_VERSION_MAJOR}.bash_completion.sh" @ONLY) -if (HAVE_IGN_TOOLS) - install( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/gui${PROJECT_VERSION_MAJOR}.bash_completion.sh - DESTINATION - ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/gz/gz${IGN_TOOLS_VER}.completion.d) -endif() +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/gui${PROJECT_VERSION_MAJOR}.bash_completion.sh + DESTINATION + ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/gz/gz${IGN_TOOLS_VER}.completion.d) From 2866b7a9ea535d8b6dafd854d0a58827df0a5776 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Tue, 14 Jun 2022 15:46:53 -0700 Subject: [PATCH 14/14] Fix tests Signed-off-by: Louise Poubel --- src/CMakeLists.txt | 2 +- src/ign_TEST.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ae08332a8..2d1176c6e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -67,7 +67,7 @@ if(TARGET UNIT_ign_TEST) "BREW_RUBY=\"${BREW_RUBY} \"") target_compile_definitions(UNIT_ign_TEST PRIVATE - "IGN_PATH=\"${IGNITION-TOOLS_BINARY_DIRS}\"") + "IGN_PATH=\"${HAVE_IGN_TOOLS}\"") set(_env_vars) list(APPEND _env_vars "IGN_CONFIG_PATH=${CMAKE_BINARY_DIR}/test/conf") diff --git a/src/ign_TEST.cc b/src/ign_TEST.cc index bf2ca3426..5954542e2 100644 --- a/src/ign_TEST.cc +++ b/src/ign_TEST.cc @@ -34,7 +34,7 @@ #endif static const std::string kIgnCommand( - std::string(BREW_RUBY) + std::string(IGN_PATH) + "/ign "); + std::string(BREW_RUBY) + std::string(IGN_PATH)); ///////////////////////////////////////////////// std::string custom_exec_str(std::string _cmd)