ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
add_executable(
  fibonacci_server src/fibonacci_server.cpp
  fibonacci_client src/fibonacci_client.cpp
)

I can't answer the first part of your question, but the above is not how add_executable(..) works.

See the CMake documentation for add_executable(..):

Add an executable to the project using the specified source files.

add_executable(<name> [WIN32] [MACOSX_BUNDLE]
               [EXCLUDE_FROM_ALL]
               source1 [source2 ...])

Adds an executable target called <name> to be built from the source files listed in the command invocation. The <name> corresponds to the logical target name and must be globally unique within a project. The actual file name of the executable built is constructed based on conventions of the native platform (such as <name>.exe or just <name>.

The first argument to add_executable(..) is the name of a single executable, with all the following arguments being the source files that together make up the binary.

In your CMake snippet, you seem to have intended to build both executables with a single add_executable(..). As should now be clear, that doesn't work.

The tutorial you linked to also doesn't do that, it has the server in its own add_executable(..) (here) and the client as well (here).

Finally: even if this were possible from the CMake side, it still wouldn't work: there can only be a single entry point in any executable binary and both the server and the client have a main(..).

add_executable(
  fibonacci_server src/fibonacci_server.cpp
  fibonacci_client src/fibonacci_client.cpp
)

I can't answer the first part of your question, but the above is not how add_executable(..) works.

See the CMake documentation for add_executable(..):

Add an executable to the project using the specified source files.

add_executable(<name> [WIN32] [MACOSX_BUNDLE]
               [EXCLUDE_FROM_ALL]
               source1 [source2 ...])

Adds an executable target called <name> to be built from the source files listed in the command invocation. The <name> corresponds to the logical target name and must be globally unique within a project. The actual file name of the executable built is constructed based on conventions of the native platform (such as <name>.exe or just <name>.

The first argument to add_executable(..) is the name of a single executable, with all the following arguments being the source files that together make up the binary.

In your CMake snippet, you seem to have intended to build both executables with a single add_executable(..). As should now be clear, that doesn't work.

The tutorial you linked to also doesn't do that, that (note the: "Add the following lines to your CMakeLists.txt"), it has the server in its own add_executable(..) (here) and the client as well (here).

Finally: even if this were possible from the CMake side, it still wouldn't work: there can only be a single entry point in any executable binary and both the server and the client have a main(..).