[cmake] Conflicting compilers for fortran and cxx languages

Summary

Cmake fails at the configure step when fortran compiler is of different kind than CXX compiler (e.g. fortran compiler is GNU 8.3.0, and CXX is MSVC 19.29).

Environment

  • Operating System : Windows
  • Architecture : x64
  • Eigen Version : 3.4.0
  • Compiler Version : MSVC 19.29.30138.0
  • Compile Flags :
  • Vector Extension :

Minimal Example

Not applicable

Steps to reproduce

  1. Configure eigen using GitHub action on windows host, with CXX compiler set to MSVC

What is the current bug behavior?

Cmake finds fortran compiler that is different than the CXX compiler. The test Detecting Fortran compiler ABI info fails, and cmake throws and error at C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeTestFortranCompiler.cmake:61 (see detailed log below): the compilation option set for the CXX compilers are forwarded to the Fortran compilers (but are incompatible: fortran expect GNU options, not MSVC). The final error is gfortran.exe: error: /machine:x64: No such file or directory.

What is the expected correct behavior?

Fortran compiler should be checked against CXX compiler before testing compilation.

Relevant logs

2022-01-18T20:41:47.5805736Z [19/72] Performing configure step for 'Eigen3'
2022-01-18T20:41:47.5884464Z FAILED: Core/Eigen3-prefix/src/Eigen3-stamp/Eigen3-configure D:/a/Radium-Engine/Radium-Engine/external/build/Core/Eigen3-prefix/src/Eigen3-stamp/Eigen3-configure 
2022-01-18T20:41:47.5910358Z cmd.exe /C "cd /D D:\a\Radium-Engine\Radium-Engine\external\build\Core\Eigen3-prefix\src\Eigen3-build && "C:\Program Files\CMake\bin\cmake.exe" -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_GENERATOR=Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=D:/a/Radium-Engine/Radium-Engine/external/install -DCMAKE_INSTALL_MESSAGE=LAZY "-DCMAKE_C_COMPILER=C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe" "-DCMAKE_CXX_COMPILER=C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe" "-DCMAKE_CXX_FLAGS=/DWIN32 /D_WINDOWS /w  /GR /EHsc" "-DCMAKE_CXX_FLAGS_DEBUG=/MDd /Zi /Ob0 /Od /RTC1" "-DCMAKE_CXX_FLAGS_RELEASE=/MD /O2 /Ob2 /DNDEBUG" "-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=/MD /Zi /O2 /Ob1 /DNDEBUG" -DCMAKE_SHARED_LINKER_FLAGS=/machine:x64 -DCMAKE_PREFIX_PATH= -DCMAKE_MODULE_PATH=D:/a/Radium-Engine/Radium-Engine/src/Radium-Engine/external/../cmake -DCMAKE_OBJECT_PATH_MAX= -DCMAKE_MACOSX_RPATH=TRUE --no-warn-unused-cli -DEIGEN_TEST_CXX11=OFF -DBUILD_TESTING=OFF -DEIGEN_BUILD_DOC=OFF -DCMAKE_MESSAGE_INDENT=-- -GNinja D:/a/Radium-Engine/Radium-Engine/external/build/Core/Eigen3-prefix/src/Eigen3 && "C:\Program Files\CMake\bin\cmake.exe" -E touch D:/a/Radium-Engine/Radium-Engine/external/build/Core/Eigen3-prefix/src/Eigen3-stamp/Eigen3-configure"
2022-01-18T20:41:47.5932731Z Not searching for unused variables given on the command line.
2022-01-18T20:41:47.5933078Z -- --The C compiler identification is MSVC 19.29.30138.0
2022-01-18T20:41:47.5934127Z -- --The CXX compiler identification is MSVC 19.29.30138.0
2022-01-18T20:41:47.5934476Z -- --Detecting C compiler ABI info
2022-01-18T20:41:47.5934755Z -- --Detecting C compiler ABI info - done
2022-01-18T20:41:47.5957441Z -- --Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
2022-01-18T20:41:47.5972347Z -- --Detecting C compile features
2022-01-18T20:41:47.5973534Z -- --Detecting C compile features - done
2022-01-18T20:41:47.6015824Z -- --Detecting CXX compiler ABI info
2022-01-18T20:41:47.6017855Z -- --Detecting CXX compiler ABI info - done
2022-01-18T20:41:47.6057127Z -- --Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
2022-01-18T20:41:47.6126562Z -- --Detecting CXX compile features
2022-01-18T20:41:47.6128856Z -- --Detecting CXX compile features - done
2022-01-18T20:41:47.6238418Z -- --Performing Test EIGEN_COMPILER_SUPPORT_CPP11
2022-01-18T20:41:47.6272057Z -- --Performing Test EIGEN_COMPILER_SUPPORT_CPP11 - Failed
2022-01-18T20:41:47.6274134Z -- --Performing Test COMPILER_SUPPORT_std=cpp03
2022-01-18T20:41:47.6296096Z -- --Performing Test COMPILER_SUPPORT_std=cpp03 - Failed
2022-01-18T20:41:47.6357377Z -- --Performing Test standard_math_library_linked_to_automatically
2022-01-18T20:41:47.6359753Z -- --Performing Test standard_math_library_linked_to_automatically - Success
2022-01-18T20:41:47.7169396Z -- --Standard libraries to link to explicitly: none
2022-01-18T20:41:47.7191710Z -- --Performing Test COMPILER_SUPPORT_OPENMP
2022-01-18T20:41:47.7285628Z -- --Performing Test COMPILER_SUPPORT_OPENMP - Success
2022-01-18T20:41:47.7288597Z -- --Looking for a Fortran compiler
2022-01-18T20:41:47.7301091Z -- --Looking for a Fortran compiler - C:/Strawberry/c/bin/gfortran.exe
2022-01-18T20:41:47.7317675Z -- --The Fortran compiler identification is GNU 8.3.0
2022-01-18T20:41:47.8178994Z -- --Detecting Fortran compiler ABI info
2022-01-18T20:41:47.8195270Z -- --Detecting Fortran compiler ABI info - failed
2022-01-18T20:41:47.8669472Z -- --Check for working Fortran compiler: C:/Strawberry/c/bin/gfortran.exe
2022-01-18T20:41:47.8678140Z -- --Check for working Fortran compiler: C:/Strawberry/c/bin/gfortran.exe - broken
2022-01-18T20:41:47.8740944Z CMake Error at C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeTestFortranCompiler.cmake:61 (message):
2022-01-18T20:41:47.8742125Z   The Fortran compiler
2022-01-18T20:41:47.9228429Z 
2022-01-18T20:41:47.9247405Z     "C:/Strawberry/c/bin/gfortran.exe"
2022-01-18T20:41:48.1158919Z 
2022-01-18T20:41:48.1634321Z   is not able to compile a simple test program.
2022-01-18T20:41:48.1711565Z 
2022-01-18T20:41:48.1716063Z   It fails with the following output:
2022-01-18T20:41:48.1720355Z 
2022-01-18T20:41:48.2010946Z     Change Dir: D:/a/Radium-Engine/Radium-Engine/external/build/Core/Eigen3-prefix/src/Eigen3-build/CMakeFiles/CMakeTmp
2022-01-18T20:41:48.2041393Z     
2022-01-18T20:41:48.2055035Z     Run Build Command(s):D:/a/Radium-Engine/Radium-Engine/ninja-build/ninja.exe cmTC_d206f && [1/4] Building Fortran preprocessed CMakeFiles/cmTC_d206f.dir/testFortranCompiler.f-pp.f
2022-01-18T20:41:48.2081300Z     [2/4] Generating Fortran dyndep file CMakeFiles/cmTC_d206f.dir/Fortran.dd
2022-01-18T20:41:48.5030242Z     [3/4] Building Fortran object CMakeFiles/cmTC_d206f.dir/testFortranCompiler.f.obj
2022-01-18T20:41:48.5743748Z     [4/4] Linking Fortran executable cmTC_d206f.exe
2022-01-18T20:41:48.5776894Z     FAILED: cmTC_d206f.exe 
2022-01-18T20:41:48.5869595Z     cmd.exe /C "cd . && C:\Strawberry\c\bin\gfortran.exe  /machine:x64 CMakeFiles/cmTC_d206f.dir/testFortranCompiler.f.obj -o cmTC_d206f.exe -Wl,--out-implib,libcmTC_d206f.dll.a -Wl,--major-image-version,0,--minor-image-version,0   && cd ."
2022-01-18T20:41:48.5876041Z     gfortran.exe: error: /machine:x64: No such file or directory
2022-01-18T20:41:48.5946619Z     ninja: build stopped: subcommand failed.

Source: https://github.com/STORM-IRIT/Radium-Engine/runs/4859062602?check_suite_focus=true#step:14:1464

Warning Messages

Anything else that might help

  • Have a plan to fix this issue.
Edited by Nicolas Mellado