Unable to build Eigen & OpenXLSX on windows

Well, I’m working on a C++ project where I am using linear algebra from Eigen.

This is how I fetch the Eigen library from my root CmakeLists.txt:

message([STATUS] "Fetching eigen.")
block(SCOPE_FOR VARIABLES)
    set(EIGEN_BUILD_TESTING OFF)
    set(EIGEN_BUILD_PKGCONFIG OFF)
    set(EIGEN_BUILD_DOC OFF)
    FetchContent_Declare(
            Eigen
            GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
            GIT_TAG 3.4
            GIT_SHALLOW TRUE
            GIT_PROGRESS TRUE
    )
    FetchContent_MakeAvailable(Eigen)
endblock()

I then have github actions to build and test on both ubuntu-22.04 and windows-latest.

The instructions to build on windows are (copied only until build starts):

# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: CMake build and test on Windows

on:
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]

env:
  # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
  BUILD_TYPE: Release

jobs:
  build:
    name: build and test
    # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
    # You can convert this to a matrix build if you need cross-platform coverage.
    # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v4

      - name: Set reusable strings
        id: strings
        shell: bash
        run: |
          echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
          echo "bin-output-dir=${{ github.workspace }}/bin" >> "$GITHUB_OUTPUT"

      - name: Configure CMake
        run: >
          cmake -B ${{ steps.strings.outputs.build-output-dir }}
          -DCMAKE_CXX_COMPILER=msvc
          -DCMAKE_C_COMPILER=msvc
          -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
          -S ${{ github.workspace }}

Problem

The linux build is successful, but the windows build fails with a slightly unexpected error already at the “Configure CMake” step. The error says:

[STATUS]Fetching pugixml.
[STATUS]Fetching eigen.
-- The C compiler identification is MSVC 19.39.33523.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test EIGEN_COMPILER_SUPPORT_CPP11
-- Performing Test EIGEN_COMPILER_SUPPORT_CPP11 - Failed
-- Performing Test COMPILER_SUPPORT_std=cpp03
-- Performing Test COMPILER_SUPPORT_std=cpp03 - Failed
-- Performing Test standard_math_library_linked_to_automatically
-- Performing Test standard_math_library_linked_to_automatically - Failed
-- Performing Test standard_math_library_linked_to_as_m
-- Performing Test standard_math_library_linked_to_as_m - Failed
CMake Error at build/_deps/eigen-src/CMakeLists.txt:136 (message):
  Can't link to the standard math library.  Please report to the Eigen
  developers, telling them about your platform.


-- Configuring incomplete, errors occurred!
Error: Process completed with exit code 1.

What anybody have clue?

Note:

This used to compile before I added OpenXLSX to the project as a submodule. Now it does not. The OpenXLSX library should be able to be built with msvc (which I am using), according to the official readme.

This is really weird to me.

Would it maybe help if I obtained all my packages with CPM (GitHub - cpm-cmake/CPM.cmake: 📦 CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management.) ?

Additional question:

What is the preffered modern approach? To use CMake and fetch content or gitlab submodules?