Skip to content

Commit b31a820

Browse files
traversaroiche033
authored andcommitted
Fix relocatibility of gz-sim-main executable (#3105)
Signed-off-by: Silvio Traversaro <[email protected]>
1 parent 3842d98 commit b31a820

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/cmd/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ if(ENABLE_GUI)
7272
target_compile_definitions(${sim_executable} PRIVATE WITH_GUI)
7373
target_compile_definitions(${sim_executable}
7474
PRIVATE
75-
"GZ_SIM_GUI_EXE=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBEXECDIR}/gz/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}/$<TARGET_FILE_NAME:${gui_executable}>\""
75+
"GZ_SIM_GUI_EXE_RELATIVE_PATH=\"${CMAKE_INSTALL_LIBEXECDIR}/gz/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}/$<TARGET_FILE_NAME:${gui_executable}>\""
7676
)
7777
endif()
7878

src/cmd/sim_main.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <gz/utils/Subprocess.hh>
3232

3333
#include "gz/sim/config.hh"
34+
#include "gz/sim/InstallationDirectories.hh"
3435
#include "gz/sim/Server.hh"
3536
#include "gz/sim/ServerConfig.hh"
3637
#include "gz.hh"
@@ -495,7 +496,10 @@ int main(int argc, char** argv)
495496
utils::setenv(
496497
std::string("GZ_SIM_WAIT_GUI"),
497498
std::to_string(opt->waitGui));
498-
launchProcess(std::string(GZ_SIM_GUI_EXE), createGuiCommand(opt));
499+
std::string gz_sim_gui_exe = gz::common::joinPaths(
500+
sim::getInstallPrefix(),
501+
GZ_SIM_GUI_EXE_RELATIVE_PATH);
502+
launchProcess(gz_sim_gui_exe, createGuiCommand(opt));
499503
}
500504
catch (const std::exception &e)
501505
{
@@ -578,7 +582,10 @@ int main(int argc, char** argv)
578582
else if(opt->launchGui)
579583
{
580584
#ifdef WITH_GUI
581-
launchProcess(std::string(GZ_SIM_GUI_EXE), createGuiCommand(opt));
585+
std::string gz_sim_gui_exe = gz::common::joinPaths(
586+
sim::getInstallPrefix(),
587+
GZ_SIM_GUI_EXE_RELATIVE_PATH);
588+
launchProcess(gz_sim_gui_exe, createGuiCommand(opt));
582589
#else
583590
std::cerr << "This version of Gazebo does not support GUI" << std::endl;
584591
#endif

0 commit comments

Comments
 (0)