Findgoogletest.cmake 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 (TARGET 3rdParty::googletest::GTest)
  9. return()
  10. endif()
  11. if (TARGET 3rdParty::googletest::GMock)
  12. return()
  13. endif()
  14. # You should not be generating dependencies on googletest (via AzTest)
  15. # if you are on a platform that cannot actually compile googletest (See cmake/Platform/platformname/PAL_platformname.cmake)
  16. if (NOT PAL_TRAIT_TEST_GOOGLE_TEST_SUPPORTED)
  17. return()
  18. endif()
  19. # This file is run when in pre-built installer mode, and thus GTest and GMock are pre-built static libraries
  20. # ALWAYS DISCLOSE THE USE OF 3rd Party Libraries. Even if they are internally linked.
  21. message(STATUS "AzTest library uses googletest v1.15.2 (BSD-3-Clause) from https://github.com/google/googletest.git")
  22. set(BASE_LIBRARY_FOLDER "${LY_ROOT_FOLDER}/lib/${PAL_PLATFORM_NAME}")
  23. add_library(gtest STATIC IMPORTED GLOBAL)
  24. set_target_properties(gtest PROPERTIES
  25. IMPORTED_LOCATION "${BASE_LIBRARY_FOLDER}/profile/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}"
  26. IMPORTED_LOCATION_DEBUG "${BASE_LIBRARY_FOLDER}/debug/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}")
  27. ly_target_include_system_directories(TARGET gtest INTERFACE "${LY_ROOT_FOLDER}/include/gmock_gtest")
  28. add_library(gmock STATIC IMPORTED GLOBAL)
  29. set_target_properties(gmock PROPERTIES
  30. IMPORTED_LOCATION "${BASE_LIBRARY_FOLDER}/profile/${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX}"
  31. IMPORTED_LOCATION_DEBUG "${BASE_LIBRARY_FOLDER}/debug/${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX}")
  32. ly_target_include_system_directories(TARGET gmock INTERFACE "${LY_ROOT_FOLDER}/include/gmock_gtest")
  33. add_library(3rdParty::googletest::GTest ALIAS gtest)
  34. add_library(3rdParty::googletest::GMock ALIAS gmock)
  35. set(googletest_FOUND TRUE)