ArthurSonzogni / FTXUI

:computer: C++ Functional Terminal User Interface. :heart:
MIT License
6.92k stars 417 forks source link

Failing to open `ftxui-screen.lib` on Windows with GitHub Actions & CPM #382

Closed szymonj99 closed 2 years ago

szymonj99 commented 2 years ago

I'm able to compile locally, but my project fails to compile when running with GitHub Actions on windows-latest in either debug or release modes. I am using CPM, but the same has happened when using FetchContent manually.

Error

Generating Code...
LINK : fatal error LNK1181: cannot open input file 'Release\ftxui-screen.lib' [D:\a\...\build\_deps\ftxui-build\dom.vcxproj]

Setup

CPMAddPackage("gh:ArthurSonzogni/FTXUI#764c24ef4046fbfd3cb1a25d0cb8a47a84e82d3a")
...
target_link_libraries(${PROJECT_NAME} PRIVATE ... ftxui::screen ftxui::dom ftxui::component)

ftxui-screen.dll seems to be generated correctly:

Generating Code...
  screen.vcxproj -> D:\a\OneControl\OneControl\build\_deps\ftxui-build\Release\ftxui-screen.dll
  Building Custom Rule D:/a/OneControl/OneControl/build/_deps/ftxui-src/CMakeLists.txt

Let me know if this is an issue on my end 💯

ArthurSonzogni commented 2 years ago

What's your github action?

There is likely a problem. You can probably take some inspiration from: https://github.com/ArthurSonzogni/FTXUI/blob/764c24ef4046fbfd3cb1a25d0cb8a47a84e82d3a/.github/workflows/build.yaml#L35-L37

https://github.com/ArthurSonzogni/FTXUI/blob/764c24ef4046fbfd3cb1a25d0cb8a47a84e82d3a/.github/workflows/build.yaml#L39-L73

szymonj99 commented 2 years ago

My action is as follows (BUILD_TYPE is Release):

build-windows-release:
    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v2

    - name: Configure CMake
      run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

    - name: Build
      run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

I'll give your suggestion a try and report back. Thanks! 💯

szymonj99 commented 2 years ago

Unfortunately, your suggestion doesn't seem to have worked for me so far. Below is my updated workflow file. Let me know if I missed something 💯

name: CMake

on:
  push:
    branches: [ '*' ]

env:
  BUILD_TYPE: Release

jobs:
  compiling:
    name: "Compiling"
    strategy:
      matrix:
        include:
          - name: Windows
            os: windows-latest
            compiler: cl

          - name: Linux GCC
            os: ubuntu-latest
            compiler: gcc

          - name: MacOS Clang
            os: macos-latest
            compiler: llvm

    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2

      - name: Setup C++
        uses: aminya/setup-cpp@v1
        with:
          # Let's add `clangtidy: true` and maybe other possible checks here in the future.
          compiler: ${{ matrix.compiler }}
          #vcvarsall: ${{ contains(matrix.os, 'windows' )}} # I'm not 100% sure what this is tbh.
          cmake: true
          ninja: true

      - name: Download Packages
        if: ${{ contains(matrix.os, 'ubuntu' )}}
        run: sudo apt update && sudo apt install libx11-dev libsfml-dev xorg-dev libopengl-dev mesa-common-dev libudev-dev libopenal-dev libvorbis-dev libflac-dev libncurses-dev
        shell: bash

      - name: Configure CMake
        run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

      - name: Build
        run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}