vcpkg/ports/gtest/portfile.cmake
SvenPStarFinanz a07171a4cf
[gtest] Update to 1.11.0 (#18509)
* [gtest] Update to release version 1.11.0

* x-add-version

* Update ports/gtest/vcpkg.json

Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com>

* renewal of x-add-version.

Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com>
2021-06-21 13:44:04 -07:00

78 lines
3.4 KiB
CMake

if (EXISTS "${CURRENT_BUILDTREES_DIR}/src/.git")
file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/src)
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO google/googletest
REF release-1.11.0
SHA512 6fcc7827e4c4d95e3ae643dd65e6c4fc0e3d04e1778b84f6e06e390410fe3d18026c131d828d949d2f20dde6327d30ecee24dcd3ef919e21c91e010d149f3a28
HEAD_REF master
PATCHES
fix-main-lib-path.patch
)
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "dynamic" GTEST_FORCE_SHARED_CRT)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DBUILD_GMOCK=ON
-DBUILD_GTEST=ON
-DCMAKE_DEBUG_POSTFIX=d
-Dgtest_force_shared_crt=${GTEST_FORCE_SHARED_CRT}
)
vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/GTest TARGET_PATH share/GTest)
file(
INSTALL
"${SOURCE_PATH}/googletest/src/gtest.cc"
"${SOURCE_PATH}/googletest/src/gtest_main.cc"
"${SOURCE_PATH}/googletest/src/gtest-all.cc"
"${SOURCE_PATH}/googletest/src/gtest-death-test.cc"
"${SOURCE_PATH}/googletest/src/gtest-filepath.cc"
"${SOURCE_PATH}/googletest/src/gtest-internal-inl.h"
"${SOURCE_PATH}/googletest/src/gtest-matchers.cc"
"${SOURCE_PATH}/googletest/src/gtest-port.cc"
"${SOURCE_PATH}/googletest/src/gtest-printers.cc"
"${SOURCE_PATH}/googletest/src/gtest-test-part.cc"
"${SOURCE_PATH}/googletest/src/gtest-typed-test.cc"
DESTINATION
${CURRENT_PACKAGES_DIR}/src
)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
if(EXISTS ${CURRENT_PACKAGES_DIR}/debug/lib/gtest_maind.lib)
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/lib/manual-link)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/gtest_maind.lib ${CURRENT_PACKAGES_DIR}/debug/lib/manual-link/gtest_maind.lib)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/gmock_maind.lib ${CURRENT_PACKAGES_DIR}/debug/lib/manual-link/gmock_maind.lib)
file(READ ${CURRENT_PACKAGES_DIR}/share/gtest/GTestTargets-debug.cmake DEBUG_CONFIG)
string(REPLACE "\${_IMPORT_PREFIX}/debug/lib/gtest_maind.lib"
"\${_IMPORT_PREFIX}/debug/lib/manual-link/gtest_maind.lib" DEBUG_CONFIG "${DEBUG_CONFIG}")
string(REPLACE "\${_IMPORT_PREFIX}/debug/lib/gmock_maind.lib"
"\${_IMPORT_PREFIX}/debug/lib/manual-link/gmock_maind.lib" DEBUG_CONFIG "${DEBUG_CONFIG}")
file(WRITE ${CURRENT_PACKAGES_DIR}/share/gtest/GTestTargets-debug.cmake "${DEBUG_CONFIG}")
endif()
if(EXISTS ${CURRENT_PACKAGES_DIR}/lib/gtest_main.lib)
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/lib/manual-link)
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/gtest_main.lib ${CURRENT_PACKAGES_DIR}/lib/manual-link/gtest_main.lib)
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/gmock_main.lib ${CURRENT_PACKAGES_DIR}/lib/manual-link/gmock_main.lib)
file(READ ${CURRENT_PACKAGES_DIR}/share/gtest/GTestTargets-release.cmake RELEASE_CONFIG)
string(REPLACE "\${_IMPORT_PREFIX}/lib/gtest_main.lib"
"\${_IMPORT_PREFIX}/lib/manual-link/gtest_main.lib" RELEASE_CONFIG "${RELEASE_CONFIG}")
string(REPLACE "\${_IMPORT_PREFIX}/lib/gmock_main.lib"
"\${_IMPORT_PREFIX}/lib/manual-link/gmock_main.lib" RELEASE_CONFIG "${RELEASE_CONFIG}")
file(WRITE ${CURRENT_PACKAGES_DIR}/share/gtest/GTestTargets-release.cmake "${RELEASE_CONFIG}")
endif()
vcpkg_copy_pdbs()
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)