It will now be explained how to set up a ContRap plugin library from scratch. You should preferably use the ContRap library assistant to create libraries. Creating a library from scratch is only neccessary if the assistant can not fulfill your special requirements.
First of all you should create a directory structure like the following:
cd MyPluginLib
mkdir src
mkdir src/library
mkdir src/plugins
The subdirectories below the src-level are required if you do not want to mix the implementation of your algorithms with ContRap-speciefic code.
The next important thing is to fetch the ContRap Cmake configuration files. If your directory structure is not integrated in a subversion repository, you should check out the Cmake directory directly using the following command called out of the MyPluginLib folder:
ln -s cmake-scripts/configure configure
If MyPluginLib is integrated in a subversion repository, it might be better to set the cmake-scripts as an external property of subversion by typing the following command out of the MyPluginLib folder:
svn up
ln -s cmake-scripts/configure configure
This fetches the externally hold CMake scripts for ContRap into your local copy.
The only thing remaining is to write the four CMakeLists.txt files in each directory of your newly created project. Below is shown how the root CMakeLists.txt file might look like.
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(MyPluginLib)
INCLUDE(cmake-scripts/host.cmake)
INCLUDE(cmake-scripts/contrap.cmake)
INCLUDE(cmake-scripts/plugins.cmake)
SUBDIRS(src)
The included .cmake files define macros used in the following CMakeLists.txt files. On the next level in the src folder the CMakeLists.txt looks as follows:
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
SUBDIRS(library plugins)
The src/library directory is not ContRap speciefic, so you can write what you want there. See the CMake documentation for details. The src/plugins directory creates a plugin library. The corresponding CMake file will now be discussed in some more detail.
USE_CONTRAP()
ADD_CONTRAP_LIBRARY(myplugins myplugin.crf mylibrary.cpp)
TARGET_LINK_LIBRARIES(myplugins core mylibrary)
USE_CONTRAP macro defines include and link paths needed to use ContRap as a development package. The macro ADD_CONTRAP_PLUGIN_LIBRARY takes the library name as a first argument. All others are names of plugin meta-description files (located in the same directory) or additional C++ source files, which should be added to the library. In our example a plugin from the file ''myplugin.crf'' and a C++ source file with the name ''mylibrary.cpp'' are added to the library ''myplugins''. The last command of the example script is the standard link command of CMake.
Of course it could be possible that you need additional CMake commands. For example this occurs if you want to install your library somewhere else, other than default.
To compile and to install the newly created library use the configure script
make
make install
This command configurates the library, performs an out-of-tree build in the BUILD_PATH directory and installs the file using the INSTALL_PATH directory as prefix. This defaults to install your plugin library to INSTALL_PATH/contrap.
After installing you can check if your plugin can be found by contrap.
Your should see your plugin reported as found in the output of the latter command. If you have installed your library to a non-default position (on Unix and MacOS it is /use/local/lib/contrap) you may need to specify the search path for contrap-config in one of the environment variables CONTRAP_PLUGIN_PATH and LD_LIBRARY_PATH (DYLD_LIBRARY_PATH on Mac OS). Notice that the second path might be needed to lookup for supplement libraries you install with your plugins.