Skip to content
Closed
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9a66c8f
Moved sim cli source files into cmd
sauk2 Mar 4, 2025
e22f98b
Added sim executable
sauk2 Mar 4, 2025
7f505c4
Added validation checks for network flags
sauk2 Mar 5, 2025
cd1dab5
Merge branch 'gz-sim9' into sim-standalone-exe
sauk2 Mar 5, 2025
9962bed
Added command to run server without gui
sauk2 Mar 8, 2025
13cef03
Added command to run gui and server+gui
sauk2 Mar 9, 2025
87f72ba
Changed return type for function to get directory
sauk2 Mar 9, 2025
d1040b3
Merge branch 'gz-sim9' into sim-standalone-exe
sauk2 Mar 9, 2025
cd4715c
Added functions to check and parse SDF
sauk2 Mar 11, 2025
c0dcc98
Updated executable with SDF parsing and added render options
sauk2 Mar 11, 2025
2014f4c
Replaced library with standalone executable in ruby script and update…
sauk2 Mar 11, 2025
678491d
Fix styling
sauk2 Mar 11, 2025
03459d3
Removed includes to fix error
sauk2 Mar 11, 2025
f57e0cd
Added server and gui executables
sauk2 Mar 17, 2025
4013fb6
Calling server and gui executables as subprocesses from main
sauk2 Mar 17, 2025
b9896e1
Removed test subprocess implementestion
sauk2 Mar 26, 2025
564fec9
Removed server exe and moved all implementation to main executable
sauk2 Mar 26, 2025
f085785
Merge branch 'gz-sim9' into sim-standalone-exe
sauk2 Mar 26, 2025
d151512
Testing windows process launch
sauk2 Mar 31, 2025
ab6354b
Merge branch 'gz-sim9' into sim-standalone-exe
sauk2 Mar 31, 2025
f7b3791
Merge branch 'gz-sim9' into sim-standalone-exe
j-rivero Apr 2, 2025
c8d3d8c
Launching non-blocking server directly from main exe
sauk2 Apr 4, 2025
bd5f506
Added conditions to build executable with GUI
sauk2 Apr 5, 2025
0136419
Attempt to remove gui dependency from gz-sim
sauk2 Apr 5, 2025
bca5c37
Added new CI job to build sim without gui
sauk2 Apr 5, 2025
df22d5e
Merge branch 'gz-sim9' into sim-standalone-exe
j-rivero Apr 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ set(gui_sources
PARENT_SCOPE
)

set(cli_sources
gz.cc
)

set(material_sources
rendering/MaterialParser/MaterialParser.cc
rendering/MaterialParser/ConfigLoader.cc
Expand Down Expand Up @@ -158,26 +154,9 @@ if (MSVC)
# members that don't get exported, so they trigger this warning. However, the
# warning is not important since those members do not need to be interfaced
# with.
set_source_files_properties(${sources} ${gtest_sources} ${cli_sources} COMPILE_FLAGS "/wd4251 /wd4146")
set_source_files_properties(${sources} ${gtest_sources} COMPILE_FLAGS "/wd4251 /wd4146")
endif()

# CLI
gz_add_component(gz
SOURCES
${cli_sources}
GET_TARGET_NAME gz_lib_target)
target_link_libraries(${gz_lib_target}
PUBLIC
${PROJECT_LIBRARY_TARGET_NAME}
gz-common${GZ_COMMON_VER}::gz-common${GZ_COMMON_VER}
gz-sim${PROJECT_VERSION_MAJOR}
gz-sim${PROJECT_VERSION_MAJOR}-gui
)

# Executable target that runs the GUI without ruby for debugging purposes.
add_executable(runGui cmd/runGui_main.cc)
target_link_libraries(runGui PRIVATE ${gz_lib_target})

# Create the library target
gz_create_core_library(SOURCES ${sources} CXX_STANDARD 17)
gz_add_get_install_prefix_impl(GET_INSTALL_PREFIX_FUNCTION gz::sim::getInstallPrefix
Expand Down
224 changes: 109 additions & 115 deletions src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,39 @@ target_link_libraries(${model_executable}

install(
TARGETS ${model_executable}
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/gz/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}/)
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/gz/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}/
)

# Create sim executable
add_library(gz STATIC gz.cc)
target_link_libraries(gz
${PROJECT_LIBRARY_TARGET_NAME}
gz-common${GZ_COMMON_VER}::gz-common${GZ_COMMON_VER}
gz-utils${GZ_UTILS_VER}::cli
gz-sim${PROJECT_VERSION_MAJOR}
gz-sim${PROJECT_VERSION_MAJOR}-gui
)

add_executable(gz-sim-gui gui_main.cc)
target_link_libraries(gz-sim-gui gz)

set(sim_executable gz-sim-main)
add_executable(${sim_executable} sim_main.cc)
target_link_libraries(${sim_executable} PUBLIC gz)

