CMakeLists.txt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. #
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. #
  8. # Currently we are in the Code folder: ${CMAKE_CURRENT_LIST_DIR}
  9. # Get the platform specific folder ${pal_dir} for the current folder: ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}
  10. # Note: o3de_pal_dir will take care of the details for us, as this may be a restricted platform
  11. # in which case it will see if that platform is present here or in the restricted folder.
  12. # i.e. It could here in our gem : Gems/ROS2RobotImporter/Code/Platform/<platorm_name> or
  13. # <restricted_folder>/<platform_name>/Gems/ROS2RobotImporter/Code
  14. o3de_pal_dir(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME} "${gem_restricted_path}" "${gem_path}" "${gem_parent_relative_path}")
  15. # Now that we have the platform abstraction layer (PAL) folder for this folder, thats where we will find the
  16. # traits for this platform. Traits for a platform are defines for things like whether or not something in this gem
  17. # is supported by this platform.
  18. include(${pal_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
  19. # Check to see if building the Gem Modules are supported for the current platform
  20. if(NOT PAL_TRAIT_ROS2ROBOTIMPORTER_SUPPORTED)
  21. return()
  22. endif()
  23. # The ${gem_name}.API target declares the common interface that users of this gem should depend on in their targets
  24. ly_add_target(
  25. NAME ${gem_name}.API INTERFACE
  26. NAMESPACE Gem
  27. FILES_CMAKE
  28. ros2robotimporter_api_files.cmake
  29. ${pal_dir}/ros2robotimporter_api_files.cmake
  30. INCLUDE_DIRECTORIES
  31. INTERFACE
  32. Include
  33. BUILD_DEPENDENCIES
  34. INTERFACE
  35. AZ::AzCore
  36. )
  37. # The ${gem_name}.Private.Object target is an internal target
  38. # It should not be used outside of this Gems CMakeLists.txt
  39. ly_add_target(
  40. NAME ${gem_name}.Private.Object STATIC
  41. NAMESPACE Gem
  42. FILES_CMAKE
  43. ros2robotimporter_private_files.cmake
  44. ${pal_dir}/ros2robotimporter_private_files.cmake
  45. TARGET_PROPERTIES
  46. O3DE_PRIVATE_TARGET TRUE
  47. INCLUDE_DIRECTORIES
  48. PRIVATE
  49. Include
  50. Source
  51. BUILD_DEPENDENCIES
  52. PUBLIC
  53. AZ::AzCore
  54. AZ::AzFramework
  55. Gem::ROS2.Static
  56. Gem::ROS2Sensors.Lidar.Static
  57. )
  58. # Here add ${gem_name} target, it depends on the Private Object library and Public API interface
  59. ly_add_target(
  60. NAME ${gem_name} ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
  61. NAMESPACE Gem
  62. FILES_CMAKE
  63. ros2robotimporter_shared_files.cmake
  64. ${pal_dir}/ros2robotimporter_shared_files.cmake
  65. INCLUDE_DIRECTORIES
  66. PUBLIC
  67. Include
  68. PRIVATE
  69. Source
  70. BUILD_DEPENDENCIES
  71. PUBLIC
  72. Gem::${gem_name}.API
  73. PRIVATE
  74. Gem::${gem_name}.Private.Object
  75. )
  76. # Include the gem name into the Client Module source file
  77. # for use with the AZ_DECLARE_MODULE_CLASS macro
  78. # This is to allow renaming of the gem to also cause
  79. # the CreateModuleClass_Gem_<gem-name> function which
  80. # is used to bootstrap the gem in monolithic builds to link to the new gem name
  81. ly_add_source_properties(
  82. SOURCES
  83. Source/Clients/ROS2RobotImporterModule.cpp
  84. PROPERTY COMPILE_DEFINITIONS
  85. VALUES
  86. O3DE_GEM_NAME=${gem_name}
  87. O3DE_GEM_VERSION=${gem_version})
  88. # By default, we will specify that the above target ${gem_name} would be used by
  89. # Client and Server type targets when this gem is enabled. If you don't want it
  90. # active in Clients or Servers by default, delete one of both of the following lines:
  91. ly_create_alias(NAME ${gem_name}.Clients NAMESPACE Gem TARGETS Gem::${gem_name})
  92. ly_create_alias(NAME ${gem_name}.Servers NAMESPACE Gem TARGETS Gem::${gem_name})
  93. ly_create_alias(NAME ${gem_name}.Unified NAMESPACE Gem TARGETS Gem::${gem_name})
  94. # For the Client and Server variants of ${gem_name} Gem, an alias to the ${gem_name}.API target will be made
  95. ly_create_alias(NAME ${gem_name}.Clients.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
  96. ly_create_alias(NAME ${gem_name}.Servers.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
  97. ly_create_alias(NAME ${gem_name}.Unified.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
  98. # Add in CMake dependencies for each gem dependency listed in this gem's gem.json file
  99. # for the Clients, Servers, Unified gem variants
  100. o3de_add_variant_dependencies_for_gem_dependencies(GEM_NAME ${gem_name} VARIANTS Clients Servers Unified)
  101. # If we are on a host platform, we want to add the host tools targets like the ${gem_name}.Editor MODULE target
  102. if(PAL_TRAIT_BUILD_HOST_TOOLS)
  103. # The ${gem_name}.Editor.API target can be used by other gems that want to interact with the ${gem_name}.Editor module
  104. ly_add_target(
  105. NAME ${gem_name}.Editor.API INTERFACE
  106. NAMESPACE Gem
  107. FILES_CMAKE
  108. ros2robotimporter_editor_api_files.cmake
  109. ${pal_dir}/ros2robotimporter_editor_api_files.cmake
  110. INCLUDE_DIRECTORIES
  111. INTERFACE
  112. Include
  113. BUILD_DEPENDENCIES
  114. INTERFACE
  115. AZ::AzToolsFramework
  116. )
  117. # The ${gem_name}.Editor.Private.Object target is an internal target
  118. # which is only to be used by this gems CMakeLists.txt and any subdirectories
  119. # Other gems should not use this target
  120. ly_add_target(
  121. NAME ${gem_name}.Editor.Private.Object STATIC
  122. NAMESPACE Gem
  123. AUTOMOC
  124. AUTORCC
  125. FILES_CMAKE
  126. ros2robotimporter_editor_private_files.cmake
  127. TARGET_PROPERTIES
  128. O3DE_PRIVATE_TARGET TRUE
  129. INCLUDE_DIRECTORIES
  130. PRIVATE
  131. Include
  132. Source
  133. BUILD_DEPENDENCIES
  134. PUBLIC
  135. AZ::AzToolsFramework
  136. Gem::CommonFeaturesAtom.Editor.Static
  137. Gem::PhysX5.Editor.Static
  138. Gem::ROS2.Static
  139. Gem::ROS2.Editor.Static
  140. Gem::ROS2Sensors.Editor.API
  141. Gem::ROS2Controllers.API
  142. Gem::ROS2Controllers.Editor.API
  143. ${gem_name}.Private.Object
  144. PRIVATE
  145. AZ::AssetBuilderSDK
  146. 3rdParty::sdformat
  147. )
  148. ly_add_target(
  149. NAME ${gem_name}.Editor GEM_MODULE
  150. NAMESPACE Gem
  151. AUTOMOC
  152. FILES_CMAKE
  153. ros2robotimporter_editor_shared_files.cmake
  154. INCLUDE_DIRECTORIES
  155. PRIVATE
  156. Source
  157. PUBLIC
  158. Include
  159. BUILD_DEPENDENCIES
  160. PUBLIC
  161. Gem::${gem_name}.Editor.API
  162. PRIVATE
  163. Gem::${gem_name}.Editor.Private.Object
  164. )
  165. # Include the gem name into the Editor Module source file
  166. # for use with the AZ_DECLARE_MODULE_CLASS macro
  167. # This is to allow renaming of the gem to also cause
  168. # the CreateModuleClass_Gem_<gem-name> function which
  169. # is used to bootstrap the gem in monolithic builds to link to the new gem name
  170. ly_add_source_properties(
  171. SOURCES
  172. Source/Tools/ROS2RobotImporterEditorModule.cpp
  173. PROPERTY COMPILE_DEFINITIONS
  174. VALUES
  175. O3DE_GEM_NAME=${gem_name}
  176. O3DE_GEM_VERSION=${gem_version})
  177. # By default, we will specify that the above target ${gem_name} would be used by
  178. # Tool and Builder type targets when this gem is enabled. If you don't want it
  179. # active in Tools or Builders by default, delete one of both of the following lines:
  180. ly_create_alias(NAME ${gem_name}.Tools NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
  181. ly_create_alias(NAME ${gem_name}.Builders NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
  182. # For the Tools and Builders variants of ${gem_name} Gem, an alias to the ${gem_name}.Editor API target will be made
  183. ly_create_alias(NAME ${gem_name}.Tools.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
  184. ly_create_alias(NAME ${gem_name}.Builders.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
  185. # Add in CMake dependencies for each gem dependency listed in this gem's gem.json file
  186. # for the Tools and Builders gem variants
  187. o3de_add_variant_dependencies_for_gem_dependencies(GEM_NAME ${gem_name} VARIANTS Tools Builders)
  188. endif()
  189. ################################################################################
  190. # Tests
  191. ################################################################################
  192. # See if globally, tests are supported
  193. if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
  194. # We globally support tests, see if we support tests on this platform for ${gem_name}.Tests
  195. if(PAL_TRAIT_ROS2ROBOTIMPORTER_TEST_SUPPORTED)
  196. # We support ${gem_name}.Tests on this platform, add dependency on the Private Object target
  197. ly_add_target(
  198. NAME ${gem_name}.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
  199. NAMESPACE Gem
  200. FILES_CMAKE
  201. ros2robotimporter_tests_files.cmake
  202. INCLUDE_DIRECTORIES
  203. PRIVATE
  204. Tests
  205. Source
  206. Include
  207. BUILD_DEPENDENCIES
  208. PRIVATE
  209. AZ::AzTest
  210. AZ::AzFramework
  211. Gem::${gem_name}.Private.Object
  212. )
  213. # Add ${gem_name}.Tests to googletest
  214. ly_add_googletest(
  215. NAME Gem::${gem_name}.Tests
  216. )
  217. endif()
  218. # If we are a host platform we want to add tools test like editor tests here
  219. if(PAL_TRAIT_BUILD_HOST_TOOLS)
  220. # We are a host platform, see if Editor tests are supported on this platform
  221. if(PAL_TRAIT_ROS2ROBOTIMPORTER_EDITOR_TEST_SUPPORTED)
  222. # We support ${gem_name}.Editor.Tests on this platform, add ${gem_name}.Editor.Tests target which depends on
  223. # private ${gem_name}.Editor.Private.Object target
  224. ly_add_target(
  225. NAME ${gem_name}.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
  226. NAMESPACE Gem
  227. FILES_CMAKE
  228. ros2robotimporter_editor_tests_files.cmake
  229. INCLUDE_DIRECTORIES
  230. PRIVATE
  231. Tests
  232. Source
  233. Include
  234. BUILD_DEPENDENCIES
  235. PRIVATE
  236. AZ::AzTest
  237. AZ::AzTestShared
  238. AZ::AzToolsFramework
  239. Gem::${gem_name}.Editor.Private.Object
  240. 3rdParty::sdformat
  241. )
  242. # Add ${gem_name}.Editor.Tests to googletest
  243. ly_add_googletest(
  244. NAME Gem::${gem_name}.Editor.Tests
  245. )
  246. endif()
  247. endif()
  248. endif()