CMakeLists.txt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #! Adds the --project-path argument to the VS IDE debugger command arguments
  2. function(add_vs_debugger_arguments)
  3. # Inject the project root into the --project-path argument into the Visual Studio Debugger arguments by defaults
  4. list(APPEND app_targets LoftSample.GameLauncher LoftSample.ServerLauncher)
  5. list(APPEND app_targets AssetBuilder AssetProcessor AssetProcessorBatch Editor)
  6. foreach(app_target IN LISTS app_targets)
  7. if (TARGET ${app_target})
  8. set_property(TARGET ${app_target} APPEND PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS "--project-path=\"${CMAKE_CURRENT_LIST_DIR}\"")
  9. endif()
  10. endforeach()
  11. endfunction()
  12. if(NOT PROJECT_NAME)
  13. cmake_minimum_required(VERSION 3.19)
  14. project(LoftSample
  15. LANGUAGES C CXX
  16. VERSION 1.0.0.0
  17. )
  18. include(EngineFinder.cmake OPTIONAL)
  19. find_package(o3de REQUIRED)
  20. o3de_initialize()
  21. add_vs_debugger_arguments()
  22. else()
  23. # Add the project_name to global LY_PROJECTS_TARGET_NAME property
  24. file(READ "${CMAKE_CURRENT_LIST_DIR}/project.json" project_json)
  25. string(JSON project_target_name ERROR_VARIABLE json_error GET ${project_json} "project_name")
  26. if(json_error)
  27. message(FATAL_ERROR "Unable to read key 'project_name' from 'project.json'")
  28. endif()
  29. set_property(GLOBAL APPEND PROPERTY LY_PROJECTS_TARGET_NAME ${project_target_name})
  30. add_subdirectory(Code)
  31. endif()