adobe / USD-Fileformat-plugins

A collection of USD fileformat plugins
298 stars 22 forks source link

CMake error when building usdfbx with Visual Studio Build Tools 2019 #11

Closed tahv closed 5 months ago

tahv commented 5 months ago

Actual Behaviour

I'm trying to build the usdfbx plugin but I get a CMake error during the Fetching GTest phase.

This only occur when I build with Visual Studio Build Tools 2019. It work with 2022.

CMake Error at <ROOT_DIRECTORY>/USD-Fileformat-plugins-build/_deps/googletest-subbuild/googletest-populate-prefix/tmp/googletest-populate-gitupdate.cmake:25 (message):

Failed to get the hash for HEAD:
[...]

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Platform and Version

Sample Code that illustrates the problem

> call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.11.34
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

> cmake \
  -S USD-Fileformat-plugins \
  -B USD-Fileformat-plugins-build \
  -D CMAKE_INSTALL_PREFIX=bin \
  -D pxr_ROOT=OpenUSD-build \
  -D FBXSDK_ROOT=fbxsdk \
  -D LibXml2_ROOT=libxml2 \
  -D USD_FILEFORMATS_ENABLE_FBX=ON \
  -D USD_FILEFORMATS_ENABLE_GLTF=OFF \
  -D USD_FILEFORMATS_ENABLE_OBJ=OFF \
  -D USD_FILEFORMATS_ENABLE_PLY=OFF \
  -D USD_FILEFORMATS_ENABLE_STL=OFF \
  -D USD_FILEFORMATS_ENABLE_DRACO=OFF

-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.29.30154.0
-- The CXX compiler identification is MSVC 19.29.30154.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- PROJECT VERSION IS: 1.0.1
Building without ASM
-- Found Python3: <PYTHON_DIRECTORY>\libs\python39.lib (found version "3.9.2") found components: Development Development.Module Development.Embed
-- Fetching GTest
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Checking Build System
  Creating directories for 'googletest-populate'
  Performing download step (git clone) for 'googletest-populate'
  -- Avoiding repeated git clone, stamp file is up to date: '<ROOT_DIRECTORY>/USD-Fileformat-plugins-build/_deps/googletest-subbuild/googletest-populate-prefix/src/googletest-populate-stamp/googletest-populate-gitinfo.txt'
  Performing update step for 'googletest-populate'
  CMake Error at <ROOT_DIRECTORY>/USD-Fileformat-plugins-build/_deps/googletest-subbuild/googletest-populate-prefix/tmp/googletest-populate-gitupdate.cmake:25 (message):
    Failed to get the hash for HEAD:

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): error MSB8066: Custom build for '<ROOT_DIRECTORY>\USD-Fileformat-plugins-build\_deps\googletest-subbuild\CMakeFiles\3c362416710b937cf42cc75d21d9822a\googletest-populate-mkdir.rule;<ROOT_DIRECTORY>\USD-Fileformat-plugins-build\_deps\googletest-subbuild\CMakeFiles\3c362416710b937cf42cc75d21d9822a\googletest-populate-download.rule;<ROOT_DIRECTORY>\USD-Fileformat-plugins-build\_deps\googletest-subbuild\CMakeFiles\3c362416710b937cf42cc75d21d9822a\googletest-populate-update.rule;<ROOT_DIRECTORY>\USD-Fileformat-plugins-build\_deps\googletest-subbuild\CMakeFiles\3c362416710b937cf42cc75d21d9822a\googletest-populate-patch.rule;<ROOT_DIRECTORY>\USD-Fileformat-plugins-build\_deps\googletest-subbuild\CMakeFiles\3c362416710b937cf42cc75d21d9822a\googletest-populate-configure.rule;<ROOT_DIRECTORY>\USD-Fileformat-plugins-build\_deps\googletest-subbuild\CMakeFiles\3c362416710b937cf42cc75d21d9822a\googletest-populate-build.rule;<ROOT_DIRECTORY>\USD-Fileformat-plugins-build\_deps\googletest-subbuild\CMakeFiles\3c362416710b937cf42cc75d21d9822a\googletest-populate-install.rule;<ROOT_DIRECTORY>\USD-Fileformat-plugins-build\_deps\googletest-subbuild\CMakeFiles\3c362416710b937cf42cc75d21d9822a\googletest-populate-test.rule;<ROOT_DIRECTORY>\USD-Fileformat-plugins-build\_deps\googletest-subbuild\CMakeFiles\8e69b32b71ed6d2b6fad3499bd4cedf4\googletest-populate-complete.rule;<ROOT_DIRECTORY>\USD-Fileformat-plugins-build\_deps\googletest-subbuild\CMakeFiles\477a4b4380e662721fe2dc8aa55b9e72\googletest-populate.rule' exited with code 1. [<ROOT_DIRECTORY>\USD-Fileformat-plugins-build\_deps\googletest-subbuild\googletest-populate.vcxproj]

CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.20/Modules/FetchContent.cmake:1012 (message):
  Build step for googletest failed: 1
Call Stack (most recent call first):
  C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.20/Modules/FetchContent.cmake:1141:EVAL:2 (__FetchContent_directPopulate)
  C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.20/Modules/FetchContent.cmake:1141 (cmake_language)
  C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.20/Modules/FetchContent.cmake:1184 (FetchContent_Populate)
  cmake/FindGTest.cmake:44 (FetchContent_MakeAvailable)
  utils/CMakeLists.txt:6 (find_package)

-- Configuring incomplete, errors occurred!
See also "<ROOT_DIRECTORY>/USD-Fileformat-plugins-build/CMakeFiles/CMakeOutput.log".
make: *** [source\USD-Fileformat-plugins-build] Error 1
kwblackstone commented 5 months ago

Hello, I successfully configured the project using Visual Studio 2019. For transparency, here are the versions I'm using: Python: 3.10.4 CMake: 3.28.3 git: 2.39.0.windows.1

The error you're encountering appears to relate primarily to Git and CMake, specifically a failure in retrieving the Git hash for the GTest HEAD. This is unusual and might indicate an underlying issue with your Git or CMake installations. Could you please provide your versions of Git and CMake? Also, is there anything else in the log file at "/USD-Fileformat-plugins-build/CMakeFiles/CMakeOutput.log" that might reveal more details.

You probably already tried this but please make sure to clean your build directory first just to make sure nothing is lingering around that could be interfering.

You could also try running the command that is failing in your terminal: CMake Error at /USD-Fileformat-plugins-build/_deps/googletest-subbuild/googletest-populate-prefix/tmp/googletest-populate-gitupdate.cmake:25 (message): Failed to get the hash for HEAD:

function(get_hash_for_ref ref out_var err_var)
  execute_process(
    COMMAND "C:/Program Files/Git/cmd/git.exe" --git-dir=.git rev-parse "${ref}^0"
    WORKING_DIRECTORY "C:/git/USD-Fileformat-plugins/build/_deps/googletest-src"
    RESULT_VARIABLE error_code
    OUTPUT_VARIABLE ref_hash
    ERROR_VARIABLE error_msg
    OUTPUT_STRIP_TRAILING_WHITESPACE
  )

If you need a workaround, you can try installing gtest locally and pass -DGTest_ROOT as a cmake parameter to prevent it from fetching gtest.

Lastly, next release should make the gtest dependency go away unless you are actually building the tests when USD_FILEFORMATS_BUILD_TESTS is on.

tahv commented 5 months ago

Thanks for the quick response,

You are correct, the issue was my CMake version. MSVC 2019 installed CMake 3.20, I used a more recent version and it worked.