2.3.4. Compile SmartSoft Component Projects

To be able to use the developed components during system composition, they have to be compiled. To do so, right click on the SmartSoft component project and choose "Compile SmartMDSD Project" (cf. figure 2.24).

Compile SmartSoft Component Project

Figure 2.24. Compile SmartSoft Component Project


If the SmartSoft component project has to be compiled without the toolchain, navigate to the component and enter the following commands:

	mkdir build
	cd build
	cmake ..
	make
					

In every component project and every communication/coordination repository folder, you will find a cmake file CMakeLists.txt. This file can be adjusted to add component-specific library dependencies.

2.3.4.1. Add Additional Libraries

In order to add external library dependencies (which should provide a cmake package definition) the following lines have to be added to the file CMakeLists.txt:

	FIND_PACKAGE(<library> REQUIRED <components>)
	GET_PROPERTY(<library>_INCLUDE_DIRS DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
	LIST(APPEND USER_INCLUDES ${<library>_INCLUDE_DIRS})
	LIST(APPEND USER_LIBS ${<library>_LIBS})

If, for example, the libraries mrpt-base and mrpt-gui should be added, the following lines have to be used:

	FIND_PACKAGE(MRPT REQUIRED base gui)
	GET_PROPERTY(MRPT_INCLUDE_DIRS DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
	LIST(APPEND USER_INCLUDES ${MRPT_INCLUDE_DIRS})
	LIST(APPEND USER_LIBS ${MRPT_LIBS})
					

For further information on how to create cmake package-definitions for external libraries see: https://cmake.org/Wiki/CMake:How_To_Find_Libraries

System libraries (e.g. installed in /usr/lib) can be added as follows:

	LIST(APPEND USER_LIBS "<library>")

The library libbluetooth, for example, can be added as follows:

	LIST(APPEND USER_LIBS "bluetooth")
					

2.3.4.2. Add Compiler Flags

Additional compiler flags can be added to the CMakeLists.txt as follows:

	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -<compiler flag>")

For instance, in order to add the compiler flag "ENABLE_HASH" use this line:

	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_HASH")
					

2.3.4.3. Add Your Own Source Files

All user source files inside of the src/ folder that have the ending .cc or .hh will be automatically included into the build process of the component. In order to use a custom subfolder inside of the src/ folder add the following lines to the CMakeLists.txt file:

	FILE(GLOB SRCS src/<directory>/*.cc)
	LIST(APPEND USER_SRCS ${SRCS})
	LIST(APPEND USER_INCLUDES src/<directory>/)

An example can be found in the SmartVisualization component. The following lines were used to add the source files of the directory "visualization":

	FILE(GLOB SRCS src/visualization/*.cc)
	LIST(APPEND USER_SRCS ${SRCS})
	LIST(APPEND USER_INCLUDES src/visualization/)
					

In case the subdirectory contains an own cmake project, use the following approach instead:

	ADD_SUBDIRECTORY(<path>)
	LIST(APPEND USER_INCLUDES <path>)
	LIST(APPEND USER_LIBS <libraries>)

An example is shown in the component SmartXsensIMUMTiServer:

	ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/src/xsensSDK)
	LIST(APPEND USER_INCLUDES ${PROJECT_SOURCE_DIR}/src/xsensSDK/Software_Development/CMTsrc)
	LIST(APPEND USER_LIBS XSense)
					

Here is an example cmake project (for the XSense SDK):

	SmartXsensIMUMTiServer/src/xsensSDK/CMakeLists.txt:

	PROJECT(XSense)

	FILE(GLOB SRCS ${PROJECT_SOURCE_DIR}/Software_Development/CMTsrc/*.cpp)
	FILE(GLOB HDRS ${PROJECT_SOURCE_DIR}/Software_Development/CMTsrc/*.h)

	INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/Software_Development/CMTsrc)

	ADD_LIBRARY(${PROJECT_NAME} STATIC ${SRCS} ${HDRS})
					

WordPress Appliance - Powered by TurnKey Linux