CMakeLists.txt 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. # Cmake version 3.17 is the minimum version needed for all of lumberyard's supported platforms
  12. cmake_minimum_required(VERSION 3.17)
  13. # CMP0111 introduced in 3.19 has a bug that produces the policy to warn every time there is an
  14. # INTERFACE IMPORTED library. We use this type of libraries for handling 3rdParty. The rest of
  15. # the documentation states that INTERFACE IMPORTED libraries do not require to set locations, but
  16. # the policy still warns about it. Issue: https://gitlab.kitware.com/cmake/cmake/-/issues/21470
  17. # The issue was fixed in 3.19.1 so we just disable the policy for 3.19
  18. if(CMAKE_VERSION VERSION_EQUAL 3.19)
  19. cmake_policy(SET CMP0111 OLD)
  20. endif()
  21. project(Lumberyard LANGUAGES C CXX)
  22. # Turn on the ability to create folders to organize projects (.vcproj)
  23. # It creates "CMakePredefinedTargets" folder by default and adds CMake
  24. # defined projects like INSTALL.vcproj and ZERO_CHECK.vcproj
  25. set_property(GLOBAL PROPERTY USE_FOLDERS ON)
  26. set(CMAKE_WARN_DEPRECATED ON)
  27. # Set output directories
  28. set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib CACHE PATH "Build directory for static libraries and import libraries")
  29. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Build directory for shared libraries")
  30. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Build directory for executables")
  31. set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "Installation prefix")
  32. include(cmake/FileUtil.cmake)
  33. include(cmake/PAL.cmake)
  34. include(cmake/PALTools.cmake)
  35. include(cmake/Configurations.cmake) # Requires to be after PAL so we get platform variable definitions
  36. include(cmake/Dependencies.cmake)
  37. include(cmake/Deployment.cmake)
  38. include(cmake/3rdParty.cmake)
  39. include(cmake/LYPython.cmake)
  40. include(cmake/LYWrappers.cmake)
  41. include(cmake/UnitTest.cmake)
  42. include(cmake/LYTestWrappers.cmake)
  43. include(cmake/Version.cmake)
  44. include(cmake/Monolithic.cmake)
  45. include(cmake/SettingsRegistry.cmake)
  46. include(cmake/TestImpactFramework/LYTestImpactFramework.cmake)
  47. list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
  48. # Add all cmake files in a project so they can be handled from within the IDE
  49. ly_include_cmake_file_list(cmake/cmake_files.cmake)
  50. add_custom_target(CMakeFiles SOURCES ${ALLFILES})
  51. ly_source_groups_from_folders("${ALLFILES}")
  52. unset(ALLFILES)
  53. # Add the projects first so the Launcher can find them
  54. include(cmake/Projects.cmake)
  55. # Add the rest of the targets
  56. add_subdirectory(Code)
  57. add_subdirectory(Gems)
  58. set(enabled_platforms
  59. ${PAL_PLATFORM_NAME}
  60. ${LY_PAL_TOOLS_ENABLED})
  61. foreach(restricted_platform ${PAL_RESTRICTED_PLATFORMS})
  62. if(restricted_platform IN_LIST enabled_platforms)
  63. add_subdirectory(restricted/${restricted_platform})
  64. endif()
  65. endforeach()
  66. # The following steps have to be done after all targets were registered:
  67. # 1. link targets where the dependency was yet not declared, we need to have the declaration so we do different
  68. # linking logic depending on the type of target
  69. ly_delayed_target_link_libraries()
  70. # 2. generate a settings registry .setreg file for all ly_add_project_dependencies() and ly_add_target_dependencies() calls
  71. # to provide applications with the filenames of gem modules to load
  72. ly_delayed_generate_settings_registry()
  73. # 3. generate a registry file for unit testing for platforms that support unit testing
  74. if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
  75. ly_delayed_generate_unit_test_module_registry()
  76. endif()
  77. # 4. inject runtime dependencies to the targets. We need to do this after (1) since we are going to walk through
  78. # the dependencies
  79. include(cmake/RuntimeDependencies.cmake)
  80. ################################################################################
  81. # Tests
  82. ################################################################################
  83. # Recurse into directory of general python test scripts
  84. # specific python test registration can be specified within the CMakeLists.txt that is associated with the test(i.e Gem/<Foo>/CMakeLists.txt)
  85. add_subdirectory(ctest_scripts)
  86. if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/CMakeLists.txt")
  87. add_subdirectory(scripts)
  88. endif()
  89. # SPEC-1417 will investigate and fix this
  90. if(NOT PAL_PLATFORM_NAME STREQUAL "Mac")
  91. add_subdirectory(Tools/LyTestTools/tests/)
  92. add_subdirectory(Tools/RemoteConsole/ly_remote_console/tests/)
  93. endif()
  94. ################################################################################
  95. # Test Impact Framework
  96. ################################################################################
  97. # Perform test impact framework post steps once all of the targets have been enumerated
  98. ly_test_impact_post_step()