12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #
- # Copyright (c) Contributors to the Open 3D Engine Project.
- # For complete copyright and license terms please see the LICENSE at the root of this distribution.
- #
- # SPDX-License-Identifier: Apache-2.0 OR MIT
- #
- #
- if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
- set(GOOGLETEST_GIT_REPOSITORY "https://github.com/google/googletest.git")
- set(GOOGLETEST_GIT_TAG 2fe3bd994b3189899d93f1d5a881e725e046fdc2) # release-1.8.1
- set(GOOGLETEST_VERSION_STRING "release-1.8.1")
- o3de_pal_dir(pal_aztest_dir ${CMAKE_CURRENT_LIST_DIR}/AzTest/Platform/${PAL_PLATFORM_NAME} ${O3DE_ENGINE_RESTRICTED_PATH} ${LY_ROOT_FOLDER})
- set(CMAKE_POLICY_DEFAULT_CMP0148 OLD)
- set(OLD_CMAKE_WARN_DEPRECATED ${CMAKE_WARN_DEPRECATED})
- set(CMAKE_WARN_DEPRECATED FALSE CACHE BOOL "" FORCE)
- include(FetchContent)
- message(STATUS "Using googletest from ${GOOGLETEST_GIT_REPOSITORY} ${GOOGLETEST_VERSION_STRING}")
- FetchContent_Declare(
- googletest
- GIT_REPOSITORY ${GOOGLETEST_GIT_REPOSITORY}
- GIT_TAG ${GOOGLETEST_GIT_TAG}
- CMAKE_ARGS "-DCMAKE_WARN_DEPRECATED=FALSE;-Dgtest_force_shared_crt=ON;-DBUILD_GMOCK=ON;-DBUILD_GTEST=ON;-DINSTALL_GTEST=OFF;-Dgmock_build_tests=OFF;-Dgtest_build_tests=OFF;-Dgtest_build_samples=OFF;-Dgtest_hide_internal_symbols=ON"
- )
-
- set(PYTHONINTERP_FOUND ON)
- set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
- set(PYTHON_VERSION_STRING ${Python_VERSION})
- FetchContent_MakeAvailable(googletest)
- unset(CMAKE_POLICY_DEFAULT_CMP0148)
- set(CMAKE_WARN_DEPRECATED ${OLD_CMAKE_WARN_DEPRECATED} CACHE BOOL "" FORCE)
- ly_create_alias(NAME googletest::GTest NAMESPACE 3rdParty TARGETS gtest)
- ly_create_alias(NAME googletest::GMock NAMESPACE 3rdParty TARGETS gmock)
- ly_add_target(
- NAME AzTest STATIC
- NAMESPACE AZ
- FILES_CMAKE
- AzTest/aztest_files.cmake
- ${pal_aztest_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
- INCLUDE_DIRECTORIES
- PUBLIC
- .
- ${pal_aztest_dir}
- BUILD_DEPENDENCIES
- PUBLIC
- 3rdParty::googletest::GMock
- 3rdParty::googletest::GTest
- 3rdParty::GoogleBenchmark
- AZ::AzCore
- PLATFORM_INCLUDE_FILES
- ${pal_aztest_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
- )
- # Maintainers, please note that when building O3DE from source, this entire script file you are looking at right now
- # will execute during configure. However, only the below literal block between the [[ and ]] below will
- # be included in the built installer, the rest of this file will not be, the above targets will be synthesized
- # as if they were prebuilt libraries (For example, the AzTest library declared above will instead be autogenerated in its
- # own file as if it were a STATIC IMPORTED GLOBAL target instead of a built-from-source-code target).
- # This means that the below block must declare all necessary 3rd Party libraries fetched and built by fetchcontent,
- # and cannot refer to variables from the rest of this script file - only the snippet below will exist, and must be self-contained.
- # Export external googletest targets for installers.
- set_property(DIRECTORY APPEND PROPERTY O3DE_SUBDIRECTORY_INSTALL_CODE [[
- add_library(gtest STATIC IMPORTED GLOBAL)
- set_target_properties(gtest PROPERTIES IMPORTED_LOCATION "${LY_ROOT_FOLDER}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}")
- ly_target_include_system_directories(TARGET gtest INTERFACE "${LY_ROOT_FOLDER}/include/gtest")
-
- add_library(gmock STATIC IMPORTED GLOBAL)
- set_target_properties(gmock PROPERTIES IMPORTED_LOCATION "${LY_ROOT_FOLDER}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX}")
- ly_target_include_system_directories(TARGET gmock INTERFACE "${LY_ROOT_FOLDER}/include/gmock")
-
- ly_create_alias(NAME googletest::GTest NAMESPACE 3rdParty TARGETS gtest)
- ly_create_alias(NAME googletest::GMock NAMESPACE 3rdParty TARGETS gmock)
- ]]
- )
- endif()
|