2020-12-12 10:33:30 +08:00
|
|
|
set(gtest_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
|
2020-03-27 14:49:12 +08:00
|
|
|
set(gtest_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
|
2020-10-14 19:35:13 +08:00
|
|
|
|
2020-12-12 10:33:30 +08:00
|
|
|
set(CMAKE_OPTION
|
|
|
|
-DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON
|
|
|
|
-DCMAKE_MACOSX_RPATH=TRUE -Dgtest_disable_pthreads=ON)
|
2021-01-23 20:20:31 +08:00
|
|
|
if(BUILD_LITE)
|
|
|
|
if(PLATFORM_ARM64)
|
2020-12-12 10:33:30 +08:00
|
|
|
set(CMAKE_OPTION -DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake
|
|
|
|
-DANDROID_NATIVE_API_LEVEL=19
|
|
|
|
-DANDROID_NDK=$ENV{ANDROID_NDK}
|
|
|
|
-DANDROID_ABI=arm64-v8a
|
|
|
|
-DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang
|
2021-03-12 17:42:00 +08:00
|
|
|
-DANDROID_STL=${ANDROID_STL}
|
2020-12-12 10:33:30 +08:00
|
|
|
${CMAKE_OPTION})
|
|
|
|
endif()
|
2021-01-23 20:20:31 +08:00
|
|
|
if(PLATFORM_ARM32)
|
2020-12-12 10:33:30 +08:00
|
|
|
set(CMAKE_OPTION -DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake
|
|
|
|
-DANDROID_NATIVE_API_LEVEL=19
|
|
|
|
-DANDROID_NDK=$ENV{ANDROID_NDK}
|
|
|
|
-DANDROID_ABI=armeabi-v7a
|
|
|
|
-DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang
|
2021-03-12 17:42:00 +08:00
|
|
|
-DANDROID_STL=${ANDROID_STL}
|
2020-12-12 10:33:30 +08:00
|
|
|
${CMAKE_OPTION})
|
|
|
|
endif()
|
2022-01-10 20:49:57 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT ENABLE_GLIBCXX)
|
|
|
|
set(gtest_CXXFLAGS "${gtest_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
|
2021-01-23 20:20:31 +08:00
|
|
|
endif()
|
2020-12-12 10:33:30 +08:00
|
|
|
|
2021-01-23 20:20:31 +08:00
|
|
|
if(ENABLE_GITEE)
|
2021-02-19 16:20:39 +08:00
|
|
|
set(REQ_URL "https://gitee.com/mirrors/googletest/repository/archive/release-1.8.1.tar.gz")
|
2022-11-02 17:39:06 +08:00
|
|
|
set(SHA256 "9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c")
|
2020-10-14 19:35:13 +08:00
|
|
|
else()
|
2021-02-19 16:20:39 +08:00
|
|
|
set(REQ_URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz")
|
2022-11-02 17:39:06 +08:00
|
|
|
set(SHA256 "9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c")
|
2021-01-23 20:20:31 +08:00
|
|
|
endif()
|
2020-10-14 19:35:13 +08:00
|
|
|
|
2020-03-27 14:49:12 +08:00
|
|
|
mindspore_add_pkg(gtest
|
2021-02-19 16:20:39 +08:00
|
|
|
VER 1.8.1
|
2021-06-30 15:59:40 +08:00
|
|
|
LIBS gtest gmock
|
2020-10-14 19:35:13 +08:00
|
|
|
URL ${REQ_URL}
|
2022-11-02 17:39:06 +08:00
|
|
|
SHA256 ${SHA256}
|
2020-12-12 10:33:30 +08:00
|
|
|
CMAKE_OPTION ${CMAKE_OPTION})
|
2020-03-27 14:49:12 +08:00
|
|
|
include_directories(${gtest_INC})
|
|
|
|
add_library(mindspore::gtest ALIAS gtest::gtest)
|
2021-06-30 15:59:40 +08:00
|
|
|
add_library(mindspore::gmock ALIAS gtest::gmock)
|
2021-02-19 16:20:39 +08:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
|
|
file(COPY ${gtest_DIRPATH}/bin/libgtest${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
|
|
|
|
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
|
|
|
|
file(COPY ${gtest_DIRPATH}/bin/libgtest_main${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
|
|
|
|
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
|
2021-09-26 18:44:01 +08:00
|
|
|
file(COPY ${gtest_DIRPATH}/bin/libgmock_main${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
|
|
|
|
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
|
|
|
|
file(COPY ${gtest_DIRPATH}/bin/libgmock${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
|
|
|
|
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
|
2021-02-19 16:20:39 +08:00
|
|
|
else()
|
|
|
|
file(COPY ${gtest_LIBPATH}/libgtest${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
|
|
|
|
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
|
|
|
|
file(COPY ${gtest_LIBPATH}/libgtest_main${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
|
|
|
|
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
|
2021-09-26 18:44:01 +08:00
|
|
|
file(COPY ${gtest_LIBPATH}/libgmock${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
|
|
|
|
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
|
|
|
|
file(COPY ${gtest_LIBPATH}/libgmock_main${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
|
|
|
|
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
|
|
|
|
endif()
|