CMakeLists.txt 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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. if(NOT PAL_TRAIT_BUILD_HOST_TOOLS)
  9. return()
  10. endif()
  11. # Builders need to be defined first because we collect the builders and pass them
  12. # to AssetBuilder and AssetProcessor so it loads them.
  13. add_subdirectory(AssetBuilderSDK)
  14. add_subdirectory(AssetBuilder)
  15. ly_add_target(
  16. NAME AssetProcessor.Static STATIC
  17. NAMESPACE AZ
  18. AUTOMOC
  19. AUTORCC
  20. FILES_CMAKE
  21. assetprocessor_static_files.cmake
  22. Platform/${PAL_PLATFORM_NAME}/assetprocessor_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
  23. INCLUDE_DIRECTORIES
  24. PUBLIC
  25. .
  26. Platform/${PAL_PLATFORM_NAME}
  27. PRIVATE
  28. native
  29. BUILD_DEPENDENCIES
  30. PUBLIC
  31. 3rdParty::Qt::Core
  32. 3rdParty::Qt::Gui
  33. 3rdParty::Qt::Network
  34. 3rdParty::RapidJSON
  35. 3rdParty::SQLite
  36. 3rdParty::xxhash
  37. AZ::AzCore
  38. AZ::AzFramework
  39. AZ::AzQtComponents
  40. AZ::AzToolsFramework
  41. AZ::AssetBuilderSDK
  42. AZ::AssetBuilder.Static
  43. ${additional_dependencies}
  44. )
  45. # Aggregates all combined AssetBuilders into a single LY_ASSET_BUILDERS #define
  46. get_property(asset_builders GLOBAL PROPERTY LY_ASSET_BUILDERS)
  47. string (REPLACE ";" "," asset_builders "${asset_builders}")
  48. ly_add_source_properties(
  49. SOURCES native/utilities/ApplicationManager.cpp
  50. PROPERTY COMPILE_DEFINITIONS
  51. VALUES LY_ASSET_BUILDERS="${asset_builders}"
  52. )
  53. ly_add_target(
  54. NAME AssetProcessor APPLICATION
  55. NAMESPACE AZ
  56. AUTOMOC
  57. AUTOUIC
  58. AUTORCC
  59. FILES_CMAKE
  60. assetprocessor_gui_files.cmake
  61. Platform/${PAL_PLATFORM_NAME}/assetprocessor_gui_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
  62. PLATFORM_INCLUDE_FILES
  63. Platform/${PAL_PLATFORM_NAME}/assetprocessor_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
  64. INCLUDE_DIRECTORIES
  65. PUBLIC
  66. .
  67. PRIVATE
  68. native
  69. BUILD_DEPENDENCIES
  70. PRIVATE
  71. AZ::AssetProcessor.Static
  72. RUNTIME_DEPENDENCIES
  73. AZ::AssetBuilder
  74. )
  75. # Adds the AssetProcessor target as a C preprocessor define so that it can be used as a Settings Registry
  76. # specialization in order to look up the generated .setreg which contains the dependencies
  77. # specified for the target.
  78. if(TARGET AssetProcessor)
  79. ly_set_gem_variant_to_load(TARGETS AssetProcessor VARIANTS Builders)
  80. set_source_files_properties(
  81. native/AssetProcessorBuildTarget.cpp
  82. PROPERTIES
  83. COMPILE_DEFINITIONS
  84. LY_CMAKE_TARGET="AssetProcessor"
  85. )
  86. else()
  87. message(FATAL_ERROR "Cannot set LY_CMAKE_TARGET define to AssetProcessor as the target doesn't exist anymore."
  88. " Perhaps it has been renamed")
  89. endif()
  90. ly_add_target(
  91. NAME AssetProcessorBatch.Static STATIC
  92. NAMESPACE AZ
  93. AUTOMOC
  94. FILES_CMAKE
  95. assetprocessor_static_batch_files.cmake
  96. INCLUDE_DIRECTORIES
  97. PUBLIC
  98. .
  99. PRIVATE
  100. native
  101. BUILD_DEPENDENCIES
  102. PUBLIC
  103. AZ::AssetProcessor.Static
  104. )
  105. ly_add_target(
  106. NAME AssetProcessorBatch EXECUTABLE
  107. NAMESPACE AZ
  108. AUTOMOC
  109. FILES_CMAKE
  110. assetprocessor_batch_files.cmake
  111. INCLUDE_DIRECTORIES
  112. PRIVATE
  113. .
  114. native
  115. BUILD_DEPENDENCIES
  116. PRIVATE
  117. AZ::AssetProcessorBatch.Static
  118. RUNTIME_DEPENDENCIES
  119. AZ::AssetBuilder
  120. )
  121. if(LY_DEFAULT_PROJECT_PATH)
  122. set_property(TARGET AssetProcessor AssetProcessorBatch APPEND PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS "--project-path=\"${LY_DEFAULT_PROJECT_PATH}\"")
  123. endif()
  124. # Adds the AssetProcessorBatch target as a C preprocessor define so that it can be used as a Settings Registry
  125. # specialization in order to look up the generated .setreg which contains the dependencies
  126. # specified for the target.
  127. if(TARGET AssetProcessorBatch)
  128. ly_set_gem_variant_to_load(TARGETS AssetProcessorBatch VARIANTS Builders)
  129. set_source_files_properties(
  130. native/AssetProcessorBatchBuildTarget.cpp
  131. PROPERTIES
  132. COMPILE_DEFINITIONS
  133. LY_CMAKE_TARGET="AssetProcessorBatch"
  134. )
  135. else()
  136. message(FATAL_ERROR "Cannot set LY_CMAKE_TARGET define to AssetProcessorBatch as the target doesn't exist anymore."
  137. " Perhaps it has been renamed")
  138. endif()
  139. ################################################################################
  140. # Tests
  141. ################################################################################
  142. if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
  143. ly_add_target(
  144. NAME AssetProcessor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
  145. NAMESPACE AZ
  146. AUTOMOC
  147. AUTORCC
  148. FILES_CMAKE
  149. assetprocessor_test_files.cmake
  150. INCLUDE_DIRECTORIES
  151. PRIVATE
  152. native
  153. .
  154. BUILD_DEPENDENCIES
  155. PRIVATE
  156. AZ::AzTest
  157. AZ::AssetProcessorBatch.Static
  158. AZ::AzToolsFrameworkTestCommon
  159. )
  160. ly_add_source_properties(
  161. SOURCES native/tests/assetBuilderSDK/assetBuilderSDKTest.cpp
  162. PROPERTY COMPILE_DEFINITIONS
  163. VALUES ${LY_PAL_TOOLS_DEFINES}
  164. )
  165. ly_add_source_properties(
  166. SOURCES native/unittests/AssetProcessorManagerUnitTests.cpp
  167. PROPERTY COMPILE_DEFINITIONS
  168. VALUES LY_CMAKE_BINARY_DIR="${CMAKE_BINARY_DIR}"
  169. )
  170. ly_add_target_files(
  171. TARGETS
  172. AssetProcessor.Tests
  173. FILES
  174. ${CMAKE_CURRENT_SOURCE_DIR}/testdata/config_broken_badplatform/AssetProcessorPlatformConfig.setreg
  175. OUTPUT_SUBDIRECTORY
  176. testdata/config_broken_badplatform
  177. )
  178. ly_add_target_files(
  179. TARGETS
  180. AssetProcessor.Tests
  181. FILES
  182. ${CMAKE_CURRENT_SOURCE_DIR}/testdata/config_broken_noscans/AssetProcessorPlatformConfig.setreg
  183. OUTPUT_SUBDIRECTORY
  184. testdata/config_broken_noscans
  185. )
  186. ly_add_target_files(
  187. TARGETS
  188. AssetProcessor.Tests
  189. FILES
  190. ${CMAKE_CURRENT_SOURCE_DIR}/testdata/config_broken_recognizers/AssetProcessorPlatformConfig.setreg
  191. OUTPUT_SUBDIRECTORY
  192. testdata/config_broken_recognizers
  193. )
  194. ly_add_target_files(
  195. TARGETS
  196. AssetProcessor.Tests
  197. FILES
  198. ${CMAKE_CURRENT_SOURCE_DIR}/testdata/config_broken_noplatform/AssetProcessorPlatformConfig.setreg
  199. OUTPUT_SUBDIRECTORY
  200. testdata/config_broken_noplatform
  201. )
  202. ly_add_target_files(
  203. TARGETS
  204. AssetProcessor.Tests
  205. FILES
  206. ${CMAKE_CURRENT_SOURCE_DIR}/testdata/config_regular/AssetProcessorPlatformConfig.setreg
  207. OUTPUT_SUBDIRECTORY
  208. testdata/config_regular
  209. )
  210. ly_add_target_files(
  211. TARGETS
  212. AssetProcessor.Tests
  213. FILES
  214. ${CMAKE_CURRENT_SOURCE_DIR}/testdata/config_regular_platform_scanfolder/AssetProcessorPlatformConfig.setreg
  215. OUTPUT_SUBDIRECTORY
  216. testdata/config_regular_platform_scanfolder
  217. )
  218. ly_add_target_files(
  219. TARGETS
  220. AssetProcessor.Tests
  221. FILES
  222. ${CMAKE_CURRENT_SOURCE_DIR}/testdata/EmptyDummyProject/AssetProcessorGamePlatformConfig.setreg
  223. OUTPUT_SUBDIRECTORY
  224. testdata/EmptyDummyProject
  225. )
  226. ly_add_target_files(
  227. TARGETS
  228. AssetProcessor.Tests
  229. FILES
  230. ${CMAKE_CURRENT_SOURCE_DIR}/testdata/DummyProject/AssetProcessorGamePlatformConfig.setreg
  231. OUTPUT_SUBDIRECTORY
  232. testdata/DummyProject
  233. )
  234. ly_add_target_files(
  235. TARGETS
  236. AssetProcessor.Tests
  237. FILES
  238. ${CMAKE_CURRENT_SOURCE_DIR}/testdata/config_metadata/AssetProcessorPlatformConfig.setreg
  239. OUTPUT_SUBDIRECTORY
  240. testdata/config_metadata
  241. )
  242. # Have the AssetProcessorTest use the LY_CMAKE_TARGET define of AssetProcessorBatch for the purpose
  243. # of looking up the generated cmake build dependencies settings registry .setreg file
  244. # It is tied to the UnitTestUtils.cpp file
  245. if(TARGET AssetProcessorBatch)
  246. set_source_files_properties(
  247. native/unittests/UnitTestUtils.cpp
  248. PROPERTIES
  249. COMPILE_DEFINITIONS
  250. LY_CMAKE_TARGET="AssetProcessorBatch"
  251. )
  252. else()
  253. message(FATAL_ERROR "Cannot set LY_CMAKE_TARGET define to AssetProcessorBatch as the target doesn't exist anymore."
  254. " Perhaps it has been renamed")
  255. endif()
  256. # there are some tests in the main suite, and some in periodic.
  257. ly_add_googletest(
  258. NAME AZ::AssetProcessor.Tests
  259. LABELS REQUIRES_tiaf
  260. )
  261. ly_add_googletest(NAME AZ::AssetProcessor.Tests.Periodic
  262. TARGET AZ::AssetProcessor.Tests
  263. TEST_SUITE periodic)
  264. # Sandbox the tests that fail intermittently
  265. ly_add_googletest(NAME AZ::AssetProcessor.Tests.Sandbox
  266. TARGET AZ::AssetProcessor.Tests
  267. TEST_SUITE sandbox)
  268. ly_add_googlebenchmark(
  269. NAME AZ::AssetProcessor.Benchmarks
  270. TARGET AZ::AssetProcessor.Tests
  271. )
  272. endif()