Selaa lähdekoodia

Redcode/driller removal (#299)

* Adds changes from the last template

Signed-off-by: Esteban Papp <[email protected]>

* Removes FileIOErrorHandler

Signed-off-by: Esteban Papp <[email protected]>

* Replaces  EventTrace with new profiler (EventTrace was not doing anything)

Signed-off-by: Esteban Papp <[email protected]>

* Removes unused files that dont exist anymore

Signed-off-by: Esteban Papp <[email protected]>
Esteban Papp 3 vuotta sitten
vanhempi
commit
833debb39a

+ 2 - 1
CMakeLists.txt

@@ -8,11 +8,12 @@
 
 if(NOT PROJECT_NAME)
     cmake_minimum_required(VERSION 3.19)
+    include(cmake/CompilerSettings.cmake)
     project(AtomSampleViewer
         LANGUAGES C CXX
         VERSION 1.0.0.0
     )
-    include(EngineFinder.cmake OPTIONAL)
+    include(cmake/EngineFinder.cmake OPTIONAL)
     find_package(o3de REQUIRED)
     o3de_initialize()
 else()

+ 3 - 2
Gem/Code/Source/AssetLoadTestComponent.cpp

@@ -16,11 +16,12 @@
 
 #include <Automation/ScriptRunnerBus.h>
 
-#include <AzCore/Debug/EventTrace.h>
 #include <AzCore/Serialization/SerializeContext.h>
 
 #include <RHI/BasicRHIComponent.h>
 
+AZ_DECLARE_BUDGET(AtomSampleViewer);
+
 namespace AtomSampleViewer
 {
     using namespace AZ;
@@ -241,7 +242,7 @@ namespace AtomSampleViewer
 
     void AssetLoadTestComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint scriptTime)
     {
-        AZ_TRACE_METHOD();
+        AZ_PROFILE_FUNCTION(AtomSampleViewer);
 
         const float timeSeconds = static_cast<float>(scriptTime.GetSeconds());
 

+ 2 - 0
Gem/Code/Source/AtomSampleViewerSystemComponent.cpp

@@ -36,6 +36,8 @@
 #include <Utils/ImGuiSaveFilePath.h>
 #include <Utils/Utils.h>
 
+AZ_DEFINE_BUDGET(AtomSampleViewer);
+
 namespace AtomSampleViewer
 {
     void AtomSampleViewerSystemComponent::Reflect(AZ::ReflectContext* context)

+ 4 - 12
Gem/Code/Source/Automation/ScriptReporter.cpp

@@ -855,24 +855,20 @@ namespace AtomSampleViewer
         AZStd::string destinationFolder = destinationFile;
         AzFramework::StringFunc::Path::StripFullName(destinationFolder);
 
-        m_fileIoErrorHandler.BusConnect();
-
         bool failed = false;
 
         if (!AZ::IO::LocalFileIO::GetInstance()->CreatePath(destinationFolder.c_str()))
         {
             failed = true;
-            m_fileIoErrorHandler.ReportLatestIOError(AZStd::string::format("Failed to create folder '%s'.", destinationFolder.c_str()));
+            AZ_Error("ScriptReporter", false, "Failed to create folder '%s'.", destinationFolder.c_str());
         }
 
         if (!AZ::IO::LocalFileIO::GetInstance()->Copy(screenshotTest.m_screenshotFilePath.c_str(), destinationFile.c_str()))
         {
             failed = true;
-            m_fileIoErrorHandler.ReportLatestIOError(AZStd::string::format("Failed to copy '%s' to '%s'.", screenshotTest.m_screenshotFilePath.c_str(), destinationFile.c_str()));
+            AZ_Error("ScriptReporter", false, "Failed to copy '%s' to '%s'.", screenshotTest.m_screenshotFilePath.c_str(), destinationFile.c_str());
         }
 
-        m_fileIoErrorHandler.BusDisconnect();
-
         if (!failed)
         {
             // Since we just replaced the baseline image, we can update this screenshot test result as an exact match.
@@ -927,24 +923,20 @@ namespace AtomSampleViewer
         // ".../AtomSampleViewer/Scripts/ExpectedScreenshots/MyTestFolder/" + "MyTest.png"
         AZStd::string sourceFilePath = AZStd::string::format("%s\\%s", sourceFolderPath.c_str(), reversePathComponents[0].c_str());
 
-        m_fileIoErrorHandler.BusConnect();
-
         // Create parent folder if it doesn't exist
         if (success && !io->CreatePath(sourceFolderPath.c_str()))
         {
             success = false;
-            m_fileIoErrorHandler.ReportLatestIOError(AZStd::string::format("Failed to create folder '%s'.", sourceFolderPath.c_str()));
+            AZ_Error("ScriptReporter", false, "Failed to create folder '%s'.", sourceFolderPath.c_str());
         }
 
         // Replace source screenshot with new result
         if (success && !io->Copy(screenshotTest.m_screenshotFilePath.c_str(), sourceFilePath.c_str()))
         {
             success = false;
-            m_fileIoErrorHandler.ReportLatestIOError(AZStd::string::format("Failed to copy '%s' to '%s'.", screenshotTest.m_screenshotFilePath.c_str(), sourceFilePath.c_str()));
+            AZ_Error("ScriptReporter", false, "Failed to copy '%s' to '%s'.", screenshotTest.m_screenshotFilePath.c_str(), sourceFilePath.c_str());
         }
 
-        m_fileIoErrorHandler.BusDisconnect();
-
         if (success)
         {
             // Since we just replaced the baseline image, we can update this screenshot test result as an exact match.

+ 0 - 2
Gem/Code/Source/Automation/ScriptReporter.h

@@ -13,7 +13,6 @@
 #include <Atom/Utils/ImageComparison.h>
 #include <Automation/ImageComparisonConfig.h>
 #include <Utils/ImGuiMessageBox.h>
-#include <Utils/FileIOErrorHandler.h>
 
 namespace AtomSampleViewer
 {
@@ -241,7 +240,6 @@ namespace AtomSampleViewer
         ScriptReport* GetCurrentScriptReport();
 
         ImGuiMessageBox m_messageBox;
-        FileIOErrorHandler m_fileIoErrorHandler;
 
         AZStd::vector<ImageComparisonToleranceLevel> m_availableToleranceLevels;
         AZStd::string m_invalidationMessage;

+ 3 - 2
Gem/Code/Source/DynamicMaterialTestComponent.cpp

@@ -18,12 +18,13 @@
 #include <Atom/RPI.Reflect/Asset/AssetUtils.h>
 
 #include <AzCore/Component/Entity.h>
-#include <AzCore/Debug/EventTrace.h>
 #include <AzCore/Debug/Timer.h>
 #include <AzCore/Math/Random.h>
 
 #include <RHI/BasicRHIComponent.h>
 
+AZ_DECLARE_BUDGET(AtomSampleViewer);
+
 namespace AtomSampleViewer
 {
     using namespace AZ;
@@ -229,7 +230,7 @@ namespace AtomSampleViewer
 
     void DynamicMaterialTestComponent::OnTick(float deltaTime, ScriptTimePoint /*scriptTime*/)
     {
-        AZ_TRACE_METHOD();
+        AZ_PROFILE_FUNCTION(AtomSampleViewer);
 
         if (m_waitingForMeshes)
         {

+ 2 - 2
Gem/Code/Source/HighInstanceExampleComponent.cpp

@@ -18,7 +18,6 @@
 
 #include <Automation/ScriptRunnerBus.h>
 
-#include <AzCore/Debug/EventTrace.h>
 #include <AzCore/Serialization/SerializeContext.h>
 #include <AzFramework/Windowing/WindowBus.h>
 
@@ -26,6 +25,7 @@
 
 #include <HighInstanceTestComponent_Traits_Platform.h>
 
+AZ_DECLARE_BUDGET(AtomSampleViewer);
 
 namespace AtomSampleViewer
 {
@@ -309,7 +309,7 @@ namespace AtomSampleViewer
 
     void HighInstanceTestComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint scriptTime)
     {
-        AZ_TRACE_METHOD();
+		AZ_PROFILE_FUNCTION(AtomSampleViewer);
 
         if (m_updateTransformEnabled)
         {

+ 3 - 11
Gem/Code/Source/MaterialHotReloadTestComponent.cpp

@@ -212,14 +212,10 @@ namespace AtomSampleViewer
 
         if (AZ::IO::LocalFileIO::GetInstance()->Exists(deletePath.c_str()))
         {
-            m_fileIoErrorHandler.BusConnect();
-
             if (!AZ::IO::LocalFileIO::GetInstance()->Remove(deletePath.c_str()))
             {
-                m_fileIoErrorHandler.ReportLatestIOError(AZStd::string::format("Failed to delete '%s'.", deletePath.c_str()));
+                AZ_Error("MaterialHotReloadTestComponent", false, "Failed to delete '%s'.", deletePath.c_str());
             }
-
-            m_fileIoErrorHandler.BusDisconnect();
         }
     }
 
@@ -232,23 +228,19 @@ namespace AtomSampleViewer
         AZ::IO::Path copyFrom = AZ::IO::Path(m_testDataFolder).Append(testDataFile);
         AZ::IO::Path copyTo = AZ::IO::Path(m_tempSourceFolder).Append(tempSourceFile);
 
-        m_fileIoErrorHandler.BusConnect();
-
         auto readResult = AZ::Utils::ReadFile(copyFrom.c_str());
         if (!readResult.IsSuccess())
         {
-            m_fileIoErrorHandler.ReportLatestIOError(readResult.GetError());
+            AZ_Error("MaterialHotReloadTestComponent", false, "%s", readResult.GetError().c_str());
             return;
         }
 
         auto writeResult = AZ::Utils::WriteFile(readResult.GetValue(), copyTo.c_str());
         if (!writeResult.IsSuccess())
         {
-            m_fileIoErrorHandler.ReportLatestIOError(writeResult.GetError());
+            AZ_Error("MaterialHotReloadTestComponent", false, "%s", writeResult.GetError().c_str());
             return;
         }
-
-        m_fileIoErrorHandler.BusDisconnect();
     }
 
     const char* ToString(AzFramework::AssetSystem::AssetStatus status)

+ 0 - 3
Gem/Code/Source/MaterialHotReloadTestComponent.h

@@ -10,7 +10,6 @@
 
 #include <CommonSampleComponentBase.h>
 #include <Utils/ImGuiSidebar.h>
-#include <Utils/FileIOErrorHandler.h>
 #include <AzCore/Component/TickBus.h>
 #include <Atom/RPI.Reflect/Material/MaterialAsset.h>
 #include <Atom/RPI.Reflect/Model/ModelAsset.h>
@@ -108,8 +107,6 @@ namespace AtomSampleViewer
         AZ::Data::Instance<AZ::RPI::Material> m_shaderVariantIndicatorMaterial_fullyBaked;
         AZ::Data::Instance<AZ::RPI::Material>  m_shaderVariantIndicatorMaterial_current;
 
-        FileIOErrorHandler m_fileIoErrorHandler;
-
         float m_clearAssetsTimeout = 0.0f;
     };
 } // namespace AtomSampleViewer

+ 0 - 1
Gem/Code/Source/RHI/BindlessPrototypeExampleComponent.cpp

@@ -20,7 +20,6 @@
 #include <AzCore/Math/MatrixUtils.h>
 
 #include <AzCore/Component/Entity.h>
-#include <AzCore/Debug/EventTrace.h>
 
 #include <AzFramework/Components/CameraBus.h>
 

+ 3 - 11
Gem/Code/Source/ShaderReloadTestComponent.cpp

@@ -91,23 +91,19 @@ namespace AtomSampleViewer
         AZ::IO::Path copyFrom = AZ::IO::Path(originalFilePath);
         AZ::IO::Path copyTo = AZ::IO::Path(newFilePath);
 
-        m_fileIoErrorHandler.BusConnect();
-
         auto readResult = AZ::Utils::ReadFile(copyFrom.c_str());
         if (!readResult.IsSuccess())
         {
-            m_fileIoErrorHandler.ReportLatestIOError(readResult.GetError());
+            AZ_Error("MaterialHotReloadTestComponent", false, "%s", readResult.GetError().c_str());
             return;
         }
 
         auto writeResult = AZ::Utils::WriteFile(readResult.GetValue(), copyTo.c_str());
         if (!writeResult.IsSuccess())
         {
-            m_fileIoErrorHandler.ReportLatestIOError(writeResult.GetError());
+            AZ_Error("MaterialHotReloadTestComponent", false, "%s", writeResult.GetError().c_str());
             return;
         }
-
-        m_fileIoErrorHandler.BusDisconnect();
     }
 
     void ShaderReloadTestComponent::DeleteTestFile(const char* tempSourceFile)
@@ -116,14 +112,10 @@ namespace AtomSampleViewer
 
         if (AZ::IO::LocalFileIO::GetInstance()->Exists(deletePath.c_str()))
         {
-            m_fileIoErrorHandler.BusConnect();
-
             if (!AZ::IO::LocalFileIO::GetInstance()->Remove(deletePath.c_str()))
             {
-                m_fileIoErrorHandler.ReportLatestIOError(AZStd::string::format("Failed to delete '%s'.", deletePath.c_str()));
+                AZ_Error("MaterialHotReloadTestComponent", false, "Failed to delete '%s'.", deletePath.c_str());
             }
-
-            m_fileIoErrorHandler.BusDisconnect();
         }
     }
 

+ 0 - 3
Gem/Code/Source/ShaderReloadTestComponent.h

@@ -21,7 +21,6 @@
 
 #include <Utils/ImGuiSidebar.h>
 #include <Utils/Utils.h>
-#include <Utils/FileIOErrorHandler.h>
 
 namespace AtomSampleViewer
 {
@@ -88,8 +87,6 @@ namespace AtomSampleViewer
         // render output capture and validation.
         void ValidatePixelColor(uint32_t color);
 
-        FileIOErrorHandler m_fileIoErrorHandler;
-
         //! Async asset load. Used to guarantee that "Fullscreen.azshader" exists before
         //! instantiating the FullscreenTriangle.pass.
         AZ::AssetCollectionAsyncLoader m_assetLoadManager;

+ 0 - 42
Gem/Code/Source/Utils/FileIOErrorHandler.cpp

@@ -1,42 +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
- *
- */
-
-#include <Utils/FileIOErrorHandler.h>
-
-namespace AtomSampleViewer
-{
-    void FileIOErrorHandler::OnError([[maybe_unused]] const AZ::IO::SystemFile* file, [[maybe_unused]] const char* fileName, int errorCode)
-    {
-        m_ioErrorCode = errorCode;
-    }
-
-    void FileIOErrorHandler::BusConnect()
-    {
-        Base::BusConnect();
-        m_ioErrorCode = ErrorCodeNotSet;
-    }
-
-    void FileIOErrorHandler::ReportLatestIOError(AZStd::string message)
-    {
-        AZ_Assert(BusIsConnected(), "FileIOErrorHandler must be connected while calling ReportLatestIOError");
-
-        if (m_ioErrorCode != ErrorCodeNotSet)
-        {
-            message += AZStd::string::format(" IO error code %d.", m_ioErrorCode);
-        }
-
-        AZ_Error("FileIOErrorHandler", false, "%s", message.c_str());
-    }
-
-    void FileIOErrorHandler::BusDisconnect()
-    {
-        Base::BusDisconnect();
-        m_ioErrorCode = ErrorCodeNotSet;
-    }
-
-} // namespace AtomSampleViewer

+ 0 - 40
Gem/Code/Source/Utils/FileIOErrorHandler.h

@@ -1,40 +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
- *
- */
-
-#pragma once
-
-#include <AzCore/IO/FileIOEventBus.h>
-#include <AzCore/std/string/string.h>
-
-namespace AtomSampleViewer
-{
-    //! Use this to report AZ::IO errors and include the OS error code in the message.
-    //! The general pattern is to call:
-    //!     FileIOErrorHandler::BusConnect()
-    //!     if(!someAzIoOperation())
-    //!         FileIOErrorHandler::ReportLatestIOError(myMessage)
-    //!     FileIOErrorHandler::BusDisconnect()
-    class FileIOErrorHandler
-        : public AZ::IO::FileIOEventBus::Handler
-    {
-        using Base = AZ::IO::FileIOEventBus::Handler;
-    public:
-
-        void BusConnect(); //!< Also resets m_ioErrorCode
-        void ReportLatestIOError(AZStd::string message);
-        void BusDisconnect(); //!< Also resets m_ioErrorCode
-
-    private:
-
-        // AZ::IO::FileIOEventBus::Handler overrides...
-        void OnError(const AZ::IO::SystemFile* file, const char* fileName, int errorCode) override;
-
-        static constexpr int ErrorCodeNotSet = -1;
-        int m_ioErrorCode = ErrorCodeNotSet;
-    };
-} // namespace AtomSampleViewer

+ 0 - 2
Gem/Code/atomsampleviewergem_private_files.cmake

@@ -171,8 +171,6 @@ set(FILES
     Source/TransparencyExampleComponent.h
     Source/ShaderReloadTestComponent.cpp
     Source/ShaderReloadTestComponent.h
-    Source/Utils/FileIOErrorHandler.cpp
-    Source/Utils/FileIOErrorHandler.h
     Source/Utils/ImGuiAssetBrowser.cpp
     Source/Utils/ImGuiAssetBrowser.h
     Source/Utils/ImGuiHistogramQueue.cpp

+ 0 - 3
Standalone/Platform/Common/AtomSampleViewerApplication.cpp

@@ -21,9 +21,6 @@
 #include <AzFramework/Network/AssetProcessorConnection.h>
 #include <AzFramework/StringFunc/StringFunc.h>
 
-#include <GridMate/Drillers/CarrierDriller.h>
-#include <GridMate/Drillers/ReplicaDriller.h>
-
 #include <Atom/RPI.Public/RPISystemInterface.h>
 #include <AzCore/Math/Random.h>
 #include <AzCore/Script/ScriptAsset.h>

+ 13 - 0
cmake/CompilerSettings.cmake

@@ -0,0 +1,13 @@
+#
+# 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
+#
+#
+
+# File to tweak compiler settings before compiler detection happens (before project() is called)
+# We dont have PAL enabled at this point, so we can only use pure-CMake variables
+if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
+    include(cmake/Platform/Linux/CompilerSettings_linux.cmake)
+endif()

+ 33 - 8
EngineFinder.cmake → cmake/EngineFinder.cmake

@@ -11,10 +11,27 @@
 include_guard()
 
 # Read the engine name from the project_json file
-file(READ ${CMAKE_CURRENT_LIST_DIR}/project.json project_json)
+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', error: ${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})
@@ -23,43 +40,51 @@ 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}', error: ${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, error: ${json_error}")
+        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}', error: ${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}', error: ${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")
-                break()
+                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 "Engine registration is required before configuring a project.  Please register an engine by running 'scripts/o3de register --this-engine'")
+        message(FATAL_ERROR "O3DE Manifest file not found.\n${registration_error}")
     endif()
 endif()

+ 34 - 0
cmake/Platform/Linux/CompilerSettings.cmake

@@ -0,0 +1,34 @@
+#
+# 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
+#
+#
+
+if(NOT CMAKE_C_COMPILER AND NOT CMAKE_CXX_COMPILER)
+    set(path_search
+        /bin
+        /usr/bin
+        /usr/local/bin
+        /sbin
+        /usr/sbin
+        /usr/local/sbin
+    )
+    list(TRANSFORM path_search APPEND "/clang-[0-9]*")
+    file(GLOB clang_versions ${path_search})
+    if(clang_versions)
+        # Find and pick the highest installed version
+        list(SORT clang_versions COMPARE NATURAL)
+        list(GET clang_versions 0 clang_higher_version_path)
+        string(REGEX MATCH "clang-([0-9.]*)" clang_higher_version ${clang_higher_version_path})
+        if(CMAKE_MATCH_1)
+            set(CMAKE_C_COMPILER clang-${CMAKE_MATCH_1})
+            set(CMAKE_CXX_COMPILER clang++-${CMAKE_MATCH_1})
+        else()
+            message(FATAL_ERROR "Clang not found, please install clang")
+        endif()
+    else()
+        message(FATAL_ERROR "Clang not found, please install clang")
+    endif()
+endif()

+ 34 - 0
cmake/Platform/Linux/CompilerSettings_linux.cmake

@@ -0,0 +1,34 @@
+#
+# 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
+#
+#
+
+if(NOT CMAKE_C_COMPILER AND NOT CMAKE_CXX_COMPILER AND NOT "$ENV{CC}" AND NOT "$ENV{CXX}")
+    set(path_search
+        /bin
+        /usr/bin
+        /usr/local/bin
+        /sbin
+        /usr/sbin
+        /usr/local/sbin
+    )
+    list(TRANSFORM path_search APPEND "/clang-[0-9]*")
+    file(GLOB clang_versions ${path_search})
+    if(clang_versions)
+        # Find and pick the highest installed version
+        list(SORT clang_versions COMPARE NATURAL)
+        list(GET clang_versions 0 clang_higher_version_path)
+        string(REGEX MATCH "clang-([0-9.]*)" clang_higher_version ${clang_higher_version_path})
+        if(CMAKE_MATCH_1)
+            set(CMAKE_C_COMPILER clang-${CMAKE_MATCH_1})
+            set(CMAKE_CXX_COMPILER clang++-${CMAKE_MATCH_1})
+        else()
+            message(FATAL_ERROR "Clang not found, please install clang")
+        endif()
+    else()
+        message(FATAL_ERROR "Clang not found, please install clang")
+    endif()
+endif()