################################################################################
# doctor-ros overlay for aws_robomaker_hospital_world (replaces upstream CMakeLists.txt)
#
# Differences from upstream commit 7161eb8448f5cba6a469da7a79ae5d660b0b7f58:
#  - no find_package(gazebo_ros): Gazebo Classic is not used on Jazzy
#  - no configure-time "pip install -r requirements.txt": the Fuel models are
#    fetched with fetch_fuel_models.py, which needs only the Python standard library
#  - an ament environment hook appends the model directories to GZ_SIM_RESOURCE_PATH
################################################################################
cmake_minimum_required(VERSION 3.5)
project(aws_robomaker_hospital_world)

find_package(ament_cmake REQUIRED)

# Fuel models used by the world (same list as upstream, owner OpenRobotics).
set(FUEL_MODELS
  XRayMachine IVStand BloodPressureMonitor BPCart BMWCart CGMClassic StorageRack Chair
  InstrumentCart1 Scrubs PatientWheelChair WhiteChipChair TrolleyBed SurgicalTrolley
  PotatoChipChair VisitorKidSit FemaleVisitorSit AdjTable MopCart3 MaleVisitorSit Drawer
  OfficeChairBlack ElderLadyPatient ElderMalePatient InstrumentCart2 MetalCabinet BedTable
  BedsideTable AnesthesiaMachine TrolleyBedPatient Shower SurgicalTrolleyMed
  StorageRackCovered KitchenSink Toilet VendingMachine ParkingTrolleyMin PatientFSit
  MaleVisitorOnPhone FemaleVisitor MalePatientBed StorageRackCoverOpen ParkingTrolleyMax
)

find_package(Python3 REQUIRED COMPONENTS Interpreter)
execute_process(
  COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/fetch_fuel_models.py
          --destination ${CMAKE_CURRENT_SOURCE_DIR}/fuel_models ${FUEL_MODELS}
  RESULT_VARIABLE FUEL_RESULT
  ERROR_VARIABLE FUEL_ERROR
)
if(NOT FUEL_RESULT EQUAL 0)
  message(FATAL_ERROR "Fuel model download failed: ${FUEL_ERROR}")
endif()

install(DIRECTORY launch models fuel_models worlds
  DESTINATION share/${PROJECT_NAME}
)

# Appends <prefix>/share/aws_robomaker_hospital_world/{models,fuel_models} to GZ_SIM_RESOURCE_PATH.
ament_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/hooks/gz_resource_path.sh.in")

ament_package()
