custom_google_test.cmake 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # {BEGIN_LICENSE}
  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. # {END_LICENSE}
  8. # Include this file in your Project/Gem/CMakeLists.txt using "include(Tests/custom_google_test.cmake)" at the end.
  9. # Add a cache variable or set -DDISABLE_GEM_TESTS=ON to disable tests for this gem
  10. # PAL_TRAIT_TEST_GOOGLE_TEST_SUPPORTED is defined in the O3DE CMake code and will be
  11. # FALSE if the current platform (like IOS for example) does not support Google Test
  12. if (NOT DISABLE_GEM_TESTS AND PAL_TRAIT_TEST_GOOGLE_TEST_SUPPORTED)
  13. # add the test cpp code (add new files in the _test_files.cmake file)
  14. ly_add_target(
  15. NAME ${gem_name}.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
  16. NAMESPACE Gem
  17. FILES_CMAKE
  18. ${CMAKE_CURRENT_LIST_DIR}/test_files.cmake
  19. BUILD_DEPENDENCIES
  20. PRIVATE
  21. AZ::AzTest
  22. )
  23. # Register the test so that it runs when you run ctest
  24. # eg, ctest -P <build-config> --test-dir <path-to-your-build-dir>
  25. # eg, ctest -P profile --test-dir build/windows
  26. # eg, ctest -P debug --test-dir build\linux
  27. ly_add_googletest(
  28. NAME Gem::${gem_name}.Tests
  29. # optional parameters:
  30. # TEST_SUITE "main" or "sandbox" or "smoke"
  31. # TARGET name of ly_target to run, if it does not match NAME of this test
  32. )
  33. endif()