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

CMAKE_GENERATOR_TOOLSET is set to v144, which doesn't exist yet #4772

Closed
MobSlicer152 opened this issue Feb 26, 2024 · 9 comments
Closed

CMAKE_GENERATOR_TOOLSET is set to v144, which doesn't exist yet #4772

MobSlicer152 opened this issue Feb 26, 2024 · 9 comments
Labels
Milestone

Comments

@MobSlicer152
Copy link

Xmake Version

v2.8.7+HEAD.da279272a

Operating System Version and Architecture

Windows 11 10.0.22631.3155

Describe Bug

I found that _get_vs_toolset in modules/package/tools/cmake.lua is responsible, and its parsing of the version doesn't work correctly with Visual Studio 2022 Preview. I modified it to return v143 if it gets v144, but this is obviously a very temporary fix.

-- get vs toolset
function _get_vs_toolset(package)
    local toolset_ver = nil
    local vs_toolset = _get_msvc(package):config("vs_toolset") or config.get("vs_toolset")
    if vs_toolset then
        local verinfo = vs_toolset:split('%.')
        if #verinfo >= 2 then
            toolset_ver = "v" .. verinfo[1] .. (verinfo[2]:sub(1, 1) or "0")
            if toolset_ver == "v144" then
                toolset_ver = "v143"
            end
        end
    end
    return toolset_ver
end

Expected Behavior

It should properly understand what toolset to use. I'm not exactly sure how you would fix this, and it's possible Microsoft will make a v144 toolset in the near future, but until then this code doesn't work properly. It's also worth mentioning that passing --vs_toolset to xmake config doesn't impact what the CMake command uses, which is probably also worth looking into, and it would be a less fragile but less convenient fix to this issue.

Project Configuration

This isn't really relevant, the issue seems to be caused by using a preview version of Visual Studio 2022

Additional Information and Error Logs

