CMakeLists.txt 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 PAL_TRAIT_BUILD_HOST_TOOLS)
  9. return()
  10. endif()
  11. ly_add_target(
  12. NAME PythonBindingsExample.Static STATIC
  13. NAMESPACE AZ
  14. FILES_CMAKE
  15. pythonbindingsexample_files.cmake
  16. PLATFORM_INCLUDE_FILES
  17. source/Platform/Common/${PAL_TRAIT_COMPILER_ID}/pythonbindingsexample_${PAL_TRAIT_COMPILER_ID_LOWERCASE}.cmake
  18. INCLUDE_DIRECTORIES
  19. PRIVATE
  20. .
  21. BUILD_DEPENDENCIES
  22. PRIVATE
  23. AZ::AzCore
  24. AZ::AzFramework
  25. AZ::AzToolsFramework
  26. )
  27. ly_add_target(
  28. NAME PythonBindingsExample EXECUTABLE
  29. NAMESPACE AZ
  30. FILES_CMAKE
  31. pythonbindingsexample_app_files.cmake
  32. INCLUDE_DIRECTORIES
  33. PRIVATE
  34. .
  35. BUILD_DEPENDENCIES
  36. PRIVATE
  37. AZ::AzCore
  38. AZ::AzFramework
  39. AZ::AzToolsFramework
  40. PythonBindingsExample.Static
  41. )
  42. # The PythonBindingsExample application isn't really an LY_PROJECT,
  43. # It's target name is being used to tag the tool_dependencies
  44. # This allows both the PythonBindingsExample and PythonBindingsExample.Tests applications
  45. # to load the generated cmake_dependencies.PythonBindingsExample.PythonBindingsExample.setreg file
  46. # which contains the list of gem dependencies
  47. ly_add_target_dependencies(
  48. TARGETS
  49. PythonBindingsExample
  50. DEPENDENCIES_FILES
  51. tool_dependencies.cmake
  52. )
  53. # Adds the PythonBindingsExample as a C preprocessor define so that it can be used as a Settings Registry
  54. # specialization in order to look up the generated .setreg which contains the dependencies
  55. # specified for the target
  56. if(TARGET PythonBindingsExample)
  57. set_source_files_properties(
  58. source/main.cpp
  59. PROPERTIES
  60. COMPILE_DEFINITIONS
  61. LY_CMAKE_TARGET="PythonBindingsExample"
  62. )
  63. else()
  64. message(FATAL_ERROR "Cannot set LY_CMAKE_TARGET define to PythonBindingsExample as the target doesn't exist anymore."
  65. " Perhaps it has been renamed")
  66. endif()
  67. if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
  68. ly_add_target(
  69. NAME PythonBindingsExample.Tests EXECUTABLE
  70. NAMESPACE AZ
  71. FILES_CMAKE
  72. pythonbindingsexample_tests_files.cmake
  73. INCLUDE_DIRECTORIES
  74. PRIVATE
  75. .
  76. BUILD_DEPENDENCIES
  77. PRIVATE
  78. AZ::AzCore
  79. AZ::AzFramework
  80. AZ::AzTest
  81. AZ::AzToolsFramework
  82. PythonBindingsExample.Static
  83. )
  84. ly_add_target_dependencies(
  85. TARGETS
  86. PythonBindingsExample.Tests
  87. DEPENDENCIES_FILES
  88. tool_dependencies.cmake
  89. )
  90. if(TARGET PythonBindingsExample)
  91. set_source_files_properties(
  92. tests/ApplicationTests.cpp
  93. PROPERTIES
  94. COMPILE_DEFINITIONS
  95. # The PythonBindingsExample target is being defined here to allow the PythonBindingsExample.Tests executable
  96. # to load the specializations which contains the "PythonBindingsExample" value'
  97. LY_CMAKE_TARGET="PythonBindingsExample"
  98. )
  99. else()
  100. message(FATAL_ERROR "Cannot set LY_CMAKE_TARGET define to PythonBindingsExample as the target doesn't exist anymore."
  101. " Perhaps it has been renamed")
  102. endif()
  103. ly_add_googletest(
  104. NAME AZ::PythonBindingsExample.Tests
  105. LABELS REQUIRES_tiaf
  106. TEST_COMMAND $<TARGET_FILE:AZ::PythonBindingsExample.Tests> --unittest
  107. )
  108. endif()