cmake_minimum_required(VERSION 2.8.3)
project(<%- pkgInfo.name %>)

## Start Global Marker
## End Global Marker

## Check C++11 / C++0x
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
    set(CMAKE_CXX_FLAGS "-std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
    set(CMAKE_CXX_FLAGS "-std=c++0x")
else()
    message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()

find_package(catkin REQUIRED COMPONENTS
<%
if (pkgInfo.Message_list || pkgInfo.Service_list || pkgInfo.Action_list) {
-%>
  message_generation
<%
}
-%>
  roscpp
  rosmod_actor
  # external packages that we depend on
  <%- pkgInfo.PackageDependencies.join(' ') %>
)

<% 
if (pkgInfo.Service_list) { 
-%>
# Generate services in the 'srv' folder
add_service_files(
  FILES
<%   
  pkgInfo.Service_list.map(function(srv) { 
-%>
  <%- srv.name %>.srv
<%
  }); 
-%>
)
<%
} 
-%>

<%
if (pkgInfo.Message_list) { 
-%>
# Generate messages in the 'msg' folder
add_message_files(
  FILES
<%
  pkgInfo.Message_list.map(function(msg) { 
-%>
  <%- msg.name %>.msg
<%
  }); 
-%>
)
<%
} 
-%>

<%
if (pkgInfo.Action_list) { 
-%>
# Generate actions in the 'action' folder
add_action_files(
  FILES
<%
  pkgInfo.Action_list.map(function(act) { 
-%>
  <%- act.name %>.action
<%
  }); 
-%>
)
<%
} 
-%>

<%
if (pkgInfo.Message_list || pkgInfo.Service_list || pkgInfo.Action_list) {
-%>
# Generate added messages and services with any dependencies listed here
generate_messages(
  DEPENDENCIES
  <%- pkgInfo.GenerateMessageDependencies.join(' ') %>
)
<%
}
-%>

#
## catkin specific configuration 
#
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
<%
if (pkgInfo.Component_list) {
-%>
  INCLUDE_DIRS include
<%
}
-%>
#  LIBRARIES client_server_package
#  CATKIN_DEPENDS roscpp std_msgs
<%
if (pkgInfo.Message_list || pkgInfo.Service_list || pkgInfo.Action_list) {
-%>
  CATKIN_DEPENDS <%- pkgInfo.PackageDependencies.join(' ') %>
<%
}
-%>
<%
if (pkgInfo.Message_list || pkgInfo.Service_list || pkgInfo.Action_list) {
-%>
  CATKIN_DEPENDS message_runtime
<%
}
-%>
#  DEPENDS system_lib
)

#
## Build 
#

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
<%
if (pkgInfo.Component_list) {
-%>
	include
    <%- pkgInfo.CMAKE_INCLUDES.join('\n') %>
<%
}
-%>
	${catkin_INCLUDE_DIRS})

<%- pkgInfo.CMAKE_COMMANDS.join('\n') %>

<%
if (pkgInfo.Component_list) {
  pkgInfo.Component_list.map(function(cmp) {
-%>
add_library(<%- cmp.name %>
            src/<%- pkgInfo.name %>/<%- cmp.name %>.cpp
<%
if (cmp['State Machine_list']) {
  cmp['State Machine_list'].map(function(hfsm) {
-%>
            include/<%- pkgInfo.name %>/<%- cmp.name %>_HFSM/<%- hfsm.sanitizedName %>_GeneratedStates.cpp
<%
});
}
-%>
            )
target_link_libraries(<%- cmp.name %>
                      ${catkin_LIBRARIES}
                      <%- cmp.LinkLibraries.join(' ') %>
                      )
<%
    if (cmp.Dependencies.length) {
-%>
add_dependencies(<%- cmp.name %>
                 <%- cmp.Dependencies.join(' ') %>
		 )
<%
    }
-%>
<%
  });
} 
-%>
