由于 install(EXPORT "foo-targets" ...) 在导出集中多次包含目标 "foo",aws-cpp-sdk 在 Windows 构建期间失败

aws-cpp-sdk fails during Windows build due to install(EXPORT "foo-targets" ...) includes target "foo" more than once in the export set

为了让我自己回答这个问题,我浪费了一天的时间,希望为其他人省去麻烦。

设置:

你试试这样的:

  git clone https://github.com/aws/aws-sdk-cpp.git
  cd aws-sdk-cpp
  mkdir build
  cd build
  cmake ..

你收到 cmake 结尾的投诉:

  [...]
  Performing configure step for 'AwsChecksums'
  -- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.17763.
  -- The C compiler identification is MSVC 19.27.29112.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/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Configuring done
CUSTOMBUILD : CMake error : install(EXPORT "aws-checksums-targets" ...) includes target "aws-checksums" more than once in the export set. [C:\Users\xyz\aws-sdk-cpp\build\.deps\AwsChecksums.vcxproj]
  -- Generating done
  CMake Generate step failed.  Build files cannot be regenerated correctly.
CMake Error at CMakeLists.txt:224 (message):
  Failed to build third-party libraries.

有一条类似的线阅读CUSTOMBUILD : CMake error : install(EXPORT "aws-c-common-targets" ...) includes target "aws-c-common" more than once in the export set. [C:\Users\xyz\aws-sdk-cpp\build\.deps\AwsCCommon.vcxproj]

完全non-obvious,但问题似乎与“cmake 3.19.0-rc1”有关。更改为 cmake 3.18.4 绕过了这个问题。我不知道这是 cmake 问题还是 sdk 问题,或者我会在某人的 github 而不是 Whosebug 上发帖。

我遇到了同样的问题,我发现 Visual Studio 2019 16.9.1 附带的 CMake 已损坏(版本报告为 3.19.20122902-MSVC_2)。

我更改了 CMake 的路径以指向 Vcpkg 使用的路径,即版本 3.19.2,现在它工作正常。

因此我认为该错误存在于 Visual Studio 附带的 CMake 中,并已在 3.19.2 中修复。