CMakeLists.txt 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #
  2. # All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
  3. # its licensors.
  4. #
  5. # For complete copyright and license terms please see the LICENSE at the root of this
  6. # distribution (the "License"). All use of this software is governed by the License,
  7. # or, if provided, by the license below or the license accompanying this file. Do not
  8. # remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
  9. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. #
  11. #! Adds the --project-path argument to the VS IDE debugger command arguments
  12. function(add_vs_debugger_arguments)
  13. # Inject the project root into the --project-path argument into the Visual Studio Debugger arguments by defaults
  14. list(APPEND app_targets MultiplayerSample.GameLauncher MultiplayerSample.ServerLauncher)
  15. list(APPEND app_targets AssetBuilder AssetProcessor AssetProcessorBatch Editor)
  16. foreach(app_target IN LISTS app_targets)
  17. if (TARGET ${app_target})
  18. set_property(TARGET ${app_target} APPEND PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS "--project-path=\"${CMAKE_CURRENT_LIST_DIR}\"")
  19. endif()
  20. endforeach()
  21. endfunction()
  22. if(NOT PROJECT_NAME)
  23. cmake_minimum_required(VERSION 3.19)
  24. project(MultiplayerSample
  25. LANGUAGES C CXX
  26. VERSION 1.0.0.0
  27. )
  28. include(EngineFinder.cmake OPTIONAL)
  29. find_package(o3de REQUIRED)
  30. o3de_initialize()
  31. add_vs_debugger_arguments()
  32. else()
  33. # Add the project_name to global LY_PROJECTS_TARGET_NAME property
  34. file(READ "${CMAKE_CURRENT_LIST_DIR}/project.json" project_json)
  35. string(JSON project_target_name ERROR_VARIABLE json_error GET ${project_json} "project_name")
  36. if(json_error)
  37. message(FATAL_ERROR "Unable to read key 'project_name' from 'project.json'")
  38. endif()
  39. set_property(GLOBAL APPEND PROPERTY LY_PROJECTS_TARGET_NAME ${project_target_name})
  40. add_subdirectory(Gem)
  41. endif()