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

Fix an issue with GMOCK_LIB NOTFOUND with Visual Studio 2019 #766

Closed
wants to merge 1 commit into from

Conversation

maxgolov
Copy link
Contributor

@maxgolov maxgolov commented May 19, 2021

Changes

@ThomsonTan - I am hitting this issue with CMake+vcpkg in Visual Studio 2019 when I enable OTLP on Windows.

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
GMOCK_LIB

Full log:

1> CMake generation started for configuration: 'nostd-x64-Debug'.
1> Command line: "cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\ENTERPRISE\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\work\opentelemetry-cpp\out\vs2019\nostd-x64-Debug\install" -DWITH_OTLP:BOOL="True" -DWITH_EXAMPLES:BOOL="true" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\ENTERPRISE\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\work\opentelemetry-cpp" 2>&1"
1> Working directory: C:\work\opentelemetry-cpp\out\vs2019\nostd-x64-Debug
1> [CMake] -- Found RE2 via CMake.
1> [CMake] PROTOBUF_PROTOC_EXECUTABLE=C:/work/opentelemetry-cpp/tools/vcpkg/installed/x64-windows/tools/protobuf/protoc.exe
1> [CMake] GTEST_INCLUDE_DIRS   = C:/work/opentelemetry-cpp/tools/vcpkg/installed/x64-windows/include
1> [CMake] GTEST_BOTH_LIBRARIES = optimized;C:/work/opentelemetry-cpp/tools/vcpkg/installed/x64-windows/lib/gtest.lib;debug;C:/work/opentelemetry-cpp/tools/vcpkg/installed/x64-windows/debug/lib/gtestd.lib;optimized;C:/work/opentelemetry-cpp/tools/vcpkg/installed/x64-windows/lib/manual-link/gtest_main.lib;debug;C:/work/opentelemetry-cpp/tools/vcpkg/installed/x64-windows/debug/lib/manual-link/gtest_maind.lib
1> [CMake] Building with nostd types...
1> [CMake] -- Configuring done
1> [CMake] CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
1> [CMake] Please set them or make sure they are set and tested correctly in the CMake files:
1> [CMake] GMOCK_LIB
1> [CMake]     linked by target "otlp_exporter_test" in directory C:/work/opentelemetry-cpp/exporters/otlp
1> [CMake] 
1> [CMake] -- Generating done
1> [CMake] CMake Generate step failed.  Build files cannot be regenerated correctly.
1> 'cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\ENTERPRISE\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\work\opentelemetry-cpp\out\vs2019\nostd-x64-Debug\install" -DWITH_OTLP:BOOL="True" -DWITH_EXAMPLES:BOOL="true" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\ENTERPRISE\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\work\opentelemetry-cpp" 2>&1"' execution failed with error: ''cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\ENTERPRISE\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\work\opentelemetry-cpp\out\vs2019\nostd-x64-Debug\install" -DWITH_OTLP:BOOL="True" -DWITH_EXAMPLES:BOOL="true" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\ENTERPRISE\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\work\opentelemetry-cpp" 2>&1"' returned with exit code: 1'.

I assume your recent change ( #726 ) - was somehow affecting Linux / gcc build. But not MSVC. Thus, I'm changing this a tiny bit - to apply your previous patch only to non-MSVC path. After I applied this change, I get it all building and working well witch CMake + Visual Studio 2019 (MSVC) + ninja. All tests are Okay. Please let me know if it makes sense. If you think this is not good, kindly elaborate on what exact issue you had originally with this variable defined.

@maxgolov maxgolov requested review from a team and ThomsonTan May 19, 2021 05:32
@codecov
Copy link

codecov bot commented May 19, 2021

Codecov Report

Merging #766 (9ad2f08) into main (976b5ca) will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #766      +/-   ##
==========================================
+ Coverage   95.95%   95.97%   +0.01%     
==========================================
  Files         176      176              
  Lines        7172     7172              
==========================================
+ Hits         6882     6883       +1     
+ Misses        290      289       -1     
Impacted Files Coverage Δ
sdk/src/logs/batch_log_processor.cc 95.00% <0.00%> (+1.25%) ⬆️

@ThomsonTan
Copy link
Contributor

@maxgolov #726 was intended for MSVC as well, as using the cached variable could cause linking to incorrect flavor of gmock.lib when updating CMAKE_BUILD_TYPE for an existing build.

It seems the your case, cmake was invoked for multiple times, and find_library(GMOCKLIB) doesn't work for some of the runs. Could you please share the repro steps?

@maxgolov
Copy link
Contributor Author

@ThomsonTan - I'm using recent (probably close to latest ) Visual Studio 2019 with CMake+ninja. Clean build, all artifacts deleted. No CMake cache generated yet. Opening the project as directory, then using built-in CMake generate and Build All.

I'm building nostd-x64-Debug configuration. In CMake build in Visual Studio - we use settings that enable WITH_OTLP=ON.

There is a markdown document describing the process in my PR here #755

I see what you are saying, since you unset the variable - and the next stage right under is supposed to populate it.. so it should work, in theory, but it's been breaking for me.

@ThomsonTan
Copy link
Contributor

I'll try to reproduce it in a fresh VM based on #755.

@ThomsonTan
Copy link
Contributor

I just did the build in a fresh VM with VS 2019 community edition, opened the opentelemetry-folder with VS 2019, garneted nostd-x64-Debug and everything built fine (WITH_OTLP is turned on in CMakeSettings.json). I do get below error but it is not blocking the build and test run.

  Copy-Item : The process cannot access the file 
  'C:\gh\opentelemetry-cpp\out\vs2019\nostd-x64-Debug\exporters\ostream\gtestd.dll' because it is being used by another 
  process.
  At C:\gh\opentelemetry-cpp\tools\vcpkg\scripts\buildsystems\msbuild\applocal.ps1:29 char:9
  +         Copy-Item "$SourceDir\$targetBinaryName" $targetBinaryDir
  +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : NotSpecified: (:) [Copy-Item], IOException
      + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand

@lalitb
Copy link
Member

lalitb commented Jun 3, 2021

Can we close this PR now that #771 has these changes included ?

@lalitb
Copy link
Member

lalitb commented Jun 4, 2021

closing this as #771 has these changes.

@lalitb lalitb closed this Jun 4, 2021
@maxgolov
Copy link
Contributor Author

maxgolov commented Jun 4, 2021

Yeah, we should be able to close it. @ThomsonTan - could you please verify the latest rc1 build on your machine?

@maxgolov maxgolov deleted the maxgolov/fix_gmock_lib branch June 4, 2021 19:53
@ThomsonTan
Copy link
Contributor

Yeah, we should be able to close it. @ThomsonTan - could you please verify the latest rc1 build on your machine?

Verified rc1 build and test passed on my machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants