ubuntu 12.04、cmake 2.8.7で、最も単純なhelloworldの例でcmakeの使用を開始しようとしています。まず、次のものを試しました:
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!
各試行の前に、コンパイル内のすべてのファイルを削除します。何が欠けているのか、変数が設定されている理由がわかりません..設定されていません...役に立たないのですか?
ご助力ありがとうございます。