Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7942 Discussions

Using Intel C++ compiler with Visual Studio 2017/2019 cmake

Sergei
Beginner
3,125 Views

Currently we use Visual Studio 2017 targeting Windows with Visual Studio solutions/projects files.
We want to build/debug our product for both Windows/Linux and trying to use Visual Studio build with cmake.
According to docs.microsoft.com/en-us/cpp/build/cmakesettings-reference?view=vs-2019 :
---

Any custom environment can be used, or these predefined environments:
linux_arm: Target ARM Linux remotely.
linux_x64: Target x64 Linux remotely.
linux_x86: Target x86 Linux remotely.
msvc_arm: Target ARM Windows with the MSVC compiler.
msvc_arm_x64: Target ARM Windows with the 64-bit MSVC compiler.
msvc_arm64: Target ARM64 Windows with the MSVC compiler.
msvc_arm64_x64: Target ARM64 Windows with the 64-bit MSVC compiler.
msvc_x64: Target x64 Windows with the MSVC compiler.
msvc_x64_x64: Target x64 Windows with the 64-bit MSVC compiler.
msvc_x86: Target x86 Windows with the MSVC compiler.
msvc_x86_x64: Target x86 Windows with the 64-bit MSVC compiler.

(though config dialog also mentions Mingw64 as an option).

Can you give recommendations how to configure VS 2017/2019 cmake to use Intel C++ compiler on both Windows and Linux?

Regards,

Sergei.

0 Kudos
4 Replies
Viet_H_Intel
Moderator
3,125 Views

After you "source /intalled_dir compilervars.csh", then see where gcc/g++ are called in your Makefile thenchange to icc/icpc

0 Kudos
Sergei
Beginner
3,125 Views

Viet,

Thank you for your response.

CMake generates Makefile files (Unix Makefile generator is configured for CMake only for Linux build files output). For Windows, VS2017/2019 with CMake generates Ninja build files.

Therefore, your advice is not applicable.

Regards,

Sergei.

0 Kudos
Sergei
Beginner
3,125 Views

How to use Intel C++ compiler with VS2017/VS219 CMake "open folder" workflow, I give example for VS2019 and Intel C++ compiler update 4:

1. Create vs2019.cmd with the following text:

---

call "C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.245\windows\bin\ipsxe-comp-vars.bat" intel64 vs2019
start "VS2019" /B "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\devenv.exe"

---

2. . Click on vs2019.cmd.

3. In VS2019 edit your CMakeSettings.json config file, add the following (for Release configuration):

---

    {
      "name": "x64-IntelEnv-Release",
      "description": "Start visual studio from Intel C++ compiler environment cmd window",
      "generator": "Ninja",
      "configurationType": "Release",
      "buildRoot": "${workspaceRoot}\\..\\cmake-build\\${name}",
      "installRoot": "${workspaceRoot}\\..\\cmake-install\\${name}",
      "cmakeCommandArgs": "",
      "buildCommandArgs": "-v",
      "ctestCommandArgs": "",
      "inheritEnvironments": [ "msvc_x64_x64" ],
      "variables": [
        {
          "name": "CMAKE_CXX_COMPILER",
          "value": "icl.exe",
          "type": "FILEPATH"
        },
        {
          "name": "CMAKE_C_COMPILER",
          "value": "icl.exe",
          "type": "FILEPATH"
        }
      ]
    }

---
4. Select "x64-IntelEnv-Release" in "Configurations" dropbox. Build.

 

0 Kudos
BullyWiiPlaza
Beginner
499 Views

Hi, can you please provide clarification for this StackOverflow question I posted regarding your instructions to use the Intel compiler with CMake in Visual Studio 2022.

Thank you!

0 Kudos
Reply