**C:\Program Files\xmake\xmake.exe f -c --require=n -p windows -a x64 -m release -k static --vs=2022
checking for Microsoft Visual Studio (x64) version ... 2022
checking for Microsoft C/C++ Compiler (x64) version ... 19.40.33521
C:\Program Files\xmake\xmake.exe require -y -v -j 26 --debugdir=C:\Users\bramb\Downloads\assimp --force --shallow --build --extra={configs={shared=false},system=false} "assimp v5.3.1"
checking for unzip ... no
checking for 7z ... C:\Program Files\xmake\winenv\bin\7z
checking for git ... ok
checking for gzip ... no
git rev-parse HEAD
checking for cmake ... no
checking for Microsoft Visual Studio (x64) version ... 2022
checking for cmake ... no
checking for cmake ... no
checking for cmake ... C:\Program Files\CMake\bin\cmake
checking for xmake::zlib ... zlib v1.3.1
checking for xmake::minizip ... minizip v1.2.13
checking for ping ... ok
pinging the host(github.com) ... 27 ms
checking for xmake::zlib ... zlib v1.3.1
checking for xmake::minizip ... minizip v1.2.13
checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33521\bin\HostX64\x64\cl.exe
checking for the c++ compiler (cxx) ... cl.exe
checking for the linker (ld) ... link.exe
checking for cmake ... C:\Program Files\CMake\bin\cmake
checking for pkgconf ... no
C:\Program Files\CMake\bin\cmake -DASSIMP_BUILD_SAMPLES=OFF -DASSIMP_BUILD_TESTS=OFF -DASSIMP_BUILD_DOCS=OFF -DASSIMP_BUILD_FRAMEWORK=OFF -DASSIMP_INSTALL_PDB=ON -DASSIMP_INJECT_DEBUG_POSTFIX=ON -DASSIMP_BUILD_ZLIB=OFF -DSYSTEM_IRRXML=ON -DASSIMP_WARNINGS_AS_ERRORS=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DASSIMP_DOUBLE_PRECISION=OFF -DASSIMP_NO_EXPORT=OFF -DASSIMP_ASAN=OFF -DASSIMP_UBSAN=OFF -DASSIMP_BUILD_ASSIMP_TOOLS=OFF -DZLIB_INCLUDE_DIR=C:\Users\bramb\AppData\Local\.xmake\packages\z\zlib\v1.3.1\d676b73b676c41cdae37b37fbf6c9cbd\include -DZLIB_LIBRARY=C:\Users\bramb\AppData\Local\.xmake\packages\z\zlib\v1.3.1\d676b73b676c41cdae37b37fbf6c9cbd\lib\zlib.lib -DCMAKE_INSTALL_PREFIX=C:\Users\bramb\AppData\Local\.xmake\packages\a\assimp\v5.3.1\de79f8655e024504b7fb71b0cd27c610 -DCMAKE_INSTALL_LIBDIR:PATH=lib -G "Visual Studio 17 2022" -A x64 -DCMAKE_GENERATOR_TOOLSET=v144 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded "-DCMAKE_CXX_FLAGS_DEBUG=/MT /Zi /Ob0 /Od /RTC1" "-DCMAKE_CXX_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG" "-DCMAKE_C_FLAGS_DEBUG=/MT /Zi /Ob0 /Od /RTC1" "-DCMAKE_C_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG" -DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=pdb "-DCMAKE_C_FLAGS=-IC:/Users/bramb/AppData/Local/.xmake/packages/m/minizip/v1.2.13/97492337f4434cbda1175027142662a3/include -IC:/Users/bramb/AppData/Local/.xmake/packages/m/minizip/v1.2.13/97492337f4434cbda1175027142662a3/include/minizip" "-DCMAKE_CXX_FLAGS=-IC:/Users/bramb/AppData/Local/.xmake/packages/m/minizip/v1.2.13/97492337f4434cbda1175027142662a3/include -IC:/Users/bramb/AppData/Local/.xmake/packages/m/minizip/v1.2.13/97492337f4434cbda1175027142662a3/include/minizip" "-DCMAKE_EXE_LINKER_FLAGS=-libpath:C:/Users/bramb/AppData/Local/.xmake/packages/m/minizip/v1.2.13/97492337f4434cbda1175027142662a3/lib minizip.lib" "-DCMAKE_SHARED_LINKER_FLAGS=-libpath:C:/Users/bramb/AppData/Local/.xmake/packages/m/minizip/v1.2.13/97492337f4434cbda1175027142662a3/lib minizip.lib" -DCMAKE_POSITION_INDEPENDENT_CODE=ON C:\Users\bramb\Downloads\assimp
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
CMake Error at CMakeLists.txt:58 (PROJECT):
  Failed to run MSBuild command:

    C:/Program Files/Microsoft Visual Studio/2022/Preview/MSBuild/Current/Bin/amd64/MSBuild.exe

  to get the value of VCTargetsPath:

    MSBuild version 17.10.0-preview-24081-01+97651a25d for .NET Framework
    Build started 26.02.2024 8:36:10.

    Project "C:\Users\bramb\Downloads\assimp\build_de79f865\CMakeFiles\3.28.3\VCTargetsPath.vcxproj" on node 1 (default targets).
    C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(457,5): error MSB8020: The build tools for v144 (Platform Toolset = 'v144') cannot be found. To build using the v144 build tools, please install v144 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\bramb\Downloads\assimp\build_de79f865\CMakeFiles\3.28.3\VCTargetsPath.vcxproj]
    Done Building Project "C:\Users\bramb\Downloads\assimp\build_de79f865\CMakeFiles\3.28.3\VCTargetsPath.vcxproj" (default targets) -- FAILED.

    Build FAILED.

    "C:\Users\bramb\Downloads\assimp\build_de79f865\CMakeFiles\3.28.3\VCTargetsPath.vcxproj" (default target) (1) ->
    (PrepareForBuild target) ->
      C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(457,5): error MSB8020: The build tools for v144 (Platform Toolset = 'v144') cannot be found. To build using the v144 build tools, please install v144 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\bramb\Downloads\assimp\build_de79f865\CMakeFiles\3.28.3\VCTargetsPath.vcxproj]

        0 Warning(s)
        1 Error(s)

    Time Elapsed 00:00:00.08


  Exit code: 1



