|
| 1 | + |
| 2 | +# Currently we are in the Code folder: ${CMAKE_CURRENT_LIST_DIR} |
| 3 | +# Get the platform specific folder ${pal_dir} for the current folder: ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME} |
| 4 | +# Note: o3de_pal_dir will take care of the details for us, as this may be a restricted platform |
| 5 | +# in which case it will see if that platform is present here or in the restricted folder. |
| 6 | +# i.e. It could here in our gem : Gems/ImGuiProvider/Code/Platform/<platorm_name> or |
| 7 | +# <restricted_folder>/<platform_name>/Gems/ImGuiProvider/Code |
| 8 | +o3de_pal_dir(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME} "${gem_restricted_path}" "${gem_path}" "${gem_parent_relative_path}") |
| 9 | + |
| 10 | +# Now that we have the platform abstraction layer (PAL) folder for this folder, thats where we will find the |
| 11 | +# traits for this platform. Traits for a platform are defines for things like whether or not something in this gem |
| 12 | +# is supported by this platform. |
| 13 | +include(${pal_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) |
| 14 | + |
| 15 | +# Check to see if building the Gem Modules are supported for the current platform |
| 16 | +if(NOT PAL_TRAIT_IMGUIPROVIDER_SUPPORTED) |
| 17 | + return() |
| 18 | +endif() |
| 19 | + |
| 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 | + imguiprovider_api_files.cmake |
| 26 | + ${pal_dir}/imguiprovider_api_files.cmake |
| 27 | + INCLUDE_DIRECTORIES |
| 28 | + INTERFACE |
| 29 | + Include |
| 30 | + BUILD_DEPENDENCIES |
| 31 | + INTERFACE |
| 32 | + AZ::AzCore |
| 33 | + Gem::Atom_Feature_Common.Static |
| 34 | +) |
| 35 | + |
| 36 | +# The ${gem_name}.Private.Object target is an internal target |
| 37 | +# It should not be used outside of this Gems CMakeLists.txt |
| 38 | +ly_add_target( |
| 39 | + NAME ${gem_name}.Private.Object STATIC |
| 40 | + NAMESPACE Gem |
| 41 | + FILES_CMAKE |
| 42 | + imguiprovider_private_files.cmake |
| 43 | + ${pal_dir}/imguiprovider_private_files.cmake |
| 44 | + TARGET_PROPERTIES |
| 45 | + O3DE_PRIVATE_TARGET TRUE |
| 46 | + INCLUDE_DIRECTORIES |
| 47 | + PRIVATE |
| 48 | + Include |
| 49 | + Source |
| 50 | + BUILD_DEPENDENCIES |
| 51 | + PUBLIC |
| 52 | + AZ::AzCore |
| 53 | + AZ::AzFramework |
| 54 | + Gem::Atom_Feature_Common.Static |
| 55 | +) |
| 56 | + |
| 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 | + imguiprovider_shared_files.cmake |
| 64 | + ${pal_dir}/imguiprovider_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 | + |
| 77 | +# Include the gem name into the Client Module source file |
| 78 | +# for use with the AZ_DECLARE_MODULE_CLASS macro |
| 79 | +# This is to allow renaming of the gem to also cause |
| 80 | +# the CreateModuleClass_Gem_<gem-name> function which |
| 81 | +# is used to bootstrap the gem in monolithic builds to link to the new gem name |
| 82 | +ly_add_source_properties( |
| 83 | +SOURCES |
| 84 | + Source/Clients/ImGuiProviderModule.cpp |
| 85 | +PROPERTY COMPILE_DEFINITIONS |
| 86 | + VALUES |
| 87 | + O3DE_GEM_NAME=${gem_name} |
| 88 | + O3DE_GEM_VERSION=${gem_version}) |
| 89 | + |
| 90 | +# By default, we will specify that the above target ${gem_name} would be used by |
| 91 | +# Client and Server type targets when this gem is enabled. If you don't want it |
| 92 | +# active in Clients or Servers by default, delete one of both of the following lines: |
| 93 | +ly_create_alias(NAME ${gem_name}.Clients NAMESPACE Gem TARGETS Gem::${gem_name}) |
| 94 | +ly_create_alias(NAME ${gem_name}.Servers NAMESPACE Gem TARGETS Gem::${gem_name}) |
| 95 | +ly_create_alias(NAME ${gem_name}.Unified NAMESPACE Gem TARGETS Gem::${gem_name}) |
| 96 | + |
| 97 | +# For the Client and Server variants of ${gem_name} Gem, an alias to the ${gem_name}.API target will be made |
| 98 | +ly_create_alias(NAME ${gem_name}.Clients.API NAMESPACE Gem TARGETS Gem::${gem_name}.API) |
| 99 | +ly_create_alias(NAME ${gem_name}.Servers.API NAMESPACE Gem TARGETS Gem::${gem_name}.API) |
| 100 | +ly_create_alias(NAME ${gem_name}.Unified.API NAMESPACE Gem TARGETS Gem::${gem_name}.API) |
| 101 | + |
| 102 | +# Add in CMake dependencies for each gem dependency listed in this gem's gem.json file |
| 103 | +# for the Clients, Servers, Unified gem variants |
| 104 | +o3de_add_variant_dependencies_for_gem_dependencies(GEM_NAME ${gem_name} VARIANTS Clients Servers Unified) |
| 105 | + |
| 106 | +# If we are on a host platform, we want to add the host tools targets like the ${gem_name}.Editor MODULE target |
| 107 | +if(PAL_TRAIT_BUILD_HOST_TOOLS) |
| 108 | + # The ${gem_name}.Editor.API target can be used by other gems that want to interact with the ${gem_name}.Editor module |
| 109 | + ly_add_target( |
| 110 | + NAME ${gem_name}.Editor.API INTERFACE |
| 111 | + NAMESPACE Gem |
| 112 | + FILES_CMAKE |
| 113 | + imguiprovider_editor_api_files.cmake |
| 114 | + ${pal_dir}/imguiprovider_editor_api_files.cmake |
| 115 | + INCLUDE_DIRECTORIES |
| 116 | + INTERFACE |
| 117 | + Include |
| 118 | + BUILD_DEPENDENCIES |
| 119 | + INTERFACE |
| 120 | + AZ::AzToolsFramework |
| 121 | + ) |
| 122 | + |
| 123 | + # The ${gem_name}.Editor.Private.Object target is an internal target |
| 124 | + # which is only to be used by this gems CMakeLists.txt and any subdirectories |
| 125 | + # Other gems should not use this target |
| 126 | + ly_add_target( |
| 127 | + NAME ${gem_name}.Editor.Private.Object STATIC |
| 128 | + NAMESPACE Gem |
| 129 | + FILES_CMAKE |
| 130 | + imguiprovider_editor_private_files.cmake |
| 131 | + TARGET_PROPERTIES |
| 132 | + O3DE_PRIVATE_TARGET TRUE |
| 133 | + INCLUDE_DIRECTORIES |
| 134 | + PRIVATE |
| 135 | + Include |
| 136 | + Source |
| 137 | + BUILD_DEPENDENCIES |
| 138 | + PUBLIC |
| 139 | + AZ::AzToolsFramework |
| 140 | + ${gem_name}.Private.Object |
| 141 | + Gem::Atom_Feature_Common.Static |
| 142 | + ) |
| 143 | + |
| 144 | + ly_add_target( |
| 145 | + NAME ${gem_name}.Editor GEM_MODULE |
| 146 | + NAMESPACE Gem |
| 147 | + AUTOMOC |
| 148 | + FILES_CMAKE |
| 149 | + imguiprovider_editor_shared_files.cmake |
| 150 | + INCLUDE_DIRECTORIES |
| 151 | + PRIVATE |
| 152 | + Source |
| 153 | + PUBLIC |
| 154 | + Include |
| 155 | + BUILD_DEPENDENCIES |
| 156 | + PUBLIC |
| 157 | + Gem::${gem_name}.Editor.API |
| 158 | + PRIVATE |
| 159 | + Gem::${gem_name}.Editor.Private.Object |
| 160 | + ) |
| 161 | + |
| 162 | + # Include the gem name into the Editor Module source file |
| 163 | + # for use with the AZ_DECLARE_MODULE_CLASS macro |
| 164 | + # This is to allow renaming of the gem to also cause |
| 165 | + # the CreateModuleClass_Gem_<gem-name> function which |
| 166 | + # is used to bootstrap the gem in monolithic builds to link to the new gem name |
| 167 | + ly_add_source_properties( |
| 168 | + SOURCES |
| 169 | + Source/Tools/ImGuiProviderEditorModule.cpp |
| 170 | + PROPERTY COMPILE_DEFINITIONS |
| 171 | + VALUES |
| 172 | + O3DE_GEM_NAME=${gem_name} |
| 173 | + O3DE_GEM_VERSION=${gem_version}) |
| 174 | + |
| 175 | + # By default, we will specify that the above target ${gem_name} would be used by |
| 176 | + # Tool and Builder type targets when this gem is enabled. If you don't want it |
| 177 | + # active in Tools or Builders by default, delete one of both of the following lines: |
| 178 | + ly_create_alias(NAME ${gem_name}.Tools NAMESPACE Gem TARGETS Gem::${gem_name}.Editor) |
| 179 | + ly_create_alias(NAME ${gem_name}.Builders NAMESPACE Gem TARGETS Gem::${gem_name}.Editor) |
| 180 | + |
| 181 | + # For the Tools and Builders variants of ${gem_name} Gem, an alias to the ${gem_name}.Editor API target will be made |
| 182 | + ly_create_alias(NAME ${gem_name}.Tools.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API) |
| 183 | + ly_create_alias(NAME ${gem_name}.Builders.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API) |
| 184 | + |
| 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 | +################################################################################ |
| 191 | +# Tests |
| 192 | +################################################################################ |
| 193 | +# See if globally, tests are supported |
| 194 | +if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) |
| 195 | + # We globally support tests, see if we support tests on this platform for ${gem_name}.Tests |
| 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 | + imguiprovider_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 | + |
| 214 | + # Add ${gem_name}.Tests to googletest |
| 215 | + ly_add_googletest( |
| 216 | + NAME Gem::${gem_name}.Tests |
| 217 | + ) |
| 218 | + |
| 219 | + # unit test for Menu tree utils |
| 220 | + ly_add_target( |
| 221 | + NAME ImGuiProvider.MenuTree.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} |
| 222 | + NAMESPACE Gem |
| 223 | + FILES_CMAKE |
| 224 | + imguiprovder_menu_tree_tests_files.cmake |
| 225 | + INCLUDE_DIRECTORIES |
| 226 | + PRIVATE |
| 227 | + Source |
| 228 | + Tests |
| 229 | + BUILD_DEPENDENCIES |
| 230 | + PRIVATE |
| 231 | + AZ::AzTestShared |
| 232 | + AZ::AzToolsFramework |
| 233 | + AZ::AzManipulatorTestFramework.Static |
| 234 | + Gem::${gem_name}.API |
| 235 | + Gem::${gem_name}.Private.Object |
| 236 | + ) |
| 237 | + target_compile_options(ImGuiProvider.MenuTree.Tests PUBLIC -fexceptions) |
| 238 | + set_target_properties(ImGuiProvider.MenuTree.Tests PROPERTIES UNITY_BUILD OFF) |
| 239 | + ly_add_googletest( |
| 240 | + NAME Gem::ImGuiProvider.MenuTree.Tests |
| 241 | + ) |
| 242 | + |
| 243 | + |
| 244 | + |
| 245 | + # If we are a host platform we want to add tools test like editor tests here |
| 246 | + if(PAL_TRAIT_BUILD_HOST_TOOLS) |
| 247 | + # We are a host platform, see if Editor tests are supported on this platform |
| 248 | + # We support ${gem_name}.Editor.Tests on this platform, add ${gem_name}.Editor.Tests target which depends on |
| 249 | + # private ${gem_name}.Editor.Private.Object target |
| 250 | + ly_add_target( |
| 251 | + NAME ${gem_name}.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} |
| 252 | + NAMESPACE Gem |
| 253 | + FILES_CMAKE |
| 254 | + imguiprovider_editor_tests_files.cmake |
| 255 | + INCLUDE_DIRECTORIES |
| 256 | + PRIVATE |
| 257 | + Tests |
| 258 | + Source |
| 259 | + Include |
| 260 | + BUILD_DEPENDENCIES |
| 261 | + PRIVATE |
| 262 | + AZ::AzTest |
| 263 | + Gem::${gem_name}.Editor.Private.Object |
| 264 | + ) |
| 265 | + |
| 266 | + # Add ${gem_name}.Editor.Tests to googletest |
| 267 | + ly_add_googletest( |
| 268 | + NAME Gem::${gem_name}.Editor.Tests |
| 269 | + ) |
| 270 | + endif() |
| 271 | +endif() |
0 commit comments