Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
803 Discussions

Use icx from cmake in VisualStudio 2022 (add into CMakePresets.json)

Daniel_D
Novice
1,213 Views

Hi,


I try to use the Intel icx compiler for a cmake based project in Visual Studio. To use it there are two steps required if I understood the process correctly from this guide:

 Automate the setvars.bat Script with Microsoft Visual Studio* (intel.com)
- modify the CMakePreset.json
- Add SETVARS_CONFIG environment variable pointing to the oneAPI setvars.bat file

here is what I did:

 

 

 

 

Changes in CMakePresets.json:
{
"name": "windows-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "icx-cl",
"CMAKE_CXX_COMPILER": "icx-cl"
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"intelliSenseMode": "windows-clang-x64"
}
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
}

 

 

 

 

 

Add the SETVARS_CONFIG var:

Daniel_D_0-1721020794786.png

 


I check the setvars.bat file in the location and verified that "icx-cl --version" works.

Daniel_D_0-1721021048266.png

(Need to use a screenshot since i always get an error sending this message as text:

Daniel_D_1-1721021114969.png

Note: there is not a single ampersand in this message - maybe a bit more AI wouldn't hurt!



 

 


This seems to be ok. If I now start VS and try to compile my project with cmake I get:

 

 

1> Working directory: W:/Libraries(CMAKE)/out/build/x64-debug
1> [CMake] -- The CXX compiler identification is unknown
1> [CMake] CMake Error at W:\Libraries(CMAKE)\CMakeLists.txt:2 (project):
1> [CMake] The CMAKE_CXX_COMPILER:
1> [CMake]
1> [CMake] icx-cl
1> [CMake]
1> [CMake] is not a full path and was not found in the PATH. Perhaps the extension is
1> [CMake] missing?
1> [CMake]
1> [CMake] Tell CMake where to find the compiler by setting either the environment
1> [CMake] variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
1> [CMake] to the compiler, or to the compiler name if it is in the PATH.

 

 

 

Tried to compile my project for WSL2 with these changes in CMakePresets.json:

    {
      "name": "linux-debug",
      "displayName": "Linux Debug",
      "generator": "Ninja",
      "binaryDir": "${sourceDir}/out/build/${presetName}",
      "installDir": "${sourceDir}/out/install/${presetName}",
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Debug",
        "CMAKE_C_COMPILER": "/opt/intel/oneapi/compiler/latest/bin/icx",
        "CMAKE_CXX_COMPILER": "/opt/intel/oneapi/compiler/latest/bin/icx"
      },
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Linux"
      },
      "vendor": {
        "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
          "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}",
          "intelliSenseMode": "windows-clang-x64"
        }
      }
    },

works without any issues!

 

 

Looks like setvars is not called on the VS start.

Any idea what I'm doing wrong?

Thanks

 

 

0 Kudos
0 Replies
Reply