install(
TARGETS ${sim_executable} gz-sim-gui
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/gz/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}/
)

target_compile_definitions(gz-sim-main
PRIVATE
"GZ_SIM_MAIN_EXE=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBEXECDIR}/gz/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}/$<TARGET_FILE_NAME:gz-sim-main>\""
"GZ_SIM_GUI_EXE=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBEXECDIR}/gz/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}/$<TARGET_FILE_NAME:gz-sim-gui>\""
)

# Build the unit tests.
set(test_sources)
set(test_sources gz_TEST.cc)

# Add systems that need a valid display here.
# \todo(anyone) Find a way to run these tests with a virtual display such Xvfb
Expand All @@ -23,13 +52,6 @@ else()
"Skipping ModelCommandAPI tests because a valid display was not found")
endif()

# gz_TEST is not supported with multi config
# CMake generators, see also cmd/CMakeLists.txt
get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT GENERATOR_IS_MULTI_CONFIG)
list(APPEND test_sources gz_TEST.cc)
endif()

# Build unit tests if Gazebo tools is installed
if(BUILD_TESTING AND GZ_TOOLS_PROGRAM)
gz_build_tests(TYPE UNIT
Expand Down Expand Up @@ -62,31 +84,8 @@ foreach(CMD_TEST
"GZ_PATH=\"${GZ_TOOLS_PROGRAM}\""
)

if(${CMD_TEST} STREQUAL UNIT_ModelCommandAPI_TEST)
set_tests_properties(${CMD_TEST} PROPERTIES
ENVIRONMENT "GZ_CONFIG_PATH=${CMAKE_BINARY_DIR}/test/conf/$<CONFIG>")
endif()

if(${CMD_TEST} STREQUAL UNIT_gz_TEST)
# Running `gz sim` 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(${CMD_TEST}
PRIVATE
"BREW_RUBY=\"${BREW_RUBY} \""
)

set(_env_vars)
list(APPEND _env_vars "GZ_CONFIG_PATH=${CMAKE_BINARY_DIR}/test/conf")
list(APPEND _env_vars "GZ_SIM_SYSTEM_PLUGIN_PATH=$<TARGET_FILE_DIR:TestModelSystem>")

set_tests_properties(${CMD_TEST} PROPERTIES
ENVIRONMENT "${_env_vars}")
endif()
set_tests_properties(${CMD_TEST} PROPERTIES
ENVIRONMENT "GZ_CONFIG_PATH=${CMAKE_BINARY_DIR}/test/conf/$<CONFIG>")

