Cmake非常简单的设置失败
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cmake非常简单的设置失败相关的知识,希望对你有一定的参考价值。
我试着用最简单的helloworld例子开始使用cmake,在ubuntu 12.04,cmake 2.8.7中。首先我尝试了以下一个:
http://www.elpauer.org/stuff/learning_cmake.pdf
project( helloworld )
set( SRCFILES helloWorld.cpp )
add_executable( helloWorld ${SRCFILES} )
我只有一个名为“helloWorld.cpp”的源文件位于CMakeLists.txt旁边。我创建了一个名为“configure”的目录,进入内部并调用“cmake ..”。我得到以下内容:
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at CMakeLists.txt:3 (add_executable):
add_executable called with incorrect number of arguments
-- Configuring incomplete, errors occurred!
试图找出我得到的所有错误以下所有变化:
project( helloworld )
set( SRCFILES helloWorld.cpp )
message ( "src ${SRCFILES}" )
set(x helloWorld.cpp)
set(y 2)
message(${x}${y})
message(${x}${y})
message(${SRCFILES})
add_executable( helloWorld ${SRCFILES} )
add_executable( helloWorld ${x} )
add_executable( helloWorld helloWorld.cpp )
结果再次完成:
...
-- Detecting CXX compiler ABI info - done
src
helloWorld.cpp2
helloWorld.cpp2
CMake Error at CMakeLists.txt:8 (message):
message called with incorrect number of arguments
CMake Error at CMakeLists.txt:10 (add_executable):
add_executable called with incorrect number of arguments
CMake Error at CMakeLists.txt:11 (add_executable):
add_executable called with incorrect number of arguments
CMake Error at CMakeLists.txt:12 (add_executable):
add_executable called with incorrect number of arguments
-- Configuring incomplete, errors occurred!
最后,琐碎
project( helloworld )
add_executable( helloWorld helloWorld.cpp )
失败:
...
-- Detecting CXX compiler ABI info - done
CMake Error at CMakeLists.txt:2 (add_executable):
add_executable called with incorrect number of arguments
-- Configuring incomplete, errors occurred!
在每次试用之前,我删除编译中的所有文件。我只是无法弄清楚缺少什么以及为什么设置变量..没有设置......没用?
非常感谢您的帮助。
答案
你可能像我一样从网页上复制了同样的损坏文本。文本中必须有一些隐藏的字符。手动重写线也为我解决了。
以上是关于Cmake非常简单的设置失败的主要内容,如果未能解决你的问题,请参考以下文章