3
0

CMakeLists.txt 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. # TODO: would like to be able to build from this path, however, the whole setup is done at the workspace's root
  9. # we also dont want to drop cmake output files everywhere.
  10. o3de_pal_dir(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME} ${O3DE_ENGINE_RESTRICTED_PATH} ${LY_ROOT_FOLDER})
  11. set(common_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/Common)
  12. if(PAL_TRAIT_PROF_PIX_SUPPORTED)
  13. set(LY_PIX_ENABLED OFF CACHE BOOL "Enables PIX profiler integration.")
  14. if(LY_PIX_ENABLED)
  15. message(STATUS "PIX found, enabling as profiler")
  16. set(AZ_CORE_PIX_BUILD_DEPENDENCIES 3rdParty::pix)
  17. endif()
  18. endif()
  19. # By default, the Settings Registry will apply user and project registry files as overrides in development (non-release) builds,
  20. # and will ignore all overrides in release builds.
  21. # This behavior can be overridden by passing -DALLOW_SETTINGS_REGISTRY_DEVELOPMENT_OVERRIDES=0, 1, 2 or 3 when generating the build files.
  22. # The override can be removed by passing -UALLOW_SETTINGS_REGISTRY_DEVELOPMENT_OVERRIDES when generating the build files.
  23. set(ALLOW_SETTINGS_REGISTRY_DEVELOPMENT_OVERRIDES "" CACHE STRING
  24. "Forces the Settings Registry development overrides to be used or ignored.
  25. If unset, development overrides are used in development builds and ignored in release builds.
  26. 0 disables the development overrides in all builds.
  27. 1 = registry overrides are allowed from the command line.
  28. 2 = registry overrides are allowed from the command line, engine, gem, and project files.
  29. 3 = registry overrides are allowed from the command line, engine, gem, project, and user files.")
  30. # If there's a value in ALLOW_SETTINGS_REGISTRY_DEVELOPMENT_OVERRIDES, the compiler flag will get set to it.
  31. # Otherwise, the variable will be empty and no compiler flag will be set, leaving it to the code to decide
  32. # whether or not to allow the Settings Registry development overrides.
  33. set(ALLOW_SETTINGS_REGISTRY_DEVELOPMENT_OVERRIDES_FLAG $<$<NOT:$<STREQUAL:"${ALLOW_SETTINGS_REGISTRY_DEVELOPMENT_OVERRIDES}","">>:ALLOW_SETTINGS_REGISTRY_DEVELOPMENT_OVERRIDES=${ALLOW_SETTINGS_REGISTRY_DEVELOPMENT_OVERRIDES}>)
  34. ly_add_target(
  35. NAME O3DEKernel ${PAL_TRAIT_MONOLITHIC_DRIVEN_LIBRARY_TYPE}
  36. NAMESPACE AZ
  37. FILES_CMAKE
  38. AzCore/o3dekernel_files.cmake
  39. PLATFORM_INCLUDE_FILES
  40. ${pal_dir}/o3dekernel_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
  41. INCLUDE_DIRECTORIES
  42. PUBLIC
  43. .
  44. ${pal_dir}
  45. ${common_dir}
  46. )
  47. ly_add_target(
  48. NAME AzCore STATIC
  49. NAMESPACE AZ
  50. FILES_CMAKE
  51. AzCore/azcore_files.cmake
  52. AzCore/std/azstd_files.cmake
  53. ${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
  54. PLATFORM_INCLUDE_FILES
  55. ${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
  56. INCLUDE_DIRECTORIES
  57. PUBLIC
  58. .
  59. ${pal_dir}
  60. ${common_dir}
  61. BUILD_DEPENDENCIES
  62. PUBLIC
  63. 3rdParty::Lua
  64. 3rdParty::RapidJSON
  65. 3rdParty::RapidXML
  66. 3rdParty::ZLIB
  67. 3rdParty::zstd
  68. 3rdParty::cityhash
  69. ${AZ_CORE_PIX_BUILD_DEPENDENCIES}
  70. AZ::O3DEKernel
  71. )
  72. ly_add_source_properties(
  73. SOURCES
  74. AzCore/Script/ScriptSystemComponent.cpp
  75. AzCore/PlatformId/PlatformId.cpp
  76. PROPERTY COMPILE_DEFINITIONS
  77. VALUES ${LY_PAL_TOOLS_DEFINES}
  78. )
  79. ly_add_source_properties(
  80. SOURCES
  81. AzCore/Component/ComponentApplication.cpp
  82. PROPERTY COMPILE_DEFINITIONS
  83. VALUES ${ALLOW_SETTINGS_REGISTRY_DEVELOPMENT_OVERRIDES_FLAG}
  84. )
  85. # Add the O3DE_STACK_CAPTURE_DEPTH define only to the cpp files for the following allocators
  86. # This reduces re-compile time when the cache variable value changes.
  87. set(O3DE_STACK_CAPTURE_DEPTH_DEFINE $<$<NOT:$<STREQUAL:"${O3DE_STACK_CAPTURE_DEPTH}","">>:O3DE_STACK_CAPTURE_DEPTH=${O3DE_STACK_CAPTURE_DEPTH}>)
  88. ly_add_source_properties(
  89. SOURCES
  90. AzCore/Memory/OSAllocator.cpp
  91. AzCore/Memory/PoolAllocator.cpp
  92. AzCore/Memory/SystemAllocator.cpp
  93. PROPERTY COMPILE_DEFINITIONS
  94. VALUES ${O3DE_STACK_CAPTURE_DEPTH_DEFINE}
  95. )
  96. if(LY_BUILD_WITH_ADDRESS_SANITIZER)
  97. # Default to use Malloc schema so ASan works well
  98. ly_add_source_properties(
  99. SOURCES AzCore/Memory/SystemAllocator.cpp
  100. PROPERTY COMPILE_DEFINITIONS
  101. VALUES AZCORE_SYSTEM_ALLOCATOR=AZCORE_SYSTEM_ALLOCATOR_MALLOC
  102. )
  103. endif()
  104. ################################################################################
  105. # Tests
  106. ################################################################################
  107. if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
  108. ly_add_target(
  109. NAME AzCoreTestCommon STATIC
  110. NAMESPACE AZ
  111. FILES_CMAKE
  112. AzCore/azcoretestcommon_files.cmake
  113. INCLUDE_DIRECTORIES
  114. PRIVATE
  115. .
  116. ${pal_dir}
  117. ${common_dir}
  118. BUILD_DEPENDENCIES
  119. PRIVATE
  120. 3rdParty::googletest::GMock
  121. 3rdParty::GoogleBenchmark
  122. )
  123. ly_add_target(
  124. NAME AzTestShared STATIC
  125. NAMESPACE AZ
  126. FILES_CMAKE
  127. Tests/aztestshared_files.cmake
  128. INCLUDE_DIRECTORIES
  129. PUBLIC
  130. Tests
  131. BUILD_DEPENDENCIES
  132. PRIVATE
  133. AZ::AzTest
  134. AZ::AzCore
  135. )
  136. ly_add_target(
  137. NAME AzCoreTestDLL MODULE
  138. NAMESPACE AZ
  139. FILES_CMAKE
  140. Tests/azcoretestdll_files.cmake
  141. INCLUDE_DIRECTORIES
  142. PUBLIC
  143. Tests
  144. BUILD_DEPENDENCIES
  145. PRIVATE
  146. AZ::AzCore
  147. )
  148. o3de_pal_dir(pal_tests_dir ${CMAKE_CURRENT_LIST_DIR}/Tests/Platform/${PAL_PLATFORM_NAME} ${O3DE_ENGINE_RESTRICTED_PATH} ${LY_ROOT_FOLDER})
  149. ly_add_target(
  150. NAME AzCore.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
  151. NAMESPACE AZ
  152. FILES_CMAKE
  153. Tests/azcoretests_files.cmake
  154. ${pal_tests_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
  155. PLATFORM_INCLUDE_FILES
  156. ${pal_tests_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
  157. INCLUDE_DIRECTORIES
  158. PRIVATE
  159. Tests
  160. COMPILE_DEFINITIONS
  161. PRIVATE
  162. AZ_NUMERICCAST_ENABLED
  163. BUILD_DEPENDENCIES
  164. PRIVATE
  165. AZ::AzCore
  166. AZ::AzCoreTestCommon
  167. AZ::AzTestShared
  168. AZ::AzTest
  169. RUNTIME_DEPENDENCIES
  170. AZ::AzCoreTestDLL
  171. )
  172. ly_add_googletest(
  173. NAME AZ::AzCore.Tests
  174. LABELS REQUIRES_tiaf
  175. )
  176. ly_add_googletest(
  177. NAME AZ::AzCore.Tests
  178. TEST_SUITE sandbox
  179. )
  180. ly_add_googlebenchmark(
  181. NAME AZ::AzCore.Benchmarks
  182. TARGET AZ::AzCore.Tests
  183. )
  184. ly_add_source_properties(
  185. SOURCES Tests/Debug.cpp
  186. PROPERTY COMPILE_DEFINITIONS
  187. VALUES AZCORETEST_DLL_NAME=\"$<TARGET_FILE_NAME:AzCore.Tests>\"
  188. )
  189. ly_add_target_files(
  190. TARGETS AzCore.Tests
  191. FILES ${CMAKE_CURRENT_SOURCE_DIR}/Tests/Memory/AllocatorBenchmarkRecordings.bin
  192. OUTPUT_SUBDIRECTORY Tests/AzCore/Memory
  193. )
  194. endif()