CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

# Project name which englobes all binaries
set(PROJECTNAME EpuckARTM)
PROJECT(${PROJECTNAME})

set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc-4.4)
set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++-4.4)

SET(CMAKE_C_FLAGS "-std=gnu99 -O0 -g")

set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )

# We define the source files for each different
# section within the src directory.
file(GLOB EPUCKFILES src/epuck/*.cc src/epuck/*.c)
file(GLOB TAMFILES src/epuck/taskAllocation/*.cc)

INCLUDE_DIRECTORIES(src/epuck/)
INCLUDE_DIRECTORIES(src/epuck/camera)
INCLUDE_DIRECTORIES(src/epuck/camera/cmvision)
INCLUDE_DIRECTORIES(src/epuck/ipc)
INCLUDE_DIRECTORIES(src/epuck/actionControl)
INCLUDE_DIRECTORIES(src/epuck/middleware)
#INCLUDE_DIRECTORIES(src/epuck/taskAllocation)

# We add the source files to the binary 
ADD_EXECUTABLE(Controller ${EPUCKFILES} ${TAMFILES})

#  WE ADD THE LIBRARIES IN ORDER TO LINK THE BINARY

# Action Allocation Related Libraries
#add_library(RTM src/epuck/taskAllocation/RTM.cc)
#add_library(ARTM src/epuck/taskAllocation/ARTM.cc)
add_library(Vector2D src/epuck/actionControl/Vector2D.cpp)
add_library(PathPlanner src/epuck/actionControl/PathPlanner.cc)
add_library(BaseActionController src/epuck/actionControl/BaseActionController.cpp)
add_library(SolitaryActionController src/epuck/actionControl/SolitaryActionController.cpp)
add_library(LocalBroadcasterActionController src/epuck/actionControl/LocalBroadcasterActionController.cpp)
add_library(BeeActionController src/epuck/actionControl/BeeActionController.cpp)
add_library(ReportTestActionController src/epuck/actionControl/ReportTestActionController.cpp)

# Vision Related Libraries
add_library(CMVision src/epuck/camera/cmvision/cmvision.cc)
add_library(Capture src/epuck/camera/cmvision/capture.cc)
add_library(V4l_helper src/epuck/camera/cmvision/v4l_helper.cc)
add_library(Camera src/epuck/camera/camera.cc)
TARGET_LINK_LIBRARIES(Camera CMVision Capture V4l_helper)

# Middleware Related Libraries
add_library(crc16 src/epuck/middleware/crc16.cc)
add_library(spicomm src/epuck/middleware/spicomm.cc)
add_library(EPuckBoardController src/epuck/middleware/EPuckBoardController.cc)
TARGET_LINK_LIBRARIES(EPuckBoardController spicomm crc16)

add_library(LinuxBoardController src/epuck/middleware/LinuxBoardController.cpp)

# IPC Communication Protocol Libraries
add_library(bytequeue src/epuck/ipc/bytequeue.c)
add_library(crc8 src/epuck/ipc/crc8.c)
add_library(ethlolmsg src/epuck/ipc/ethlolmsg.c)
add_library(IPC src/epuck/ipc/ipc.cc)
add_library(IPCInterface src/epuck/ipc/IPCInterface.cc)
TARGET_LINK_LIBRARIES(IPCInterface IPC bytequeue ethlolmsg crc8 Vector2D)


# We link the libraries to the target
TARGET_LINK_LIBRARIES(Controller ReportTestActionController BeeActionController LocalBroadcasterActionController SolitaryActionController BaseActionController PathPlanner Vector2D EPuckBoardController Camera IPCInterface LinuxBoardController -lpthread) 
