CMakeLists.txt 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 PROJECT_NAME)
  9. cmake_minimum_required(VERSION 3.22)
  10. # Utility function to look for an optional 'engine_finder_cmake_path'setting
  11. function(get_engine_finder_cmake_path project_json_file_path path_value)
  12. if(NOT ${path_value} AND EXISTS "${project_json_file_path}")
  13. file(READ "${project_json_file_path}" project_json_data)
  14. string(JSON engine_finder_cmake_value ERROR_VARIABLE json_error GET ${project_json_data} "engine_finder_cmake_path")
  15. cmake_path(APPEND CMAKE_CURRENT_SOURCE_DIR "${engine_finder_cmake_value}" engine_finder_cmake_value)
  16. if(NOT json_error AND EXISTS "${engine_finder_cmake_value}")
  17. set(${path_value} "${engine_finder_cmake_value}" PARENT_SCOPE)
  18. elseif(json_error AND ${engine_finder_cmake_value} STREQUAL "NOTFOUND")
  19. # When the error value is just NOTFOUND that means there is a JSON
  20. # parsing error, and not simply a missing key
  21. message(WARNING "Unable to read 'engine_finder_cmake_path'.\nError: ${json_error} ${engine_finder_cmake_value}")
  22. endif()
  23. endif()
  24. endfunction()
  25. # Check for optional 'engine_finder_cmake_path' in order of preference
  26. # We support per-project customization to make it easier to upgrade
  27. # or revert to a custom EngineFinder.cmake
  28. get_engine_finder_cmake_path("${CMAKE_CURRENT_SOURCE_DIR}/user/project.json" engine_finder_cmake_path)
  29. get_engine_finder_cmake_path("${CMAKE_CURRENT_SOURCE_DIR}/project.json" engine_finder_cmake_path)
  30. if(NOT engine_finder_cmake_path)
  31. set(engine_finder_cmake_path cmake/EngineFinder.cmake)
  32. endif()
  33. include(${engine_finder_cmake_path} OPTIONAL)
  34. find_package(o3de REQUIRED)
  35. project(AutomatedTesting
  36. LANGUAGES C CXX
  37. VERSION 1.0.0.0
  38. )
  39. o3de_initialize()
  40. endif()