Using CPM to add Eigen and OpenXLSX libraries

Hi,

I have a cmake + C++ project where I need both Eigen and OpenXLSX libraries.

According to the readme, the OpenXLSX should build on both windows and linux platforms.

My attempt

I am using CPM, so my main root/CMakeLists.txt is

# add dependencies
include(cmake/CPM.cmake)
CPMAddPackage("gh:gabime/spdlog@1.13.0")
CPMAddPackage("gh:zeux/pugixml@1.14")
CPMAddPackage(
        GITLAB_REPOSITORY libeigen/eigen
        GIT_TAG 3.4
        OPTIONS "EIGEN_BUILD_DOC OFF"
        "EIGEN_BUILD_PKGCONFIG OF"
        "EIGEN_BUILD_DOC OFF"
)
CPMAddPackage("gh:vincentlaucsb/csv-parser#2.2.0")
CPMAddPackage("gh:troldal/OpenXLSX#ededa1e8398305d0983648d3e9f120ff7e228d2b")

Here I added the last line to include a specific commit of OpenXLSX as well.

Problem

While this builds successfully on ubuntu-22.04 with my github actions, it fails miserably on windows latest after adding that single line in CMake.

The output I was able to get says:

Run cmake -B D:\a\myproject\myproject/build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -S D:\a\myproject\myproject
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.20348.
-- The CXX compiler identification is MSVC 19.39.33523.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CPM: Adding package spdlog@1.13.0 (v1.13.0)
-- Build spdlog: 1.13.0
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Build type: Release
-- CPM: Adding package pugixml@1.14 (v1.14)
-- CPM: Adding package eigen@3.4 (3.4)
-- 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.

YOu can see the now the eigen library suddenly no longer buildsā€¦

Would anybody know what to do?

Iā€™d ask CPM developers; they may have more ways to assist.

Other than that, I would try to strip it down and/or trace why this Eigen message shows up suddenly. Maybe there are cache variables that end up conflicting somewhere?

you should check you label!

you are working with an old version on branch 3.4

IMHO: you need at least version: Reorganize CMake and minimize configuration for non-top-level builds. (!1556) Ā· Merge requests Ā· libeigen / eigen Ā· GitLab

1 Like

Is it safe to use not-yet-officially-released version?

I intentionally used the latest release.

If you need the Windows build, open a ticket as written.