首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >有没有一种使用英特尔编译器运行cmake的方法?

有没有一种使用英特尔编译器运行cmake的方法?
EN

Stack Overflow用户
提问于 2022-11-03 11:12:30
回答 2查看 69关注 0票数 0

我试图使用英特尔编译器运行一个程序,但在编译程序时显示了错误。是因为cmake。

代码语言:javascript
运行
复制
cmake -G "Visual Studio 17 2022" -A x64 -T "Intel(R) oneAPI DPC++ Compiler" ..
-- CMAKE_BUILD_TYPE is unset, defaulting to Release
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.25099.
CMake Error at CMakeLists.txt:81 (project):
Failed to run MSBuild command:
C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe
to get the value of VCTargetsPath:
MSBuild version 17.3.1+2badb37d1 for .NET Framework
Build started 9/2/2022 10:51:43 AM.
Project "C:\Users\mtc\source\repos\onednn\build\CMakeFiles\3.23.1\VCTargetsPath.vcxproj" on node 1 (default targets).
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(460,5): error MSB8020: The build tools for Intel(R) oneAPI DPC++ Compiler (Platform Toolset = 'Intel(R) oneAPI DPC++ Compiler') cannot be found. 
To build using the Intel(R) oneAPI DPC++ Compiler build tools, please install Intel(R) oneAPI DPC++ Compiler build tools. 
Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\mtc\source\repos\onednn\build\CMakeFiles\3.23.1\VCTargetsPath.vcxproj]
Done Building Project "C:\Users\mtc\source\repos\onednn\build\CMakeFiles\3.23.1\VCTargetsPath.vcxproj" (default targets) -- FAILED

"C:\Users\mtc\source\repos\onednn\build\CMakeFiles\3.23.1\VCTargetsPath.vcxproj" (default target) (1) ->
(PrepareForBuild target) ->
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(460,5): error MSB8020: The build tools for Intel(R) oneAPI DPC++ Compiler (Platform Toolset = 'Intel(R) oneAPI DPC++ Compiler') cannot be found. To build using the Intel(R) oneAPI DPC++ Compiler build tools,
please install Intel(R) oneAPI DPC++ Compiler build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\mtc\source\repos\onednn\build\CMakeFiles\3.23.1\VCTargetsPath.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.15
Exit code: 1
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-11-09 11:09:45

忍者是唯一与CMake oneAPI DPC++编译器协同工作的DPC++生成器。

如果您想使用Intel oneAPI DPC++编译器,请遵守以下链接中的说明:build.html#id1

若要使用Intel NextGen编译器,请使用以下命令:

代码语言:javascript
运行
复制
cmake -G ""Visual Studio 17 2022"" -T ""Intel C++ Compiler 2022"" ...
票数 1
EN

Stack Overflow用户

发布于 2022-11-03 14:01:15

有几件事可能会导致你的问题。

  1. 确保编译器已加载在当前命令环境中。对于英特尔编译器,这通常是C:\Program Files (x86)\Intel\oneAPI\setvars.bat
  2. 确保已安装的CMake版本比您试图使用的工具集更新。具体来说,CMake version > 3.22.2 if you are using intel 2022.
  3. 您的CMakeLists.txt没有发布,但是根据英特尔的文档,您需要添加

此外,一旦您能够构建目标,我建议您切换到使用CMakePresets.json文件来配置您的CMake构建。我有一个是这样的:

在此预置文件中,缓存变量INTEL_COMPILER用于打开/关闭CMakeLists.txt中的特定英特尔编译器标志,如/fp:precise

CMakePresets.json

代码语言:javascript
运行
复制
{
    "version": 3,
    "cmakeMinimumRequired": {
    "major": 3,
    "minor": 22,
    "patch": 2
    },
    "configurePresets": [
    {
        "name": "base",
        "hidden": true,
        "binaryDir": "${sourceDir}/_build/${presetName}"
    },
    {
        "name": "Windows",
        "hidden": true,
        "inherits": [
        "base"
        ],
        "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Windows"
        },
        "vendor": {
        "microsoft.com/VisualStudioSettings/CMake/1.0": {
            "hostOS": "Windows"
        }
        }
    },
    {
        "name": "Debug",
        "hidden": true,
        "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Debug"
        }
    },
    {
        "name": "Release",
        "hidden": true,
        "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Release"
        }
    },
    {
        "name": "Intel - IDE",
        "hidden": true,
        "toolset": "Intel C++ Compiler 2022",
        "cacheVariables": {
        "INTEL_COMPILER": "ON"
        }
    },
    {
        "name": "Visual Studio 2022 - Intel",
        "displayName": "Visual Studio 2022 using Intel compiler",
        "inherits": [
        "Windows",
        "Intel - IDE"
        ],
        "generator": "Visual Studio 17 2022"
    }
    ],
    "buildPresets": [
    {
        "name": "Windows",
        "hidden": true,
        "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Windows"
        },
        "vendor": {
        "microsoft.com/VisualStudioSettings/CMake/1.0": {
            "hostOS": "Windows"
        }
        }
    },
    {
        "name": "Visual Studio 2022 - Intel",
        "displayName": "Visual Studio 2022 using Intel compiler",
        "inherits": [
        "Windows"
        ],
        "configurePreset": "Visual Studio 2022 - Intel"
    }
    ]
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74302175

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档