CMake does not identify Intel compilers
Apologies if I have missed something obvious, but I'm stuck. On a Windows 10 64-bit PC, I have Intel Parallel Studio XE 2017 Composer with C/C++ and Fortran compilers, but I cannot get CMake to find these compilers. I also have Visual Studio installed too, with MSVC compilers. Here are my steps:
- Start a "Intel Compiler 17.0 Update 6 Intel(R) 64 Visual Studio 2017" shell.
- Create a dummy project that needs C and CXX. I'm leaving Fortran out of this for now, as CMake can't find it.
- Set CC and CXX environment variables. (this appears to have no effect)
- Try to configure.
Here is the output of the steps
Intel(R) MPI Library 2017 Update 4 for Windows* Target Build Environment for Intel(R) 64 applications
Copyright (C) 2007-2017 Intel Corporation. All rights reserved.
Copyright (C) 1985-2017 Intel Corporation. All rights reserved.
Intel(R) Compiler 17.0 Update 6 (package 270)
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.8
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
d:\src\foo\build>cmake --version
cmake version 3.12.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
d:\src\foo\build>where icl
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.6.270\windows\bin\intel64\icl.exe
d:\src\foo\build>where cl
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\cl.exe
d:\src\foo\build>set CC="C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.6.270\windows\bin\intel64\icl.exe"
d:\src\foo\build>set CXX=%CC%
d:\src\foo\build>cat ..\CMakeLists.txt
cmake_minimum_required(VERSION 3.12)
project(Foo LANGUAGES C CXX)
message(STATUS "CMAKE_SIZEOF_VOID_P: ${CMAKE_SIZEOF_VOID_P}")
message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
d:\src\foo\build>cmake -DCMAKE_C_COMPILER=%CC% -DCMAKE_CXX_COMPILER=%CXX% ..
-- Building for: Visual Studio 15 2017
-- The C compiler identification is MSVC 19.16.27027.1
-- The CXX compiler identification is MSVC 19.16.27027.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMAKE_SIZEOF_VOID_P: 4
-- CMAKE_C_COMPILER: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- CMAKE_CXX_COMPILER: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Configuring done
-- Generating done
-- Build files have been written to: D:/src/foo/build
Note that despite my best efforts to set C and CXX compilers to Intel 64-bit compiler, only Visual Studio's 32-bit compiler is picked up.
Why is CMake ignoring various measures to try and specify the compiler? They are clearly on the PATH. Why would it use a 32-bit Visual Studio compiler instead?