lukka / run-cmake

GitHub Action to build C++ applications with CMake (CMakePresets.json), Ninja and vcpkg on GitHub.
MIT License
176 stars 19 forks source link

run cmake using VS15Arm64 failed #3

Closed imbillow closed 4 years ago

imbillow commented 4 years ago

it says:

CMake Error at CMakeLists.txt:2 (project):
  Generator

    Visual Studio 15 2017

  could not find any instance of Visual Studio.

-- Configuring incomplete, errors occurred!

I known it need load environment by exec C:\\Program Files (x86)\\Microsoft Visual Studio\\${version}\\Enterprise\\VC\\vcvarsall.bat, but I don't how to fix it in the action.

lukka commented 4 years ago

@iovw the CMake's Visual Studio generator is usually able to find any instance of Visual Studio you request. Can you point out an actual error log that reproduces the problem?

Note that the action does not try to setup the environment (i.e. running vsdevcmd.bat). You can use msvc-dev-cmd action for that specific purpose.

The only case run-cmake sets up the build environment is when using its integration with run-vcpkg action (i.e. when useVcpkgToolchainFile : true): in this case vcpkg env is being run, which in turn runs the aforementioned 'vsdevcmd.bat'. This is needed when you want to use exactly the same toolset and environment to build your app and your dependencies.

imbillow commented 4 years ago
##[debug]CMake arguments:  -G "Visual Studio 15 2017" -A x64 -DCMAKE_BUILD_TYPE=Release D:\a\Notepad--\Notepad--
##[debug]Generating project files with CMake in build directory 'D:\a\_temp/build' ...
"C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 15 2017" -A x64 -DCMAKE_BUILD_TYPE=Release D:\a\Notepad--\Notepad--
CMake Error at CMakeLists.txt:2 (project):
  Generator

    Visual Studio 15 2017

  could not find any instance of Visual Studio.

-- Configuring incomplete, errors occurred!
imbillow commented 4 years ago

CMakeLists.txt

cmake_minimum_required(VERSION 3.15)
project(Notepad)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

find_package(Qt5 COMPONENTS Widgets LinguistTools PrintSupport REQUIRED)

set(TS_FILES Notepad_zh_CN.ts)
add_executable(Notepad
        main.cpp
        notepad.cpp
        notepad.h
        notepad.ui
        ${TS_FILES}
        )

target_link_libraries(Notepad PRIVATE Qt5::Widgets Qt5::PrintSupport)
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})

install(TARGETS Notepad DESTINATION bin)
imbillow commented 4 years ago

from this

the windows2019 vm haven't installed vs2017, but VS2019, it seems the reason.

And when i use

      - uses: ilammy/msvc-dev-cmd@v1
        if: "contains(matrix.os, 'windows')"
        with:
          toolset: 14.16

it had the same problem.

lukka commented 4 years ago

@iovw right, if there is no Visual Studio 2017 installed, the only way is to use the self hosted runners, and ensure you have the software you require. Let me know if there is anything I could improve in this action, thanks!

imbillow commented 4 years ago

I think it need a hint, such as:

Unless use the self hosted runners, it just has VS16*, Ninja, Makefile, these cmake generator available.

More info about Software installed on GitHub-hosted runners, goto https://help.github.com/en/actions/reference/software-installed-on-github-hosted-runners.

Maybe better?

lukka commented 4 years ago

@iovw yes, it should be documented indeed.