cmake_minimum_required(VERSION 2.8.3)

project(robot_face)

find_package(catkin REQUIRED 
	roscpp
	roslib
	std_msgs
	sensor_msgs
	message_generation
	genmsg
	image_transport
	cv_bridge
	cmake_modules
)

#set the default path for built executables to the "bin" directory
#INSTALL(CODE "FILE(MAKE_DIRECTORY \${ENV}\${CMAKE_INSTALL_PREFIX}${mydir})")
#set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
#set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)


set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Use OGRE from ROS
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} /usr/share/OGRE/cmake/modules)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${ogre_PACKAGE_PATH}/ogre/include/OGRE")
# QT related
set(CMAKE_INCLUDE_PATH "/usr/share/qt4/include")
set(QT_USE_QTXML TRUE)

add_definitions(-DROS_INDIGO=1)



#for face output
find_package(OGRE)
#for GUI visualization
find_package(Qt4 REQUIRED COMPONENTS QtCore QtGui)
#for speak out
find_package(Festival)
#festival depends on that
find_package(EST)
#for resizing image
find_package(OpenCV REQUIRED)

add_message_files(
	FILES
		ImageDisplay.msg
		ImageFileDisplay.msg
)

generate_messages(
	DEPENDENCIES
		sensor_msgs
)

###########
## Build ##
###########

#set build type
#set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE Release)	

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(include
	SYSTEM
	${catkin_INCLUDE_DIRS}
	${QT_INCLUDE_DIR}
	${Festival_INCLUDE_DIR}
	${EST_INCLUDE_DIR}
	${OGRE_INCLUDE_DIR}
	#/usr/include/OGRE/
	#../../../../experimental/Libraries/
	#$ENV{HOMER_DIR}
)
include(${QT_USE_FILE}) 

catkin_package(
		CATKIN_DEPENDS roscpp message_runtime std_msgs sensor_msgs
)

## Declare source files
set(RobotFace_SRC
	src/main.cpp
	src/MainWindow.cpp
	src/TalkingHead.cpp
	src/TextOutDisplay.cpp
	src/QtRosNode.cpp
	src/FestivalGenerator.cpp
	src/RotationLabel.cpp
	src/TextProcessor.cpp
	src/ImageDisplay.cpp
)

# Declare header files (needed to specify all include files for wrapping with QT4)
set(RobotFace_INC
	include/MainWindow.h
	include/TalkingHead.h
	include/TextOutDisplay.h
	include/QtRosNode.h
	include/FestivalGenerator.h
	include/RotationLabel.h
	include/ImageDisplay.h
)

QT4_WRAP_CPP(RobotFace_MOC_SRC ${RobotFace_INC})

add_executable(FestivalSynthesizer src/FestivalSynthesizer.cpp src/TextProcessor.cpp )
add_executable(RobotFace ${RobotFace_SRC} ${RobotFace_MOC_SRC})

# fix archlinux build
list(APPEND Festival_LIBRARIES curses)



add_dependencies(RobotFace ${PROJECT_NAME}_gencpp roscpp_serialization)

target_link_libraries(FestivalSynthesizer
	${catkin_LIBRARIES}
	${Festival_LIBRARIES}
	${EST_LIBRARIES}
	pulse-simple
)

target_link_libraries(RobotFace
	${catkin_LIBRARIES}
	${QT_LIBRARIES}
	${OGRE_LIBRARIES}
	${Festival_LIBRARIES}
	${EST_LIBRARIES}
	pthread
)

install(TARGETS FestivalSynthesizer DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
install(TARGETS RobotFace DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
install(DIRECTORY include/ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})

#############
## Testing ##
#############

## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_ptu.cpp)
# if(TARGET ${PROJECT_NAME}-test)
#	 target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()

## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
