瀏覽代碼

Updates for PhysX4/5 split (#36)

* Updates for PhysX4/5 split
* Removed legacy `enabled_gems` and updated project.json
*  Updated EngineFinder.cmake (Replaced with EngineFinder_O3DE_2210.cmake)
* Tagged ROS2 dependency against version 3.1.0 or higher
* Tagged engine version to 4.1.0

Signed-off-by: Steve Pham <[email protected]>
Steve Pham 1 年之前
父節點
當前提交
5050e0be93

+ 0 - 3
Gem/CMakeLists.txt

@@ -95,6 +95,3 @@ o3de_find_ancestor_project_root(project_path project_name "${CMAKE_CURRENT_SOURC
 if (NOT project_name)
     set(project_name ${Name})
 endif()
-
-# Enable the specified list of gems from GEM_FILE or GEMS list for this specific project:
-ly_enable_gems(PROJECT_NAME ${project_name} GEM_FILE enabled_gems.cmake)

+ 0 - 29
Gem/enabled_gems.cmake

@@ -1,29 +0,0 @@
-#
-# Copyright (c) Contributors to the Open 3D Engine Project.
-# For complete copyright and license terms please see the LICENSE at the root of this distribution.
-#
-# SPDX-License-Identifier: Apache-2.0 OR MIT
-#
-#
-
-set(ENABLED_GEMS
-    RobotVacuumSample
-    Atom
-    CameraFramework
-    DebugDraw
-    GameState
-    ImGui
-    LandscapeCanvas
-    LyShine
-    PhysX
-    PrimitiveAssets
-    PrefabBuilder
-    SaveData
-    ScriptCanvasPhysics
-    ScriptEvents
-    StartingPointInput
-    TextureAtlas
-    WhiteBox
-    ROS2
-    ArchVis
-)

+ 0 - 1
Gem/robot_vacuum_sample_files.cmake

@@ -10,5 +10,4 @@ set(FILES
     Include/RobotVacuumSample/RobotVacuumSampleBus.h
     Source/RobotVacuumSampleSystemComponent.cpp
     Source/RobotVacuumSampleSystemComponent.h
-    enabled_gems.cmake
 )

+ 1 - 1
Registry/physxdebugconfiguration.setreg

@@ -1,7 +1,7 @@
 {
     "Amazon": {
         "Gems": {
-            "PhysX": {
+            "PhysX5": {
                 "Debug": {
                     "PhysXDebugConfiguration": {}
                 }

+ 1 - 1
Registry/physxdefaultsceneconfiguration.setreg

@@ -1,7 +1,7 @@
 {
     "Amazon": {
         "Gems": {
-            "PhysX": {
+            "PhysX5": {
                 "DefaultSceneConfiguration": {}
             }
         }

+ 3 - 3
Registry/physxsystemconfiguration.setreg

@@ -1,13 +1,13 @@
 {
     "Amazon": {
         "Gems": {
-            "PhysX": {
+            "PhysX5": {
                 "PhysXSystemConfiguration": {
                     "CollisionConfig": {
                         "Layers": {
                             "LayerNames": [
                                 "Default",
-                                "Robot",
+                                {},
                                 {},
                                 {},
                                 {},
@@ -80,7 +80,7 @@
                                 },
                                 {
                                     "Id": {
-                                        "GroupId": "{B72454E5-5436-42F5-9BAE-6B9D2763E433}"
+                                        "GroupId": "{0CD57BF7-E5B5-4F99-A5CD-CBA5F6A4B017}"
                                     },
                                     "Name": "None",
                                     "Group": {

+ 42 - 126
cmake/EngineFinder.cmake

@@ -11,56 +11,30 @@
 
 include_guard()
 
+# Read the engine name from the project_json file
+file(READ ${CMAKE_CURRENT_SOURCE_DIR}/project.json project_json)
 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/project.json)
 
-# Option 1: Use engine manually set in CMAKE_MODULE_PATH
-# CMAKE_MODULE_PATH must contain a path to an engine's cmake folder 
+string(JSON LY_ENGINE_NAME_TO_USE ERROR_VARIABLE json_error GET ${project_json} engine)
+if(json_error)
+    message(FATAL_ERROR "Unable to read key 'engine' from 'project.json'\nError: ${json_error}")
+endif()
+
 if(CMAKE_MODULE_PATH)
     foreach(module_path ${CMAKE_MODULE_PATH})
-        cmake_path(SET module_engine_version_cmake_path "${module_path}/o3deConfigVersion.cmake")
-        if(EXISTS "${module_engine_version_cmake_path}")
-            include("${module_engine_version_cmake_path}")
-            if(PACKAGE_VERSION_COMPATIBLE)
-                message(STATUS "Selecting engine from CMAKE_MODULE_PATH '${module_path}'")
-                return()
-            else()
-                message(WARNING "Not using engine from CMAKE_MODULE_PATH '${module_path}' because it is not compatible with this project.")
+        if(EXISTS ${module_path}/Findo3de.cmake)
+            file(READ ${module_path}/../engine.json engine_json)
+            string(JSON engine_name ERROR_VARIABLE json_error GET ${engine_json} engine_name)
+            if(json_error)
+                message(FATAL_ERROR "Unable to read key 'engine_name' from 'engine.json'\nError: ${json_error}")
             endif()
-        endif()
-    endforeach()
-    message(VERBOSE "No compatible engine found from CMAKE_MODULE_PATH '${CMAKE_MODULE_PATH}'.")
-endif()
-
-# Option 2: Use the engine from the 'engine_path' field in <project>/user/project.json
-cmake_path(SET O3DE_USER_PROJECT_JSON_PATH ${CMAKE_CURRENT_SOURCE_DIR}/user/project.json)
-if(EXISTS "${O3DE_USER_PROJECT_JSON_PATH}")
-    file(READ "${O3DE_USER_PROJECT_JSON_PATH}" user_project_json)
-    if(user_project_json)
-        string(JSON user_project_engine_path ERROR_VARIABLE json_error GET ${user_project_json} engine_path)
-        if(user_project_engine_path AND NOT json_error)
-            cmake_path(SET user_engine_version_cmake_path "${user_project_engine_path}/cmake/o3deConfigVersion.cmake")
-            if(EXISTS "${user_engine_version_cmake_path}")
-                include("${user_engine_version_cmake_path}")
-                if(PACKAGE_VERSION_COMPATIBLE)
-                    message(STATUS "Selecting engine '${user_project_engine_path}' from 'engine_path' in '<project>/user/project.json'.")
-                    list(APPEND CMAKE_MODULE_PATH "${user_project_engine_path}/cmake")
-                    return()
-                else()
-                    message(FATAL_ERROR "The engine at '${user_project_engine_path}' from 'engine_path' in '${O3DE_USER_PROJECT_JSON_PATH}' is not compatible with this project. Please register this project with a compatible engine, or remove the local override by running:\nscripts\\o3de edit-project-properties -pp ${CMAKE_CURRENT_SOURCE_DIR} --user --engine-path \"\"")
-                endif()
-            else()
-                message(FATAL_ERROR "This project cannot use the engine at '${user_project_engine_path}' because the version cmake file '${user_engine_version_cmake_path}' needed to check compatibility is missing.  \nPlease register this project with a compatible engine, or remove the local override by running:\nscripts\\o3de edit-project-properties -pp ${CMAKE_CURRENT_SOURCE_DIR} --user --engine-path \"\"\nIf you want this project to use an older engine(not recommended), provide a custom EngineFinder.cmake using the o3de CLI's --engine-finder-cmake-path option. ")
+            if(LY_ENGINE_NAME_TO_USE STREQUAL engine_name)
+                return() # Engine being forced through CMAKE_MODULE_PATH
             endif()
-        elseif(json_error AND ${user_project_engine_path} STREQUAL "NOTFOUND")
-            # When the value is just NOTFOUND that means there is a JSON
-            # parsing error, and not simply a missing key 
-            message(FATAL_ERROR "Unable to read 'engine_path' from '${user_project_engine_path}'\nError: ${json-error}")
         endif()
-    endif()
+    endforeach()
 endif()
 
-
-# Option 3: Find a compatible engine registered in ~/.o3de/o3de_manifest.json 
 if(DEFINED ENV{USERPROFILE} AND EXISTS $ENV{USERPROFILE})
     set(manifest_path $ENV{USERPROFILE}/.o3de/o3de_manifest.json) # Windows
 else()
@@ -68,108 +42,50 @@ else()
 endif()
 
 set(registration_error [=[
-To enable more verbose logging, run the cmake command again with '--log-level VERBOSE'
-
 Engine registration is required before configuring a project.
 Run 'scripts/o3de register --this-engine' from the engine root.
 ]=])
 
-# Create a list of all engines
+# Read the ~/.o3de/o3de_manifest.json file and look through the 'engines_path' object.
+# Find a key that matches LY_ENGINE_NAME_TO_USE and use that as the engine path.
 if(EXISTS ${manifest_path})
     file(READ ${manifest_path} manifest_json)
     set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${manifest_path})
 
-    string(JSON engines_count ERROR_VARIABLE json_error LENGTH ${manifest_json} engines)
+    string(JSON engines_path_count ERROR_VARIABLE json_error LENGTH ${manifest_json} engines_path)
     if(json_error)
-        message(FATAL_ERROR "Unable to read key 'engines' from '${manifest_path}'\nError: ${json_error}\n${registration_error}")
+        message(FATAL_ERROR "Unable to read key 'engines_path' from '${manifest_path}'\nError: ${json_error}\n${registration_error}")
     endif()
 
-    string(JSON engines_type ERROR_VARIABLE json_error TYPE ${manifest_json} engines)
-    if(json_error OR NOT ${engines_type} STREQUAL "ARRAY")
-        message(FATAL_ERROR "Type of 'engines' in '${manifest_path}' is not a JSON ARRAY\nError: ${json_error}\n${registration_error}")
+    string(JSON engines_path_type ERROR_VARIABLE json_error TYPE ${manifest_json} engines_path)
+    if(json_error OR NOT ${engines_path_type} STREQUAL "OBJECT")
+        message(FATAL_ERROR "Type of 'engines_path' in '${manifest_path}' is not a JSON Object\nError: ${json_error}")
     endif()
 
-    math(EXPR engines_count "${engines_count}-1")
-    foreach(array_index RANGE ${engines_count})
-        string(JSON manifest_engine_path ERROR_VARIABLE json_error GET ${manifest_json} engines "${array_index}")
+    math(EXPR engines_path_count "${engines_path_count}-1")
+    foreach(engine_path_index RANGE ${engines_path_count})
+        string(JSON engine_name ERROR_VARIABLE json_error MEMBER ${manifest_json} engines_path ${engine_path_index})
         if(json_error)
-            message(FATAL_ERROR "Unable to read 'engines/${array_index}' from '${manifest_path}'\nError: ${json_error}\n${registration_error}")
+            message(FATAL_ERROR "Unable to read 'engines_path/${engine_path_index}' from '${manifest_path}'\nError: ${json_error}")
         endif()
-        list(APPEND O3DE_ENGINE_PATHS ${manifest_engine_path})
-    endforeach()
-elseif(NOT CMAKE_MODULE_PATH)
-    message(FATAL_ERROR "O3DE Manifest file not found at '${manifest_path}'.\n${registration_error}")
-endif()
-
-# We cannot just run find_package() on the list of engine paths because
-# CMAKE_FIND_PACKAGE_SORT_ORDER sorts based on file name and chooses
-# the first package that returns PACKAGE_VERSION_COMPATIBLE 
-set(O3DE_MOST_COMPATIBLE_ENGINE_PATH "")
-set(O3DE_MOST_COMPATIBLE_ENGINE_VERSION "")
-set(O3DE_HAS_OLDER_ENGINES false)
-foreach(manifest_engine_path IN LISTS O3DE_ENGINE_PATHS) 
-    # Does this engine have a config version cmake file?
-    cmake_path(SET version_cmake_path "${manifest_engine_path}/cmake/o3deConfigVersion.cmake")
-    if(NOT EXISTS "${version_cmake_path}") 
-        message(VERBOSE "Ignoring '${manifest_engine_path}' because no config version cmake file was found at '${version_cmake_path}'")
-        set(O3DE_HAS_OLDER_ENGINES true)
-        continue()
-    endif()
 
-    unset(PACKAGE_VERSION)
-    unset(PACKAGE_VERSION_COMPATIBLE)
-    include("${version_cmake_path}")
+        if(LY_ENGINE_NAME_TO_USE STREQUAL engine_name)
+            string(JSON engine_path ERROR_VARIABLE json_error GET ${manifest_json} engines_path ${engine_name})
+            if(json_error)
+                message(FATAL_ERROR "Unable to read value from 'engines_path/${engine_name}'\nError: ${json_error}")
+            endif()
 
-    # Follow the version checking convention from find_package(CONFIG)
-    if(PACKAGE_VERSION_COMPATIBLE)
-        if(NOT O3DE_MOST_COMPATIBLE_ENGINE_PATH) 
-            set(O3DE_MOST_COMPATIBLE_ENGINE_PATH "${manifest_engine_path}") 
-            set(O3DE_MOST_COMPATIBLE_ENGINE_VERSION ${PACKAGE_VERSION}) 
-            message(VERBOSE "Found compatible engine '${manifest_engine_path}' with version '${PACKAGE_VERSION}'")
-        elseif(${PACKAGE_VERSION} VERSION_GREATER ${O3DE_MOST_COMPATIBLE_ENGINE_VERSION})
-            set(O3DE_MOST_COMPATIBLE_ENGINE_PATH "${manifest_engine_path}")
-            set(O3DE_MOST_COMPATIBLE_ENGINE_VERSION ${PACKAGE_VERSION})
-            message(VERBOSE "Found more compatible engine '${manifest_engine_path}' with version '${PACKAGE_VERSION}' because it has a greater version number.")
-        else()
-            message(VERBOSE "Not using engine '${manifest_engine_path}' with version '${PACKAGE_VERSION}' because it doesn't have a greater version number or has a different engine name.")
+            if(engine_path)
+                list(APPEND CMAKE_MODULE_PATH "${engine_path}/cmake")
+                return()
+            endif()
         endif()
-    else()
-        message(VERBOSE "Ignoring '${manifest_engine_path}' because it is not a compatible engine.")
-    endif()
-endforeach()
-
-if(O3DE_MOST_COMPATIBLE_ENGINE_PATH)
-    message(STATUS "Selecting engine '${O3DE_MOST_COMPATIBLE_ENGINE_PATH}'")
-    # Make sure PACKAGE_VERSION_COMPATIBLE is set so Findo3de.cmake knows
-    # compatibility was checked
-    set(PACKAGE_VERSION_COMPATIBLE True)
-    set(PACKAGE_VERSION O3DE_MOST_COMPATIBLE_ENGINE_VERSION)
-    list(APPEND CMAKE_MODULE_PATH "${O3DE_MOST_COMPATIBLE_ENGINE_PATH}/cmake")
-    return()
-endif()
-
-# No compatible engine was found.
-if(O3DE_HAS_OLDER_ENGINES)
-    message(STATUS "Unable to find a compatible engine but engines were found that do not support compatibility checks.  Falling back to older EngineFinder logic.")
-    include(cmake/EngineFinder_O3DE_2210.cmake)
-    return()
-endif()
-
-# Read the 'engine' field in project.json or user/project.json for more helpful messages 
-if(user_project_json)
-    string(JSON user_project_engine ERROR_VARIABLE json_error GET ${user_project_json} engine)
-endif()
-
-if(NOT user_project_engine)
-    file(READ ${CMAKE_CURRENT_SOURCE_DIR}/project.json o3de_project_json)
-    string(JSON project_engine ERROR_VARIABLE json_error GET ${o3de_project_json} engine)
-    if(json_error)
-        message(FATAL_ERROR "Unable to read key 'engine' from 'project.json'\nError: ${json_error}")
-    endif()
-endif()
-
-if(user_project_engine)
-    message(FATAL_ERROR "The local '${O3DE_USER_PROJECT_JSON_PATH}' engine is '${user_project_engine}' but no compatible engine with that name and version was found.  Please register the compatible engine, or remove the local engine override.\n${registration_error}")
+    endforeach()
+    
+    message(FATAL_ERROR "The project.json uses engine name '${LY_ENGINE_NAME_TO_USE}' but no engine with that name has been registered.\n${registration_error}")
 else()
-    message(FATAL_ERROR "The project.json engine is '${project_engine}' but no engine with that name and version was found.\n${registration_error}")
+    # If the user is passing CMAKE_MODULE_PATH we assume thats where we will find the engine
+    if(NOT CMAKE_MODULE_PATH)
+        message(FATAL_ERROR "O3DE Manifest file not found.\n${registration_error}")
+    endif()
 endif()

+ 0 - 91
cmake/EngineFinder_O3DE_2210.cmake

@@ -1,91 +0,0 @@
-#
-# Copyright (c) Contributors to the Open 3D Engine Project.
-# For complete copyright and license terms please see the LICENSE at the root of this distribution.
-#
-# SPDX-License-Identifier: Apache-2.0 OR MIT
-#
-#
-
-# This file is copied during engine registration. Edits to this file will be lost next
-# time a registration happens.
-
-include_guard()
-
-# Read the engine name from the project_json file
-file(READ ${CMAKE_CURRENT_SOURCE_DIR}/project.json project_json)
-set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/project.json)
-
-string(JSON LY_ENGINE_NAME_TO_USE ERROR_VARIABLE json_error GET ${project_json} engine)
-if(json_error)
-    message(FATAL_ERROR "Unable to read key 'engine' from 'project.json'\nError: ${json_error}")
-endif()
-
-if(CMAKE_MODULE_PATH)
-    foreach(module_path ${CMAKE_MODULE_PATH})
-        if(EXISTS ${module_path}/Findo3de.cmake)
-            file(READ ${module_path}/../engine.json engine_json)
-            string(JSON engine_name ERROR_VARIABLE json_error GET ${engine_json} engine_name)
-            if(json_error)
-                message(FATAL_ERROR "Unable to read key 'engine_name' from 'engine.json'\nError: ${json_error}")
-            endif()
-            if(LY_ENGINE_NAME_TO_USE STREQUAL engine_name)
-                return() # Engine being forced through CMAKE_MODULE_PATH
-            endif()
-        endif()
-    endforeach()
-endif()
-
-if(DEFINED ENV{USERPROFILE} AND EXISTS $ENV{USERPROFILE})
-    set(manifest_path $ENV{USERPROFILE}/.o3de/o3de_manifest.json) # Windows
-else()
-    set(manifest_path $ENV{HOME}/.o3de/o3de_manifest.json) # Unix
-endif()
-
-set(registration_error [=[
-Engine registration is required before configuring a project.
-Run 'scripts/o3de register --this-engine' from the engine root.
-]=])
-
-# Read the ~/.o3de/o3de_manifest.json file and look through the 'engines_path' object.
-# Find a key that matches LY_ENGINE_NAME_TO_USE and use that as the engine path.
-if(EXISTS ${manifest_path})
-    file(READ ${manifest_path} manifest_json)
-    set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${manifest_path})
-
-    string(JSON engines_path_count ERROR_VARIABLE json_error LENGTH ${manifest_json} engines_path)
-    if(json_error)
-        message(FATAL_ERROR "Unable to read key 'engines_path' from '${manifest_path}'\nError: ${json_error}\n${registration_error}")
-    endif()
-
-    string(JSON engines_path_type ERROR_VARIABLE json_error TYPE ${manifest_json} engines_path)
-    if(json_error OR NOT ${engines_path_type} STREQUAL "OBJECT")
-        message(FATAL_ERROR "Type of 'engines_path' in '${manifest_path}' is not a JSON Object\nError: ${json_error}")
-    endif()
-
-    math(EXPR engines_path_count "${engines_path_count}-1")
-    foreach(engine_path_index RANGE ${engines_path_count})
-        string(JSON engine_name ERROR_VARIABLE json_error MEMBER ${manifest_json} engines_path ${engine_path_index})
-        if(json_error)
-            message(FATAL_ERROR "Unable to read 'engines_path/${engine_path_index}' from '${manifest_path}'\nError: ${json_error}")
-        endif()
-
-        if(LY_ENGINE_NAME_TO_USE STREQUAL engine_name)
-            string(JSON engine_path ERROR_VARIABLE json_error GET ${manifest_json} engines_path ${engine_name})
-            if(json_error)
-                message(FATAL_ERROR "Unable to read value from 'engines_path/${engine_name}'\nError: ${json_error}")
-            endif()
-
-            if(engine_path)
-                list(APPEND CMAKE_MODULE_PATH "${engine_path}/cmake")
-                return()
-            endif()
-        endif()
-    endforeach()
-    
-    message(FATAL_ERROR "The project.json uses engine name '${LY_ENGINE_NAME_TO_USE}' but no engine with that name has been registered.\n${registration_error}")
-else()
-    # If the user is passing CMAKE_MODULE_PATH we assume thats where we will find the engine
-    if(NOT CMAKE_MODULE_PATH)
-        message(FATAL_ERROR "O3DE Manifest file not found.\n${registration_error}")
-    endif()
-endif()

+ 15 - 3
project.json

@@ -18,8 +18,20 @@
     ],
     "restricted": "RobotVacuumSample",
     "gem_names": [
-        "ROS2",
-        "ArchVis"
+        "ArchVis",
+        "Atom",
+        "CameraFramework",
+        "DebugDraw",
+        "GameState",
+        "ImGui",
+        "LyShine",
+        "PhysX5",
+        "PrimitiveAssets",
+        "PrefabBuilder",
+        "ROS2>=3.1.0",
+        "ScriptEvents",
+        "StartingPointInput",
+        "TextureAtlas"
     ],
-    "engine_version": "2.2.0"
+    "engine_version": "4.1.0"
 }