Are CMake GLOB and source_group compatible?
Posted
by jwfearn
on Stack Overflow
See other posts from Stack Overflow
or by jwfearn
Published on 2010-06-01T04:19:47Z
Indexed on
2010/06/01
4:23 UTC
Read the original article
Hit count: 432
cmake
I'm using CMake 2.8.0 (on Windows) with the "Visual Studio 10 Win64" generator. GLOB
and source_group
don't seem to work together. Is there a way to get this to work?
I use file( GLOB ... )
to create a list of .cpp
files and then use source_group
to create a filter in the generated Visual Studio project:
# 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} )
with line 6 commented out, the project is generated fine:
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
with line 6 un-commented, I get an error:
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!
I notice that output value of ${HELLO_SRCS}
does not seem to contain any delimiters between the file names, nor does it have quotes or other delimiters wrapping the file names which contain spaces. Does that have anything to do with my problem? Renaming all directories to avoid spaces is not really an option.
© Stack Overflow or respective owner