2014-03-26 33 views
1

我发现了这样的东西,但它不起作用。不明白,用这里初始化变量show_contents_prog - 什么意思'猫'和'类型' 任何人都可以帮助正确的方式?CMake跨平台读取文件到变量

if (UNIX) 
    set (show_contents_prog cat) 
elseif (WIN32) 
    set (show_contents_prog type) 
endif (WIN32) 

execute_process(COMMAND ${show_contents_prog} input.txt OUTPUT_VARIABLE file_contents) 

回答

3

我想你想要什么CMake的file(READ ...)命令:

file(READ input.txt file_contents) 

至于cat在Unix系统或type在Windows上,他们基本上打印出指定的文件(S)的内容。