cmake:在Windows上找不到LIBCLANG_PATH

时间:2019-01-31 07:29:06

标签: c++ windows cmake llvm-clang libclang

我正在尝试编写一个简单的cAST游标游标。

https://github.com/dyhe83/clang-AST-cursor-traveler

下面的cmake代码在Linux上可以正常使用。

PROJECT(traveler)

FIND_LIBRARY(LIBCLANG_PATH
    clang HINTS /usr/local/lib/
)

ADD_EXECUTABLE(traveler 
    traveler.cpp
)

TARGET_LINK_LIBRARIES(traveler
    ${LIBCLANG_PATH}
)

我也想在Windows上运行此示例。

我的LLVM构建在“ C:\ Program Files(x86)\ LLVM”中 folder

但是在我更改了CMakeLists.txt的FIND_LIBRARY部分之后。

FIND_LIBRARY(LIBCLANG_PATH
    clang HINTS "C:\\Program Files (x86)\\LLVM\\lib"
)

发生一些错误:

D:\WorkSpace\C\clang-AST-cursor-traveler\build>cmake ..
-- Building for: Visual Studio 15 2017
-- The C compiler identification is MSVC 19.16.27025.1
-- The CXX compiler identification is MSVC 19.16.27025.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIBCLANG_PATH
    linked by target "traveler" in directory D:/WorkSpace/C/clang-AST-cursor-traveler/src

-- Configuring incomplete, errors occurred!
See also "D:/WorkSpace/C/clang-AST-cursor-traveler/build/CMakeFiles/CMakeOutput.log".

“ C:\ Program Files(x86)\ LLVM \ lib”具有这些库。 LibClang

有人知道Windows上正确的clang库路径在哪里吗?

1 个答案:

答案 0 :(得分:0)

尝试在Windows中设置环境。 我的意思是您添加/编辑PATH环境变量的地方

LIBCLANG_PATH = C:\ Program Files(x86)\ LLVM \ lib