#
# The find_package macro for Orocos-RTT works best with
# cmake >= 2.6.3
#
cmake_minimum_required(VERSION 2.6.3)

#
# This creates a standard cmake project. You may extend this file with
# any cmake macro you see fit.
#
project(Controller)

#
# Do setup in case of ros package, If ROS_ROOT is set, it is
# recommended to use RTT/OCL through the ros packages.
#
set (ROS_ROOT $ENV{ROS_ROOT} )
if (ROS_ROOT)
  include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
  rosbuild_init()
  rosbuild_find_ros_package( rtt )
  set( RTT_HINTS HINTS ${rtt_PACKAGE_PATH}/install )
endif()

# Set the CMAKE_PREFIX_PATH in case you're not using Orocos through ROS
# for helping these find commands find RTT.
find_package(OROCOS-RTT REQUIRED rtt-scripting rtt-marshalling ${RTT_HINTS})

message(STATUS " ++++++++ lib rtt-scripting ++++++  " ${OROCOS-RTT_RTT-SCRIPTING_LIBRARY})
message(STATUS " ++++++++ found lib rtt-scripting ++++++  " ${OROCOS-RTT_RTT-SCRIPTING_FOUND})

message(STATUS " ++++++++ lib rtt-marshalling ++++++  " ${OROCOS-RTT_RTT-MARSHALLING_LIBRARY})
message(STATUS " ++++++++ found rtt-marshalling ++++++  " ${OROCOS-RTT_RTT-MARSHALLING_FOUND})

# Defines the orocos_* cmake macros. See that file for additional
# documentation.
include(${OROCOS-RTT_USE_FILE_PATH}/UseOROCOS-RTT.cmake)

#
# Components, types and plugins.
#
# The CMake 'target' names are identical to the first argument of the
# macros below, except for orocos_typegen_headers, where the target is fully
# controlled by generated code of 'typegen'.
#

# Creates a component library libController-<target>.so
# and installs in the directory lib/orocos/Controller/
#
orocos_component(Controller Controller-component.hpp Controller-component.cpp) # ...you may add multiple source files
target_link_libraries(Controller ${OROCOS-RTT_RTT-SCRIPTING_LIBRARY} ${OROCOS-RTT_RTT-MARSHALLING_LIBRARY})
#
# You may add multiple orocos_component statements.

#
# Additional headers:
#
# Installs in the include/orocos/Controller/ directory
#
orocos_install_headers( Controller-component.hpp ) # ...you may add multiple header files
#
# You may add multiple orocos_install_headers statements.

#
# Building a Plugin
#
# Creates a plugin library libController-plugin-<target>.so
# and installs in the directory lib/orocos/Controller/plugins/
#
# Be aware that a plugin may only have the loadRTTPlugin() function once defined in a .cpp file.
# This function is defined by the plugin and service CPP macros.
#
orocos_plugin(Controller-plugin Controller-plugin.cpp) # ...only one plugin function per library !
#
# You may add multiple orocos_plugin statements.


#
# Building a Service:
#
# Creates a plugin library libController-service-<target>.so
# and installs in the directory lib/orocos/Controller/plugins/
#
orocos_service(Controller-service Controller-service.cpp) # ...only one service per library !
#
# You may add multiple orocos_service statements.


#
# Building a typekit (recommended):
#
# Creates a typekit library libController-types-<target>.so
# and installs in the directory lib/orocos/Controller/types/
#
orocos_typegen_headers(Controller-types.hpp) # ...you may add multiple header files
#
# You may only have *ONE* orocos_typegen_headers statement !


#
# Building a normal library (optional):
#
# Creates a library libsupport-<target>.so and installs it in
# lib/
#
orocos_library(support support.cpp) # ...you may add multiple source files
#
# You may add multiple orocos_library statements.


#
# Generates and installs our package. Must be the last statement such
# that it can pick up all above settings.
#
orocos_generate_package()
