2
0

CMakeLists.txt 1.8 KB

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