# ----------------------------------------------------------------------------
#  Root CMake file for Android pcl_perception Build
#
#    To build with cmake
#        $ mkdir build
#        $ cd build
#        $ cmake-gui .. 
#               set the path for flann, cminpack, eigen, boost, pcl standalone
#        $ make
#    Make sure to set the path in the cache for the crystax ndk available 
#    here:
#          http://www.crystax.net/android/ndk-r4.php
#
#   - initial version August 2010, for OpenCV port, 
#           by Ethan Rublee ethan.ruble@gmail.com
#   - Changed December 2010 for pcl_perception
#
# ----------------------------------------------------------------------------
project(pcl_perception)

cmake_minimum_required(VERSION 2.8)

#include the AndroidModule.cmake to allow generation of android stuff.
set(ANDROID_CMAKE_DIR ${CMAKE_SOURCE_DIR}/../android_cmake CACHE PATH 
    "The android cmake scripts     directory")
include(${ANDROID_CMAKE_DIR}/AndroidModule.cmake REQUIRED)

set(perception_pcl_root ${CMAKE_SOURCE_DIR}/../../ CACHE PATH "perception_pcl root directory")

#find flann
set(flann_root ${perception_pcl_root}/flann/build/flann-1.6.6-src CACHE PATH "flann-1.6.6-src directory")
if(NOT EXISTS ${flann_root}/src/cpp)
message(FATAL_ERROR "Cannot find flann!" )
endif()
set(flann_src_cpp ${flann_root}/src/cpp)

#find cminpack
set(cminpack_root ${perception_pcl_root}/cminpack/build/cminpack-1.1.1 CACHE PATH "the cminpack root directory")
if(NOT EXISTS ${cminpack_root})
message(FATAL_ERROR "Cannot find cminpack!" )
endif()

#find Eigen
set(eigen_root "${CMAKE_SOURCE_DIR}/eigen/eigen_local/eigen" CACHE PATH "eigen3 root directory,
try eigen/get_eigen.sh")
if(NOT EXISTS ${eigen_root}/Eigen)
message(FATAL_ERROR "Cannot find eigen! try eigen/get_eigen.sh, or point to an existing eigen source dir." )
endif()

#find Boost 1.4.5
set(boost_root "${CMAKE_SOURCE_DIR}/boost/boost_local/boost_1_45_0" CACHE PATH "boost includes")
if(NOT EXISTS ${boost_root}/boost)
message(FATAL_ERROR "Cannot find boost! use the boost/get_boost.sh script to get and patch boost" )
endif()

#find the pcl stand alone dir
set(pcl_root "${CMAKE_SOURCE_DIR}/pcl/pcl_local/pcl-0.7.0" CACHE PATH "pcl tarball directory
try using the pcl/get_pcl_standalone.sh")

if(NOT EXISTS ${pcl_root})
message(FATAL_ERROR "Cannot find pcl!" )
endif()

#these should be in the dependency order
set(APP_MODULES 
pcl_kdtree 
pcl_keypoints 
pcl_range_image
pcl_range_image_border_extractor 
pcl_registration 
pcl_sample_consensus 
pcl_surface
pcl_segmentation 
pcl_io
pcl_features
pcl_filters 
pcl_base 
boost-system 
boost-filesystem
flann 
cminpack
)

set(APP_INCLUDES 
${pcl_root}/src
${pcl_root}/include 
${pcl_root}/include/roslib 
${pcl_root}/include/sensor_msgs 
${eigen_root} 
${cminpack_root} 
${flann_src_cpp} 
${boost_root}
)

gen_android_project(pcl_perception "${APP_MODULES}" "${APP_INCLUDES}")

add_subdirectory(${CMAKE_SOURCE_DIR}/flann "${JNI_DIR}/flann")
add_subdirectory(${CMAKE_SOURCE_DIR}/cminpack "${JNI_DIR}/cminpack")
add_subdirectory(${CMAKE_SOURCE_DIR}/pcl "${JNI_DIR}/pcl")
add_subdirectory(${CMAKE_SOURCE_DIR}/boost "${JNI_DIR}/boost")

android_status()
