1

In my CMake project, I'm checking for use of MSVC compilers in order to alert users of a particular error message. However, when I use all Intel compilers (Fortran, C, C++), the MSVC CMake variable is still enabled. Is this expected?

Inspecting the CMakeCache for "MSVC" shows that the linker and archiver are from MSVC:

//Path to a program.
CMAKE_AR:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/lib.exe
//Path to a program.
CMAKE_LINKER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/link.exe

I've added a check in my CMakeLists.txt to print the value of that variable: message("MSVC ${MSVC}"). Here's my CMake configuration command and output:

C:\Users\rmudafor\Desktop\openfast\build_sl>cmake .. -G"NMake Makefiles" -DCMAKE_C_COMPILER:FILEPATH="C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\bin\intel64\icl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\bin\intel64\icl.exe" -DCMAKE_Fortran_COMPILER:FILEPATH="C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\bin\intel64\ifort.exe" -DBUILD_SHARED_LIBS=ON
-- The CXX compiler identification is Intel 20.2.1.20201112
-- The C compiler identification is Intel 20.2.1.20201112
-- The Fortran compiler identification is Intel 20.2.1.20201112
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/intel64/icl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/intel64/icl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/intel64/ifort.exe - skipped
-- Checking whether C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/intel64/ifort.exe supports Fortran 90
-- Checking whether C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/intel64/ifort.exe supports Fortran 90 - yes
-- Performing Test HAS_FORTRAN2008
-- Performing Test HAS_FORTRAN2008 - Success
-- Enabling Fortran 2008 features
-- Found MKL: C:/Program Files (x86)/Intel/oneAPI/mkl/latest/lib/intel64/mkl_intel_lp64.lib;C:/Program Files (x86)/Intel/oneAPI/mkl/latest/lib/intel64/mkl_sequential.lib;C:/Program Files (x86)/Intel/oneAPI/mkl/latest/lib/intel64/mkl_core.lib
MSVC 1
CMake Error at CMakeLists.txt:81 (message):
  Shared libraries are not support by OpenFAST with the MSVC build tool
  (https://github.com/OpenFAST/openfast/issues/448).


-- Configuring incomplete, errors occurred!
See also "C:/Users/rmudafor/Desktop/openfast/build_sl/CMakeFiles/CMakeOutput.log".
See also "C:/Users/rmudafor/Desktop/openfast/build_sl/CMakeFiles/CMakeError.log".
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
raf
  • 535
  • 4
  • 18
  • So what happens when you clean CMake cache? – Attis May 12 '21 at 19:48
  • From the description of `MSVC` CMake variable I understand, that it is set not only for MSVC compiler (`cl`), but also for a compiler which is able to "**simulate**" command line of `cl`. Probably, Intel compiler is classified to that "simulation" category. This would explain `CMAKE_LINKER` set to the MSVC linker. You could also check [MSVC_VERSION](https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html) variable and find out which MSVC version is "simulated" by the Intel. – Tsyvarev May 12 '21 at 20:11
  • @Attis The command and output above is with a clean cache – raf May 12 '21 at 23:13
  • @Tsyvarev MSVC_VERSION is 1927 with Intel 20.2.1.20201112. That version corresponds to Visual Studio 2019 version 16.7 (_MSC_VER = 14.27) which is the same version as `lib.exe` and `link.exe` the CMake found. I'd like to test whether using an Intel linker and archiver would still set this variable, but I havent located those in my Intel installation. – raf May 12 '21 at 23:21
  • Does this article help to solve your issue? https://stackoverflow.com/questions/49763259/cmake-custom-toolchain-cmake-ar-and-cmake-cxx-archive-create – Attis May 13 '21 at 07:38

0 Answers0