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

Fails to build an RC object #79

Closed glebm closed 2 years ago

glebm commented 2 years ago

I'm migrating DevilutionX MSVC build from AppVeyor to GitHub Actions (https://github.com/diasurgical/devilutionX/pull/4947) and I've hit the following error:

  add_executable(${BIN_TARGET}
    WIN32
    MACOSX_BUNDLE
    Source/main.cpp
    Packaging/windows/devilutionx.exe.manifest
    Packaging/windows/devilutionx.rc
    Packaging/apple/AppIcon.icns
    Packaging/apple/LaunchScreen.storyboard)
[186/593] Building RC object CMakeFiles\devilutionx.dir\Packaging\windows\devilutionx.rc.res
  FAILED: CMakeFiles/devilutionx.dir/Packaging/windows/devilutionx.rc.res 
  C:/ProgramData/chocolatey/bin/ccache.exe D:/a/_temp/125992~1/CMAKE-~1.0-W/bin/cmcldeps.exe RC D:\a\devilutionX\devilutionX\Packaging\windows\devilutionx.rc CMakeFiles\devilutionx.dir\Packaging\windows\devilutionx.rc.res.d CMakeFiles\devilutionx.dir\Packaging\windows\devilutionx.rc.res "Note: including file: " "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe" C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe -DASIO_STANDALONE -DBUILD_TESTING -DDEVILUTIONX_DEFAULT_RESAMPLER=Speex -DDEVILUTIONX_PALETTE_TRANSPARENCY_BLACK_16_LUT -DDEVILUTIONX_RESAMPLER_SDL -DDEVILUTIONX_RESAMPLER_SPEEX -DFMT_LOCALE -DFMT_SHARED -DPACKET_ENCRYPTION -D_CRT_SECURE_NO_WARNINGS -D_DEBUG -I D:\a\devilutionX\devilutionX\Source -I D:\a\devilutionX\devilutionX\build-ninja-vcpkg-debug\Source -I D:\a\devilutionX\devilutionX\3rdParty\PKWare\. -I D:\a\devilutionX\devilutionX\build-ninja-vcpkg-debug\_deps\libmpq-src -I D:\a\devilutionX\devilutionX\build-ninja-vcpkg-debug\_deps\libsmacke...
  cl : Command line warning D9002 : ignoring unknown option '/fo'
  c1: fatal error C1083: Cannot open source file: 'CMakeFiles\devilutionx.dir\Packaging\windows\devilutionx.rc.res.dep.obj ': No such file or directory
  devilutionx.rc

https://github.com/diasurgical/devilutionX/runs/7271331869?check_suite_focus=true

glebm commented 2 years ago

Looks like the root cause is how DevilutionX sets up ccache:

find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
  set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()
glebm commented 2 years ago

Fixed like this:

 find_program(CCACHE_PROGRAM ccache)
 if(CCACHE_PROGRAM)
-  set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
+  set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
+  set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
 endif()