VSCode不使用Vcpkg获得的库

时间:2018-08-04 09:43:26

标签: cmake visual-studio-code vcpkg

由于某些原因,VSCode无法在Vcpkg的已安装库目录中看到标头。我在Ubuntu 17.04上使用CMake构建系统。 我收到如下错误:

[GCC] GL/glew.h: No such file or directory

我的CMakeLists.txt看起来像这样:

cmake_minimum_required (VERSION 3.8)
set (CMAKE_CXX_STANDARD 17)

project ("RubeusCore")

FIND_PACKAGE(OpenGL REQUIRED)

# Include sub-projects.
add_subdirectory ("RubeusCore")

而RubeusCore / CMakeLists.txt是这样的:

cmake_minimum_required (VERSION 3.8)

link_directories(Source/)

file(GLOB_RECURSE SOURCES
    Source/*.cpp
)

# Add source to this project's executable.
add_executable (RubeusCore "RubeusCore.cpp" "RubeusCore.h" ${SOURCES})

target_include_directories(RubeusCore PUBLIC ./Include)
include_directories(${OPENGL_INCLUDE_DIRS})

target_link_libraries(RubeusCore ${OPENGL_LIBRARIES})

.vscode / c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "${vcpkgRoot}/x64-linux/include/"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/g++",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 4
}

此外,我一次在CMake中指定了Vcpkg工具链文件。

1 个答案:

答案 0 :(得分:0)

您可以尝试在 VSCODE settings.json

中添加 VCPKG Toolchain 文件
...

"cmake.configureSettings": {
        "CMAKE_TOOLCHAIN_FILE": "C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
}