使用带有空白的CMake的include_directories命令 [英] Using CMake's include_directories command with white spaces
问题描述
我正在使用CMake构建项目,并且有以下内容:
I am using CMake to build my project and I have the following line:
include_directories(${LLVM_INCLUDE_DIRS})
,在评估LLVM_INCLUDE_DIRS
之后,其评估结果为:
which, after evaluating LLVM_INCLUDE_DIRS
, evaluates to:
include_directories(C:\Program Files\LLVM\include)
问题在于,这被认为是两个包含目录,即"C:\ Program"和"Files \ LLVM \ include".
The problem is that this is being considered two include directories, "C:\Program" and "Files\LLVM\include".
有什么主意我该如何解决这个问题?我尝试使用引号,但没有用.
Any idea how can I solve this problem? I tried using quotation marks, but it didn't work.
编辑:原来问题出在文件llvm-3.0\share\llvm\cmake\LLVMConfig.cmake
中.我用引号将以下路径括起来,问题已解决:
It turned out that the problem is in the file llvm-3.0\share\llvm\cmake\LLVMConfig.cmake
. I enclosed the following paths with quotation marks and the problem was solved:
set(LLVM_INSTALL_PREFIX C:/Program Files/LLVM)
set(LLVM_INCLUDE_DIRS ${LLVM_INSTALL_PREFIX}/include)
set(LLVM_LIBRARY_DIRS ${LLVM_INSTALL_PREFIX}/lib)
推荐答案
在设置LLVM_INCLUDE_DIRS
时,这很可能是错误,而不是include_directories
的问题.
This is more likely to be an error at the point where LLVM_INCLUDE_DIRS
is set rather than a problem with include_directories
.
要对此进行检查,请尝试致电include_directories("C:\\Program Files\\LLVM\\include")
-它应该可以正常工作.
To check this, try calling include_directories("C:\\Program Files\\LLVM\\include")
- it should work correctly.
问题似乎是LLVM_INCLUDE_DIRS
是在不使用引号的情况下构造的.尝试例如运行以下命令:
The problem seems to be that LLVM_INCLUDE_DIRS
was constructed without using quotation marks. Try for example running this:
set(LLVM_INCLUDE_DIRS C:\\Program Files\\LLVM\\include)
message("${LLVM_INCLUDE_DIRS}")
set(LLVM_INCLUDE_DIRS "C:\\Program Files\\LLVM\\include")
message("${LLVM_INCLUDE_DIRS}")
输出为:
C:\Program;Files\LLVM\include
C:\Program Files\LLVM\include
请注意第一条输出行中的分号.这是一个包含2个项目的列表.
Note the semi-colon in the first output line. This is a list with 2 items.
因此解决此问题的方法是修改LLVM_INCLUDE_DIRS
的创建方式.
So the way to fix this is to modify the way in which LLVM_INCLUDE_DIRS
is created.
这篇关于使用带有空白的CMake的include_directories命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!