如何在忍者上添加包含路径,并为VS 2019添加叮当
How to add include path on Ninja and clang for VS 2019?
>所以,我想使用 CMake 和 clang 作为 VS2019 的前端,使用额外的包含路径构建我的项目。
我已经尝试过的:
- CMakeList.txt
# CMakeList.txt : CMake project for test-llvm, include source and define
# project specific logic here.
#
cmake_minimum_required (VERSION 3.8)
# Add source to this project's executable.
add_executable (test-llvm "test-llvm.cpp" "test-llvm.h")
# TODO: Add tests and install targets if needed.
set(INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
- CMakeSettings.json
{
"configurations": [
{
"name": "x64-Clang-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${projectDir}\out\build\${name}",
"installRoot": "${projectDir}\out\install\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x64" ],
"variables": []
},
{
"name": "x86-Clang-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\out\build\${name}",
"installRoot": "${projectDir}\out\install\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x86" ],
"variables": []
}
]
}
- test-llvm.cpp
#include <needtoinclude.h>
int main()
{
std::cout << "Hello world" << std::endl;
}
- test-llvm.h (Empty(
- 包括
- /需要包括.h
#pragma once
#include <iostream>
以及我得到哪些错误:
>------ Build All started: Project: test-llvm, Configuration: x64-Clang-Debug ------
[1/2] C:PROGRA~2MIB055~12019PROFES~1COMMON7IDECOMMON~1MICROS~1Llvmbinclang-cl.exe /nologo -TP -m64 -fdiagnostics-absolute-paths /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 /showIncludes /FoCMakeFilestest-llvm.dirtest-llvm.cpp.obj /FdCMakeFilestest-llvm.dir -c ......test-llvm.cpp
FAILED: CMakeFiles/test-llvm.dir/test-llvm.cpp.obj
C:PROGRA~2MIB055~12019PROFES~1COMMON7IDECOMMON~1MICROS~1Llvmbinclang-cl.exe /nologo -TP -m64 -fdiagnostics-absolute-paths /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 /showIncludes /FoCMakeFilestest-llvm.dirtest-llvm.cpp.obj /FdCMakeFilestest-llvm.dir -c ......test-llvm.cpp
C:UsersstakemuraDropboxDocumentstest-llvmtest-llvm.cpp(1,13): fatal error : 'needtoinclude.h' file not found
<U+FEFF>#include <needtoinclude.h>
^~~~~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
Build All failed.
我应该怎么做才能添加包含路径?
我修改了CMakeList.txt如下所示。似乎解决了。
# CMakeList.txt : CMake project for test-llvm, include source and define
# project specific logic here.
#
cmake_minimum_required (VERSION 3.8)
# Add source to this project's executable.
add_executable (test-llvm "test-llvm.cpp" "test-llvm.h")
# TODO: Add tests and install targets if needed.
include_directories("include")
相关文章:
- QAbstractTableModel,并为单行发出dataChanged
- 如何使用Crypto++并为RSA返回可打印的字节/字符数组
- Cmake:为 C 设置警告级别,并为 MSVC 单独设置C++代码(Visual C++)
- 如何读取文本文件中的数据并为每列 c++ 分配数组
- 访问列表中的所有 std::变体,并为每次访问捕获附加值
- c++ 如何在数组的开头添加值并为其编制索引?
- 我正在尝试编写将 ASCII 转换为十进制、添加并转换回 ASCII 的软件
- 创建一个类来访问和指定向量类型,并构建一个获取位置并为其分配区域的类
- 是否可以在 c++ 中创建一个文件并为其提供属性以将其隐藏?(在 Ubuntu 上)
- 谷歌测试发现在macOSX上添加并运行了我的所有测试两次
- 具有模板的树类,并为子级动态分配
- 在编译时将两个或多个不同大小的数组合并为一个数组
- 仅为特定条件重置变量的值,并为其他所有条件重置固定值
- 如何在忍者上添加包含路径,并为VS 2019添加叮当
- 如何在类中初始化数组并为第一个元素设置值
- 如何使用任何类型的数组创建模板类并为其设置值?
- Qt创建动态对象并为同一信号分配不同的功能
- WinAPI:OpenProcess()返回错误5,并为主机进程启用SeDebugPrivilege
- 如何使用const_reference类型来声明一个变量并为其赋值 front() 函数的返回值
- c++ -从其他对象继承std::元组,并为其添加虚函数