cmake_minimum_required(VERSION 2.8.3)
project(hos_cosgi_devicerepository)

## Find catkin macros and libraries
find_package(catkin REQUIRED COMPONENTS
  hos_celix
  hos_core_msgs
  hos_cosgi_core
  hos_deps
  hos_cosgi_webserver
  hos_cpp_utils
  roscpp
)

## System dependencies are found with CMake's conventions
find_package(APR REQUIRED)
find_package(CELIX REQUIRED)
find_package(Boost REQUIRED)
find_package(libvariant REQUIRED)
find_package(Poco REQUIRED COMPONENTS Net NetSSL)


###################################
## catkin specific configuration ##
###################################

catkin_package(
	INCLUDE_DIRS include/${PROJECT_NAME}/
	CATKIN_DEPENDS hos_celix hos_core_msgs hos_cosgi_core roscpp hos_cpp_utils
)


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

add_definitions(
	-std=c++11
)

include_directories(
	include/${PROJECT_NAME}/
	${catkin_INCLUDE_DIRS}
	${APR_INCLUDE_DIR}
	${APR_INCLUDE_DIR}/apr-1.0
	${libvariant_INCLUDE_DIR}
	${Poco_INCLUDE_DIRS}
)

set(BUNDLE_SYMBOLICNAME "hos.hos_devicerepository")
set(BUNDLE_VERSION "1.0.0")
set(BUNDLE_NAME "hos_devicerepository")

bundle(hos_cosgi_devicerepository
	SOURCES 
	${PROJECT_SOURCE_DIR}/src/BundleActivator
	${PROJECT_SOURCE_DIR}/src/hos/cosgi/service/devicerepository/DeviceRepositoryServiceImpl
	${PROJECT_SOURCE_DIR}/src/hos/cosgi/service/devicerepository/webresource/DeviceRepoHandler
)

target_link_libraries(hos_cosgi_devicerepository
	${catkin_LIBRARIES}
	${APR_LIBRARIES}
	${libvariant_LIBRARY}
	${Poco_LIBRARIES}
)

message("Poco_LIBRARIES: ${Poco_LIBRARIES}")


#############
## Install ##
#############

## Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
	DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
	FILES_MATCHING PATTERN "*.h"
)

install(FILES
	${CMAKE_BINARY_DIR}/hos_cosgi_devicerepository.zip
	DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/bundles
)

install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc
   DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
   OPTIONAL
)


###################
## Documentation ##
###################

find_package(Doxygen)
if(DOXYGEN_FOUND)
	configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
	add_custom_target(doc
		${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
		WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
	)
endif(DOXYGEN_FOUND)

