diff --git a/CMakeLists.txt b/CMakeLists.txt index dbfb6a209d..96941f0d91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -278,7 +278,12 @@ function(install_windows_deps) COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/setup-buildtools.cmd) set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tools/vcpkg/scripts/buildsystems/vcpkg.cmake - PARENT_SCOPE) + CACHE FILEPATH "") + message( + "Make sure that vcpkg.cmake is set as the CMAKE_TOOLCHAIN_FILE at the START of the cmake build process! + Can be command-line arg (cmake -DCMAKE_TOOLCHAIN_FILE=...) or set in your editor of choice." + ) + endfunction() function(set_target_version target_name) @@ -548,9 +553,10 @@ if(BUILD_TESTING) ${CMAKE_BINARY_DIR}/lib/libgmock.a) elseif(WIN32) # Make sure we are always bootsrapped with vcpkg on Windows - find_package(GTest REQUIRED) + find_package(GTest) if(NOT (GTEST_FOUND OR GTest_FOUND)) install_windows_deps() + include(${CMAKE_TOOLCHAIN_FILE}) find_package(GTest REQUIRED) endif() else() diff --git a/test_common/src/http/client/nosend/CMakeLists.txt b/test_common/src/http/client/nosend/CMakeLists.txt index 071e109fe5..1f32861b41 100644 --- a/test_common/src/http/client/nosend/CMakeLists.txt +++ b/test_common/src/http/client/nosend/CMakeLists.txt @@ -28,7 +28,7 @@ if(${BUILD_TESTING}) endif() target_link_libraries( - opentelemetry_http_client_nosend ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIB} - opentelemetry_ext opentelemetry_test_common) + opentelemetry_http_client_nosend ${GTEST_BOTH_LIBRARIES} opentelemetry_ext + opentelemetry_test_common) endif() diff --git a/tools/setup-buildtools.cmd b/tools/setup-buildtools.cmd index 43be03a267..c9a9d9ca2b 100644 --- a/tools/setup-buildtools.cmd +++ b/tools/setup-buildtools.cmd @@ -9,6 +9,7 @@ if defined VCPKG_ROOT ( set "PATH=%VCPKG_ROOT%;%PATH%" ) else ( set "PATH=%~dp0vcpkg;%PATH%" + set "VCPKG_ROOT=%~dp0vcpkg" ) pushd %~dp0 @@ -53,9 +54,6 @@ where /Q vcpkg.exe if %ERRORLEVEL% == 1 ( REM Build our own vcpkg from source REM Prefer building in VCPKG_ROOT - if not defined VCPKG_ROOT ( - set "VCPKG_ROOT=%~dp0\vcpkg" - ) pushd "!VCPKG_ROOT!" call bootstrap-vcpkg.bat popd