CMakeLists.txt 10 KB

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