# On Windows there is no RPATH, so an alternative way for tests for finding .dll libraries
# in build directory in necessary. For regular tests, the trick is to place all libraries
Expand All @@ -100,87 +99,6 @@ foreach(CMD_TEST
endif()
endforeach()

#===============================================================================
# Generate the ruby script.
# Note that the major version of the library is included in the name.
# Ex: cmdsim0.rb
set(cmd_script_name "cmd${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_generated "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>_${cmd_script_name}")
set(cmd_script_configured "${CMAKE_CURRENT_BINARY_DIR}/${cmd_script_name}.configured")

# Set the library_location variable to the relative path to the library file
# within the install directory structure.
if(WIN32)
set(plugin_location ${CMAKE_INSTALL_BINDIR})
else()
set(plugin_location ${CMAKE_INSTALL_LIBDIR})
endif()

set(library_location "../../../${plugin_location}/$<TARGET_FILE_NAME:${gz_lib_target}>")

configure_file(
"cmd${GZ_DESIGNATION}.rb.in"
"${cmd_script_configured}"
@ONLY)

file(GENERATE
OUTPUT "${cmd_script_generated}"
INPUT "${cmd_script_configured}")

# Install the ruby command line library in an unversioned location.
install(FILES ${cmd_script_generated} DESTINATION lib/ruby/gz RENAME ${cmd_script_name})

set(gz_library_path "${CMAKE_INSTALL_PREFIX}/lib/ruby/gz/cmd${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}")

# Generate a configuration file.
# Note that the major version of the library is included in the name.
# Ex: sim0.yaml
configure_file(
"${GZ_DESIGNATION}.yaml.in"
"${CMAKE_CURRENT_BINARY_DIR}/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml" @ONLY)

# Install the yaml configuration files in an unversioned location.
install( FILES
${CMAKE_CURRENT_BINARY_DIR}/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml
DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/gz/)

#===============================================================================
# Generate the ruby script for internal testing.
# Note that the major version of the library is included in the name.
# Ex: cmdsim0.rb
# The logic is valid only for single-config CMake generators, so no script is
# generated if a multiple-config CMake geneator is used
get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT GENERATOR_IS_MULTI_CONFIG)
set(cmd_script_generated_test "${CMAKE_BINARY_DIR}/test/lib/ruby/gz/cmd${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_configured_test "${cmd_script_generated_test}.configured")

# Set the library_location variable to the relative path to the library file
# within the install directory structure.
set(library_location "$<TARGET_FILE:${gz_lib_target}>")

configure_file(
"cmd${GZ_DESIGNATION}.rb.in"
"${cmd_script_configured_test}"
@ONLY)

file(GENERATE
OUTPUT "${cmd_script_generated_test}"
INPUT "${cmd_script_configured_test}")

# Used only for internal testing.
set(gz_library_path
"${CMAKE_BINARY_DIR}/test/lib/ruby/gz/cmd${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}")

# Generate a configuration file for internal testing.
# Note that the major version of the library is included in the name.
# Ex: sim0.yaml
configure_file(
"${GZ_DESIGNATION}.yaml.in"
"${CMAKE_BINARY_DIR}/test/conf/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml" @ONLY)
endif()

#===============================================================================
# Generate the ruby script for internal testing of model command.
# Note that the major version of the library is included in the name.
Expand Down Expand Up @@ -220,6 +138,46 @@ file(GENERATE
INPUT "${CMAKE_CURRENT_BINARY_DIR}/model${PROJECT_VERSION_MAJOR}.yaml.configured"
)

#===============================================================================
# Generate the ruby script for internal testing of sim command.
# Note that the major version of the library is included in the name.
# Ex: cmdsim0.rb
set(gz_sim_ruby_path
"${CMAKE_BINARY_DIR}/test/lib/$<CONFIG>/ruby/gz/cmdsim${PROJECT_VERSION_MAJOR}")
set(cmd_sim_script_generated_test "${gz_sim_ruby_path}.rb")
set(cmd_sim_script_configured_test
"${CMAKE_CURRENT_BINARY_DIR}/test_cmdsim${PROJECT_VERSION_MAJOR}.rb.configured")

# Set the library_location variable to the full path of the library file within
# the build directory.
set(sim_exe_location "$<TARGET_FILE:${sim_executable}>")

configure_file(
"cmdsim.rb.in"
"${cmd_sim_script_configured_test}"
@ONLY
)

file(GENERATE
OUTPUT "${cmd_sim_script_generated_test}"
INPUT "${cmd_sim_script_configured_test}"
)

# Generate a configuration file for internal testing.
# Note that the major version of the library is included in the name.
# Ex: sim0.yaml
configure_file(
"sim.yaml.in"
"${CMAKE_CURRENT_BINARY_DIR}/sim${PROJECT_VERSION_MAJOR}.yaml.configured"
@ONLY
)

file(GENERATE
OUTPUT "${CMAKE_BINARY_DIR}/test/conf/$<CONFIG>/sim${PROJECT_VERSION_MAJOR}.yaml"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/sim${PROJECT_VERSION_MAJOR}.yaml.configured"
)


#===============================================================================
# Used for the installed model command version.
# Generate the ruby script that gets installed.
Expand Down Expand Up @@ -256,6 +214,42 @@ configure_file(

install(FILES ${model_configured} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gz/)

#===============================================================================
# Used for the installed sim command version.
# Generate the ruby script that gets installed.
# Note that the major version of the library is included in the name.
# Ex: cmdsim0.rb
set(cmd_sim_script_generated "${CMAKE_CURRENT_BINARY_DIR}/cmdsim${PROJECT_VERSION_MAJOR}.rb")
set(cmd_sim_script_configured "${cmd_sim_script_generated}.configured")

# Set the library_location variable to the relative path to the library file
# within the install directory structure.
set(sim_exe_location "../../../${CMAKE_INSTALL_LIBEXECDIR}/gz/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}/$<TARGET_FILE_NAME:${sim_executable}>")

configure_file(
"cmdsim.rb.in"
"${cmd_sim_script_configured}"
@ONLY
)

file(GENERATE
OUTPUT "${cmd_sim_script_generated}"
INPUT "${cmd_sim_script_configured}"
)
# Install the ruby command line library in an unversioned location.
install(FILES ${cmd_sim_script_generated} DESTINATION lib/ruby/gz)

# Used for the installed version.
set(gz_sim_ruby_path "${CMAKE_INSTALL_PREFIX}/lib/ruby/gz/cmdsim${PROJECT_VERSION_MAJOR}")

set(sim_configured "${CMAKE_CURRENT_BINARY_DIR}/sim${PROJECT_VERSION_MAJOR}.yaml")
configure_file(
"sim.yaml.in"
${sim_configured}
@ONLY)

install(FILES ${sim_configured} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gz/)

#===============================================================================
# Bash completion

Expand Down
2 changes: 0 additions & 2 deletions src/cmd/ModelCommandAPI.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*
*/

#include "gz/sim/gz/Export.hh"

/// \brief External hook to get a list of available models.
void cmdModelList();

Expand Down
Loading