CMakeLists.txt 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. # Copyright (c) Contributors to the Open 3D Engine Project.
  2. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  3. #
  4. # SPDX-License-Identifier: Apache-2.0 OR MIT
  5. # Only allow this gem to be configured on platforms that are currently supported
  6. include(${CMAKE_CURRENT_SOURCE_DIR}/Platform/${PAL_PLATFORM_NAME}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
  7. if(NOT PAL_TRAIT_BUILD_ROS2_GEM_SUPPORTED)
  8. message(FATAL_ERROR "The ROS2 Gem is not currently supported on ${PAL_PLATFORM_NAME}")
  9. return()
  10. endif()
  11. # If no ROS2 is found, no targets are valid for this Gem
  12. find_package(ROS2 MODULE)
  13. if (NOT ROS2_FOUND)
  14. message(FATAL_ERROR "Unable to detect a the ROS2 distribution on this system. Make sure it is installed and enabled.")
  15. return()
  16. endif()
  17. # Add the ROS2.Static target
  18. # Note: We include the common files and the platform specific files which are set in ros2_common_files.cmake
  19. # and in ${pal_dir}/ros2_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
  20. ly_add_target(
  21. NAME ${gem_name}.Static STATIC
  22. NAMESPACE Gem
  23. FILES_CMAKE
  24. ros2_header_files.cmake
  25. ros2_files.cmake
  26. INCLUDE_DIRECTORIES
  27. PUBLIC
  28. Include
  29. PRIVATE
  30. Source
  31. BUILD_DEPENDENCIES
  32. PUBLIC
  33. AZ::AzCore
  34. AZ::AzFramework
  35. Gem::Atom_RPI.Public
  36. Gem::Atom_Feature_Common.Static
  37. Gem::Atom_Component_DebugCamera.Static
  38. Gem::StartingPointInput
  39. )
  40. target_depends_on_ros2_packages(${gem_name}.Static rclcpp builtin_interfaces std_msgs sensor_msgs nav_msgs urdfdom tf2_ros ackermann_msgs gazebo_msgs control_toolbox)
  41. ly_add_target(
  42. NAME ${gem_name}.API HEADERONLY
  43. NAMESPACE Gem
  44. FILES_CMAKE
  45. ros2_header_files.cmake
  46. INCLUDE_DIRECTORIES
  47. INTERFACE
  48. Include
  49. )
  50. # Here add ROS2 target, it depends on the ROS2.Static
  51. ly_add_target(
  52. NAME ${gem_name} ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
  53. NAMESPACE Gem
  54. FILES_CMAKE
  55. ros2_shared_files.cmake
  56. INCLUDE_DIRECTORIES
  57. PUBLIC
  58. Include
  59. PRIVATE
  60. Source
  61. BUILD_DEPENDENCIES
  62. PRIVATE
  63. Gem::${gem_name}.Static
  64. Gem::Atom_Feature_Common.Static
  65. )
  66. # By default, we will specify that the above target ROS2 would be used by
  67. # Client and Server type targets when this gem is enabled. If you don't want it
  68. # active in Clients or Servers by default, delete one of both of the following lines:
  69. ly_create_alias(NAME ${gem_name}.Clients NAMESPACE Gem TARGETS Gem::${gem_name})
  70. ly_create_alias(NAME ${gem_name}.Servers NAMESPACE Gem TARGETS Gem::${gem_name})
  71. # If we are on a host platform, we want to add the host tools targets like the ${gem_name}.Editor target which
  72. # will also depend on ${gem_name}.Static
  73. if(PAL_TRAIT_BUILD_HOST_TOOLS)
  74. ly_add_target(
  75. NAME ${gem_name}.Editor.Static STATIC
  76. NAMESPACE Gem
  77. FILES_CMAKE
  78. ros2_editor_files.cmake
  79. PLATFORM_INCLUDE_FILES
  80. ${CMAKE_CURRENT_LIST_DIR}/Platform/Common/${PAL_TRAIT_COMPILER_ID}/ros2_static_editor_${PAL_TRAIT_COMPILER_ID_LOWERCASE}.cmake
  81. INCLUDE_DIRECTORIES
  82. PRIVATE
  83. Source
  84. PUBLIC
  85. Include
  86. COMPILE_DEFINITIONS
  87. PRIVATE
  88. ROS2_EDITOR
  89. BUILD_DEPENDENCIES
  90. PUBLIC
  91. AZ::AzToolsFramework
  92. Gem::AtomLyIntegration_CommonFeatures.Editor.Static
  93. Gem::LmbrCentral.API
  94. Gem::PhysX.Editor.Static
  95. Gem::${gem_name}.Static
  96. )
  97. ly_add_target(
  98. NAME ${gem_name}.Editor GEM_MODULE
  99. NAMESPACE Gem
  100. AUTOMOC
  101. AUTORCC
  102. FILES_CMAKE
  103. ros2_editor_files.cmake
  104. ros2_editor_shared_files.cmake
  105. PLATFORM_INCLUDE_FILES
  106. ${CMAKE_CURRENT_LIST_DIR}/Platform/Common/${PAL_TRAIT_COMPILER_ID}/ros2_static_editor_${PAL_TRAIT_COMPILER_ID_LOWERCASE}.cmake
  107. COMPILE_DEFINITIONS
  108. PRIVATE
  109. ROS2_EDITOR
  110. INCLUDE_DIRECTORIES
  111. PRIVATE
  112. Source
  113. PUBLIC
  114. Include
  115. BUILD_DEPENDENCIES
  116. PUBLIC
  117. Gem::${gem_name}.Editor.Static
  118. Gem::Atom_Feature_Common.Static
  119. )
  120. # By default, we will specify that the above target ROS2 would be used by
  121. # Tool and Builder type targets when this gem is enabled. If you don't want it
  122. # active in Tools or Builders by default, delete one of both of the following lines:
  123. ly_create_alias(NAME ${gem_name}.Tools NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
  124. ly_create_alias(NAME ${gem_name}.Builders NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
  125. endif()
  126. ################################################################################
  127. # Tests
  128. ################################################################################
  129. # See if globally, tests are supported
  130. if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
  131. if(PAL_TRAIT_TEST_GOOGLE_TEST_SUPPORTED)
  132. # We support ROS2.Tests on this platform, add ROS2.Tests target which depends on ROS2.Static
  133. ly_add_target(
  134. NAME ${gem_name}.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
  135. NAMESPACE Gem
  136. FILES_CMAKE
  137. ros2_tests_files.cmake
  138. INCLUDE_DIRECTORIES
  139. PRIVATE
  140. Tests
  141. Source
  142. BUILD_DEPENDENCIES
  143. PRIVATE
  144. AZ::AzTest
  145. Gem::${gem_name}.Static
  146. )
  147. # Add ROS2.Tests to googletest
  148. ly_add_googletest(
  149. NAME Gem::${gem_name}.Tests
  150. )
  151. endif()
  152. # If we are a host platform we want to add tools test like editor tests here
  153. if(PAL_TRAIT_BUILD_HOST_TOOLS)
  154. if(PAL_TRAIT_TEST_GOOGLE_TEST_SUPPORTED)
  155. # We support ROS2.Editor.Tests on this platform, add ROS2.Editor.Tests target which depends on ROS2.Editor
  156. ly_add_target(
  157. NAME ${gem_name}.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
  158. NAMESPACE Gem
  159. FILES_CMAKE
  160. ros2_editor_tests_files.cmake
  161. PLATFORM_INCLUDE_FILES
  162. ${CMAKE_CURRENT_LIST_DIR}/Platform/Common/${PAL_TRAIT_COMPILER_ID}/ros2_static_editor_${PAL_TRAIT_COMPILER_ID_LOWERCASE}.cmake
  163. INCLUDE_DIRECTORIES
  164. PRIVATE
  165. Tests
  166. Source
  167. BUILD_DEPENDENCIES
  168. PRIVATE
  169. AZ::AzTest
  170. Gem::${gem_name}.Editor
  171. )
  172. # Add ROS2.Editor.Tests to googletest
  173. ly_add_googletest(
  174. NAME Gem::${gem_name}.Editor.Tests
  175. )
  176. endif()
  177. endif()
  178. endif()