Cmake非常简单的设置失败

时间:2013-04-17 23:37:11

标签: 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} )

我在CMakeLists.txt旁边只有一个名为“helloWorld.cpp”的源文件。我创建了一个名为“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!

在每次试用之前,我删除了编译中的所有文件。我只是无法弄清楚缺少什么以及为什么设置变量..没有设置......没用?

非常感谢你的帮助。

1 个答案:

答案 0 :(得分:1)

你可能像我一样从网页上复制了同样的损坏文本。文本中必须有一些隐藏的字符。手动重写线也解决了它。