lukka / run-cmake

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

Windows -> Must define a target architecture #74

Closed Baklap4 closed 2 years ago

Baklap4 commented 2 years ago

Finally got to the part of building my application. I'm trying to compile it and it almost finishes and then ultimately fails upon building my resource file:

2022-04-07T20:28:18.7563698Z [147/154] Building RC object game\CMakeFiles\performous.dir\__\performous.rc.res
2022-04-07T20:28:18.7565108Z FAILED: game/CMakeFiles/performous.dir/__/performous.rc.res 
2022-04-07T20:28:18.7580156Z C:/PROGRA~1/CMake/bin/cmcldeps.exe RC D:\a\performous\performous\build\x64-debug\performous.rc game\CMakeFiles\performous.dir\__\performous.rc.res.d game\CMakeFiles\performous.dir\__\performous.rc.res "Note: including file: " "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe" C:\PROGRA~2\WI3CF2~1\10\bin\100220~1.0\x64\rc.exe -DEPOXY_SHARED -DHAVE_BLAS=1 -DHAVE_C99_VARARGS_MACROS=1 -DHAVE_FFTW3=1 -DHAVE_FFTW3F=1 -DHAVE_LIMITS_H=1 -DHAVE_MATH_H=1 -DHAVE_OPENBLAS_CBLAS_H=1 -DHAVE_STDARG_H=1 -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DUSE_OPENCV -DUSE_PORTMIDI -I D:\a\performous\performous\build\x64-debug\game -I D:\a\performous\performous\game -I D:\a\performous\performous\build\x64-debug\ced-src -I D:\a\performous\performous\build\x64-debug\_deps\aubio-sources-build\include -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\include -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\include\SDL2 -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\include\cairo -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\include\gdk-pixbuf-2.0 -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\debug\include\..\lib\libxml++-5.0\include -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\include\libxml++-5.0 -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\include\libxml2 -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\debug\include\..\lib\glibmm-2.68\include -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\include\glibmm-2.68 -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\include\sigc++-3.0 -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\debug\include\..\lib\sigc++-3.0\include -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\debug\..\include\pango-1.0 -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\debug\..\include\harfbuzz -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\debug\..\include -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\debug\..\include\glib-2.0 -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\debug\lib\glib-2.0\include -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\debug\..\include\libpng16 -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\debug\..\include\fribidi -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\debug\..\include\cairo -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\debug\..\include\lzo -I D:\a\performous\performous\build\x64-debug\vcpkg_installed\x64-windows\debug\..\include\pixman-1 -DWIN32 -D_DEBUG /fo game\CMakeFiles\performous.dir\__\performous.rc.res D:\a\performous\performous\build\x64-debug\performous.rc
2022-04-07T20:28:18.7588166Z cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release
2022-04-07T20:28:18.7588802Z 
2022-04-07T20:28:18.7590671Z ##[error]C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um\winnt.h(253): fatal error C1189: #error:  Must define a target architecture.
2022-04-07T20:28:18.7591830Z 

any idea why this is the case? I'm building with Ninja as generator.

This is the relevant section in our actions:

- uses: lukka/run-vcpkg@v10.2
        with:
          vcpkgGitCommitId: '71d274d7ce32d7f2508062a70e0a5ebe981319eb'

      - uses: lukka/run-cmake@v10
        env:
          PKG_CONFIG_EXECUTABLE: D:/a/performous/performous/pkg-config-lite-0.28-1/bin/pkg-config.exe
        with:
          configurePreset: 'x64-debug'
          buildPreset: 'x64-debug'

our presets file looks like this:

{
  "version": 2,
  "configurePresets": [
    {
      "name": "windows-base",
      "description": "Target Windows with the Visual Studio development environment.",
      "hidden": true,
      "generator": "Ninja",
      "binaryDir": "${sourceDir}/build/${presetName}",
      "cacheVariables": {
        "CMAKE_C_COMPILER": "cl.exe",
        "CMAKE_CXX_COMPILER": "cl.exe",
        "BUILD_SHARED_LIBS": "ON",
        "ENABLE_WEBSERVER": "OFF",
        "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/${presetName}-install",
        "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
      }
    }
  ]
"buildPresets": [
    {
      "name": "x64-debug",
      "configurePreset": "x64-debug",
      "displayName": "Build x64-debug with Ninja",
      "description": "Build x64-debug with Ninja"
    }
]

generated output summary in GH-actions image

Baklap4 commented 2 years ago

Okay stupid me.. in our resource file we had 2 includes:

#include <winuser.h>
#include <winver.h>

LANGUAGE 9, 1

1 ICON "@CMAKE_SOURCE_DIR@/win32/performous.ico"

VS_VERSION_INFO VERSIONINFO
 FILEVERSION @VERSION_MAJOR@, @VERSION_MINOR@, @VERSION_PATCH@, @VERSION_TWEAK@
 PRODUCTVERSION @VERSION_MAJOR@, @VERSION_MINOR@, @VERSION_PATCH@, @VERSION_TWEAK@
 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
 FILEOS VOS_NT_WINDOWS32
 FILETYPE VFT_APP
 FILESUBTYPE VFT2_UNKNOWN
BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "040904b0"
    BEGIN
      VALUE "CompanyName",  "@CMAKE_PROJECT_NAME@ Developers"
      VALUE "FileDescription",  "@CMAKE_PROJECT_NAME@ Game"
      VALUE "FileVersion", "@PROJECT_VERSION@"
      VALUE "InternalName", "Performous.exe"
      VALUE "LegalCopyright", "Copyright © 2009-@YEAR@ @CMAKE_PROJECT_NAME@ Team - GNU GPL v2 or later"
      VALUE "OriginalFilename", "Performous.exe"
      VALUE "ProductName", "@CMAKE_PROJECT_NAME@"
      VALUE "ProductVersion", "@PROJECT_VERSION@"
    END
  END
  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x409, 1200
  END
END

Replacing those with #using <windows.h> solved the problem.

Strange thing is that i don't get this error locally 🤔

lukka commented 2 years ago

@Baklap4 frankly speaking I had no idea, great you solved the problem :) If locally is working, but not on the runner, please check that Windows SDK and MSVC versions matches what you have locally. On the runner in your log I see MSVC 14.31.31103 and Windows SDK 10.0.22000.0