cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
include(${TOOLS_DIR}/common.cmake)


#-----------------------------------------------------------------------------------------
# Library name and version (Defined by user)
#   Check http://apr.apache.org/versioning.html for library version numbering rules
#-----------------------------------------------------------------------------------------
SetProjNameVer(vslam_opencv 0 0 1)

if("${ARCH}" MATCHES "a15")
add_definitions(-DARCH_A15)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -mfloat-abi=hard -fexceptions")
endif()

include_directories(
	${CMAKE_CURRENT_SOURCE_DIR}/include
)


#-----------------------------------------------------------------
#	Set Sources
#-----------------------------------------------------------------

set(CMAKE_CURRENT_SOURCE_DIR_ORIG ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR_ORIG}/calib3d)
include(${CMAKE_CURRENT_SOURCE_DIR}/CmakeLists.txt)
set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR_ORIG}/core)
include(${CMAKE_CURRENT_SOURCE_DIR}/CmakeLists.txt)
set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR_ORIG}/features2d)
include(${CMAKE_CURRENT_SOURCE_DIR}/CmakeLists.txt)
set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR_ORIG}/flann)
include(${CMAKE_CURRENT_SOURCE_DIR}/CmakeLists.txt)
set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR_ORIG}/imgcodecs)
include(${CMAKE_CURRENT_SOURCE_DIR}/CmakeLists.txt)
set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR_ORIG}/imgproc)
include(${CMAKE_CURRENT_SOURCE_DIR}/CmakeLists.txt)
set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR_ORIG}/video)
include(${CMAKE_CURRENT_SOURCE_DIR}/CmakeLists.txt)
set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR_ORIG}/videoio)
include(${CMAKE_CURRENT_SOURCE_DIR}/CmakeLists.txt)
set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR_ORIG}/xfeatures2d)
include(${CMAKE_CURRENT_SOURCE_DIR}/CmakeLists.txt)

set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR_ORIG})
#set(PUBLIC_HEADER ${${PROJECT_NAME}_HEADER})


					   
#-----------------------------------------------------------------------------------------
# Library to be generated
#-----------------------------------------------------------------------------------------
#configure_files(${CMAKE_CURRENT_SOURCE_DIR}/include/
#               ${PACKAGES_INSTALL_DIR}/${PROJ_NAME}-${PACKAGE_VER}-${ARCH}/include/
#			   )
			   
GenLibWithNanopbSupport()

#-----------------------------------------------------------------------------------------
# Create config and version cmake files
# http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file
#-----------------------------------------------------------------------------------------
ConfigPkgDescFiles()


#-----------------------------------------------------------------------------------------
# Definitions of install targets libraries, headers and dev
#-----------------------------------------------------------------------------------------
InstallAll()
#install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/opencv DESTINATION ${PACKAGES_INSTALL_DIR}/${PROJ_NAME}-${PACKAGE_VER}-${ARCH}/include)
#install(FILES flann/libflann.a DESTINATION lib )
# add custom installs as needed
	

#-----------------------------------------------------------------------------------------
# Test application
#-----------------------------------------------------------------------------------------


#------------------------------------------------------	-----------------------------------
#Packaging
#-----------------------------------------------------------------------------------------
Packaging()


# Publish target specific header
add_custom_command(TARGET vslam_opencv  POST_BUILD
                   COMMAND ${CMAKE_COMMAND} -E copy_directory
                       ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${PACKAGES_INSTALL_DIR}/${PROJ_NAME}-${PACKAGE_VER}-${ARCH}/include)
					   



