cmake_minimum_required(VERSION 2.8.3)
project(hos_cosgi_sitemap)

## Find catkin macros and libraries
find_package(catkin REQUIRED COMPONENTS
  hos_celix
  hos_cosgi_webserver
  hos_cosgi_devicerepository
  hos_cosgi_core
  hos_cpp_utils
  hos_deps
  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_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_sitemap")
set(BUNDLE_VERSION "1.0.0")
set(BUNDLE_NAME "hos_sitemap")

bundle(hos_cosgi_sitemap
	SOURCES 
	${PROJECT_SOURCE_DIR}/src/BundleActivator
	${PROJECT_SOURCE_DIR}/src/hos/cosgi/service/sitemap/SitemapServiceImpl
	${PROJECT_SOURCE_DIR}/src/hos/cosgi/service/sitemap/webresource/SitemapHandler
	${PROJECT_SOURCE_DIR}/src/hos/cosgi/service/sitemap/sitemap_template/SitemapTemplateImpl
)

target_link_libraries(hos_cosgi_sitemap
	${catkin_LIBRARIES}
	${APR_LIBRARIES}
	${libvariant_LIBRARY}
	${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_sitemap.zip
	DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/bundles
)

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

foreach(dir launch schema examples)
  install(DIRECTORY ${dir}/
    DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/${dir}
  )
endforeach(dir)


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

find_package(Doxygen)
if(DOXYGEN_FOUND)
	add_custom_target(doc)
endif(DOXYGEN_FOUND)

