【发布时间】:2010-06-01 04:19:47
【问题描述】:
我正在使用 CMake 2.8.1(在 Windows 上)和 "Visual Studio 10" 生成器。 GLOB 和 source_group 似乎不能一起工作。有没有办法让它工作?
我使用file( GLOB ... ) 创建.cpp 文件列表,然后使用source_group 在生成的Visual Studio 项目中创建一个过滤器:
# C:\Users\My Name\hello\CMakeLists.txt
cmake_minimum_required( VERSION 2.8 )
project( hello_proj )
file( GLOB HELLO_SRCS *.cpp )
message( "HELLO_SRCS="${HELLO_SRCS} )
#source_group( hello_group ${HELLO_SRCS} ) #line 6: uncomment to get error
add_executable( hello_exec ${HELLO_SRCS} )
注释掉第6行,项目生成正常:
C:\Users\My Name\hello>cmake .
HELLO_SRCS=C:/Users/My Name/hello/hello.cppC:/Users/My Name/hello/print_line.cpp
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/My Name/hello
第 6 行未注释,我得到一个错误:
C:\Users\My Name\hello>cmake .
HELLO_SRCS=C:/Users/My Name/hello/hello.cppC:/Users/My Name/hello/print_line.cpp
CMake Error at CMakeLists.txt:6 (source_group):
source_group Unknown argument "C:/Users/My Name/hello/hello.cpp".
Perhaps the FILES keyword is missing.
-- Configuring incomplete, errors occurred!
我注意到${HELLO_SRCS} 的输出值似乎不包含文件名之间的任何分隔符,也没有引号或其他分隔符包裹包含空格的文件名。这跟我的问题有关系吗?重命名所有目录以避免空格并不是一个真正的选择。
【问题讨论】:
标签: cmake