-- Configuring incomplete, errors occurred!
error: execv(C:\Program Files\CMake\bin\cmake -DASSIMP_BUILD_SAMPLES=OFF -DASSIMP_BUILD_TESTS=OFF -DASSIMP_BUILD_DOCS=OFF -DASSIMP_BUILD_FRAMEWORK=OFF -DASSIMP_INSTALL_PDB=ON -DASSIMP_INJECT_DEBUG_POSTFIX=ON -DASSIMP_BUILD_ZLIB=OFF -DSYSTEM_IRRXML=ON -DASSIMP_WARNINGS_AS_ERRORS=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DASSIMP_DOUBLE_PRECISION=OFF -DASSIMP_NO_EXPORT=OFF -DASSIMP_ASAN=OFF -DASSIMP_UBSAN=OFF -DASSIMP_BUILD_ASSIMP_TOOLS=OFF -DZLIB_INCLUDE_DIR=C:\Users\bramb\AppData\Local\.xmake\packages\z\zlib\v1.3.1\d676b73b676c41cdae37b37fbf6c9cbd\include -DZLIB_LIBRARY=C:\Users\bramb\AppData\Local\.xmake\packages\z\zlib\v1.3.1\d676b73b676c41cdae37b37fbf6c9cbd\lib\zlib.lib -DCMAKE_INSTALL_PREFIX=C:\Users\bramb\AppData\Local\.xmake\packages\a\assimp\v5.3.1\de79f8655e024504b7fb71b0cd27c610 -DCMAKE_INSTALL_LIBDIR:PATH=lib -G "Visual Studio 17 2022" -A x64 -DCMAKE_GENERATOR_TOOLSET=v144 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded "-DCMAKE_CXX_FLAGS_DEBUG=/MT /Zi /Ob0 /Od /RTC1" "-DCMAKE_CXX_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG" "-DCMAKE_C_FLAGS_DEBUG=/MT /Zi /Ob0 /Od /RTC1" "-DCMAKE_C_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG" -DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=pdb "-DCMAKE_C_FLAGS=-IC:/Users/bramb/AppData/Local/.xmake/packages/m/minizip/v1.2.13/97492337f4434cbda1175027142662a3/include -IC:/Users/bramb/AppData/Local/.xmake/packages/m/minizip/v1.2.13/97492337f4434cbda1175027142662a3/include/minizip" "-DCMAKE_CXX_FLAGS=-IC:/Users/bramb/AppData/Local/.xmake/packages/m/minizip/v1.2.13/97492337f4434cbda1175027142662a3/include -IC:/Users/bramb/AppData/Local/.xmake/packages/m/minizip/v1.2.13/97492337f4434cbda1175027142662a3/include/minizip" "-DCMAKE_EXE_LINKER_FLAGS=-libpath:C:/Users/bramb/AppData/Local/.xmake/packages/m/minizip/v1.2.13/97492337f4434cbda1175027142662a3/lib minizip.lib" "-DCMAKE_SHARED_LINKER_FLAGS=-libpath:C:/Users/bramb/AppData/Local/.xmake/packages/m/minizip/v1.2.13/97492337f4434cbda1175027142662a3/lib minizip.lib" -DCMAKE_POSITION_INDEPENDENT_CODE=ON C:\Users\bramb\Downloads\assimp) failed(1)
  => install assimp v5.3.1 .. failed
error: install failed!
error: execv(C:\Program Files\xmake\xmake.exe require -y -v -j 26 --debugdir=C:\Users\bramb\Downloads\assimp --force --shallow --build --extra={configs={shared=false},system=false} "assimp v5.3.1") failed(-1)
error: execv(xrepo.bat install -y --shallow -v -p windows -a x64 -m release -k static -j 26 --vs=2022 -d . "assimp v5.3.1") failed(-1)
**
@waruqi
Copy link
Member

waruqi commented Feb 27, 2024

It should just be that the current cmake version doesn't support the latest vs preview version and v144, it doesn't seem to have anything to do with xmake.

We shouldn't have to hardcode changes to _get_vs_toolset, and there's no other way to work around it, since it's not a bug and you can wait for cmake to support it.

@MobSlicer152
Copy link
Author

It shouldn't be hardcoded, but v144 doesn't exist. The latest toolset is v143, but the code that parses the version number doesn't work for this version..

@waruqi
Copy link
Member

waruqi commented Mar 2, 2024

but we get v144 from vs/vcvarsall.bat. we cannot modify it.

you can run xmake l detect.sdks.find_vstudio and show output.

@A2va
Copy link
Contributor

A2va commented Mar 3, 2024

You are using the Visual Studio preview which includes the MSVC preview (v144). Cmake doesn't support the Visual Studio preview, so it won't recognise the compiler.

@waruqi
Copy link
Member

waruqi commented Mar 3, 2024

You are using the Visual Studio preview which includes the MSVC preview (v144). Cmake doesn't support the Visual Studio preview, so it won't recognise the compiler.

So I think this should be a cmake issue, and you can wait for cmake to support it instead of modifying the version in tools/cmake.lua

waruqi added a commit that referenced this issue Mar 6, 2024
@waruqi waruqi added this to the v2.8.9 milestone Mar 6, 2024
@waruqi
Copy link
Member

waruqi commented Mar 6, 2024

I don't know which version of cmake supports v144, I can only assume at this point that it's not supported in any version prior to 3.29.0 and let it using v143

#4800

@qudix
Copy link

qudix commented Mar 6, 2024

@waruqi
Copy link
Member

waruqi commented Mar 6, 2024

waruqi added a commit that referenced this issue Mar 6, 2024
fix vs toolset v144 for cmake #4772
@waruqi
Copy link
Member

waruqi commented Mar 6, 2024

try xmake update -s dev

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

No branches or pull requests

4 participants