|
Code that implements your business logic, i.e. what your program shall actually do, shall be written in libraries. Libraries help to keep your components as small as possible, and to re-use code.
To create a library, the CMakeLists.txt needs to have the following content:
Dependencies may contain only a single ::
separator, which separates the project name from the target name. Hence, the target name itself may not contain ::
separators, so it cannot directly reflect the namespace structure. By convention, an underscore _
is used instead.
For example, if your project is named project_name
, and the target covers classes defined in the namespace project_name::tools::geometry
, the corresponding target name would be core_geometry
, resulting in the dependency name project_name::tools_geometry
.
Note that this convention can lead to ambiguities: An underscore might either separate namespaces, which should usually coincide with the folder structure, or correspond to a snake_case namespace.
For example, the dependency name project_name::tools_point_cloud
could either refer to the namespace project_name::tools::point_cloud
or (in this case less likely) project_name::tools::point::cloud
.
Use armarx_add_component
with the additional section ICE_DEPENDENCIES
.
Defining ARON targets and dependencies inside armarx_add_library
is and old and deprecated approach. Instead, use armarx_add_aron_library
. By convention, that target should have the same name as the library, extended by the suffix _aron
.
When dependencies of a target cannot be fulfilled, the target is silently disabled. Making cmake fail in such a case is currently not an option due to existing ArmarX packages.
A consequence might be that you cannot execute a component of your project, since it has not been built successfully. Even worse, it might happen that you run an old version of your component and wonder why your code changes do not change its behavior as expected. Thus, you might be interested in knowing whether targets failed.
The most direct option is to check the cmake output with cmake's default settings. This means to check whether after a line like
there is a following line like
A slightly more comfortable solution is to let cmake create a summary of the targets. To do so, e.g. ensure your workspace is activated, go to the build folder of your project and open cmake-gui:
Set the path of the source code and of the build directory. Then, enter e.g. summary
in the search field, to find the property ARMARX_CMAKE_ADDON_FEATURE_SUMMARY
. Enable it using the checkbox, and click configure.
Now, every time you execute cmake (including when doing so inside qtcreator), you will get a summary of targets that have or have not been built:
In the last category, you see a list of targets that have been disabled, which might not be what you had intended. Hence, you can more easily see whether problems have occurred.