Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUILD] Fixing CMake to build GTest on Windows #1887

Merged
merged 25 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0d6e552
cmake breaks here because of the REQUIRED clause
bachittle Dec 22, 2022
492285c
Merge branch 'main' into cmake_win_fix
bachittle Jan 3, 2023
877e14c
Merge branch 'main' into cmake_win_fix
lalitb Jan 3, 2023
d9e8473
Merge branch 'cmake_win_fix' of https://github.com/bachittle/opentele…
bachittle Jan 3, 2023
070a675
playing around with vcpkg, got it working but all tests fail (most li…
bachittle Jan 3, 2023
1124c66
Merge branch 'main' into cmake_win_fix
ThomsonTan Jan 3, 2023
e3d8a79
cmake toolchain files can't be set inside cmakelists.txt, maybe at th…
bachittle Jan 4, 2023
22caf23
Merge branch 'cmake_win_fix' of https://github.com/bachittle/opentele…
bachittle Jan 4, 2023
62db735
Merge branch 'main' into cmake_win_fix
lalitb Jan 30, 2023
9cfdac7
Merge branch 'main' into cmake_win_fix
lalitb Jan 31, 2023
2839764
Merge branch 'main' into cmake_win_fix
ThomsonTan Feb 4, 2023
cbbd449
better inclusion of VCPKG_ROOT
bachittle Feb 6, 2023
f7de82c
fixed cmake formatting
bachittle Feb 6, 2023
531f726
Merge branch 'main' into cmake_win_fix
ThomsonTan Feb 6, 2023
8e62fe0
actually fix cmake format (ran the command)
bachittle Feb 6, 2023
f931327
Merge branch 'main' into cmake_win_fix
ThomsonTan Feb 9, 2023
57a0975
Merge branch 'main' into cmake_win_fix
ThomsonTan Feb 10, 2023
7b954d0
Merge branch 'main' into cmake_win_fix
ThomsonTan Feb 11, 2023
a2f4462
Merge branch 'main' into cmake_win_fix
ThomsonTan Feb 18, 2023
0a17a07
Merge branch 'main' into cmake_win_fix
bachittle Feb 27, 2023
596c2b8
Merge branch 'main' into cmake_win_fix
ThomsonTan Mar 9, 2023
2bd872b
trying to include CMAKE_TOOLCHAIN_FILE, still fails...
bachittle Mar 10, 2023
cb439ce
fix cmake format
bachittle May 23, 2023
f6375fb
Merge branch 'main' into cmake_win_fix
ThomsonTan May 23, 2023
7349c5b
Merge branch 'main' into cmake_win_fix
marcalff May 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions test_common/src/http/client/nosend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
4 changes: 1 addition & 3 deletions tools/setup-buildtools.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if defined VCPKG_ROOT (
set "PATH=%VCPKG_ROOT%;%PATH%"
) else (
set "PATH=%~dp0vcpkg;%PATH%"
set "VCPKG_ROOT=%~dp0vcpkg"
)
pushd %~dp0

Expand Down Expand Up @@ -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
Expand Down