Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何为VS2019在忍者和叮当上添加包含路径?_C++_Visual Studio_Cmake_Clang_Ninja - Fatal编程技术网

C++ 如何为VS2019在忍者和叮当上添加包含路径?

C++ 如何为VS2019在忍者和叮当上添加包含路径?,c++,visual-studio,cmake,clang,ninja,C++,Visual Studio,Cmake,Clang,Ninja,因此,我想使用CMake和clang作为VS2019的前端,用额外的include路径构建我的项目 我已经尝试过的: CMakeLists.txt CMakeSettings.json test-llvm.cpp #包括 int main() { std::cout我修改了CMakeList.txt如下,似乎已经解决了 # CMakeList.txt : CMake project for test-llvm, include source and define # project

因此,我想使用CMake和clang作为VS2019的前端,用额外的include路径构建我的项目

我已经尝试过的:

  • CMakeLists.txt
  • CMakeSettings.json
  • test-llvm.cpp
#包括
int main()
{

std::cout我修改了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")

你试过了吗?试着添加
target\u include\u目录(test llvm PRIVATE“${CMAKE\u CURRENT\u SOURCE\u DIR}/include”)
。应该会有帮助的。谢谢你的有用评论。这似乎可以通过include\u directories命令解决。
{
  "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": []
    }
  ]
}
>------ Build All started: Project: test-llvm, Configuration: x64-Clang-Debug ------
  [1/2] C:\PROGRA~2\MIB055~1\2019\PROFES~1\COMMON7\IDE\COMMON~1\MICROS~1\Llvm\bin\clang-cl.exe  /nologo -TP   -m64 -fdiagnostics-absolute-paths  /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 /showIncludes /FoCMakeFiles\test-llvm.dir\test-llvm.cpp.obj /FdCMakeFiles\test-llvm.dir\ -c ..\..\..\test-llvm.cpp
  FAILED: CMakeFiles/test-llvm.dir/test-llvm.cpp.obj 
  C:\PROGRA~2\MIB055~1\2019\PROFES~1\COMMON7\IDE\COMMON~1\MICROS~1\Llvm\bin\clang-cl.exe  /nologo -TP   -m64 -fdiagnostics-absolute-paths  /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 /showIncludes /FoCMakeFiles\test-llvm.dir\test-llvm.cpp.obj /FdCMakeFiles\test-llvm.dir\ -c ..\..\..\test-llvm.cpp
C:\Users\stakemura\Dropbox\Documents\test-llvm\test-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 : 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")