## Learning High-order Random Fields for Smoothed Labeling
##    Authors:
##             Daniel Munoz
##             Drew Bagnell
##             Nicolas Vandapel
##             Martial Hebert
##
##
## http://www.cs.cmu.edu/~dmunoz/projects/m3n.html
##
## Reference Papers:
##
##  D. Munoz, J. A. Bagnell, N. Vandapel, M. Hebert "Contextual Classification with Functional Max-Margin Markov Networks" (CVPR2009)
##  D. Munoz, N. Vandapel, M. Hebert "Onboard Contextual Classification of 3-D Point Clouds with Learned High-order Markov Random Fields" (ICRA2009)
##  D. Munoz, J. A. Bagnell, M. Hebert "On Two Methods for Semi-Supervised Structured Prediction" (CMU-RI-TR-10-02, 2010)
##
##  License: Modified BSD
##

project (struct_predict_smooth)

cmake_minimum_required (VERSION 2.4.6)

if(COMMAND cmake_policy)
     cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/m3n/examples)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

#####
# path to eigen2 library
set(EIGEN_INCLUDE_PATH /usr/include/eigen2)

#####
# find BOOST and its graph library
find_package( Boost COMPONENTS graph REQUIRED)
if(Boost_FOUND)
  include_directories(${Boost_INCLUDE_DIRS})
  MESSAGE(STATUS "Boost_LIB_VERSION: " ${Boost_LIB_VERSION})
  MESSAGE(STATUS "Boost_INCLUDE_DIRS are: " ${Boost_INCLUDE_DIRS})
  MESSAGE(STATUS "Boost_GRAPH_LIBRARY is: " ${Boost_GRAPH_LIBRARY})
  MESSAGE(STATUS "boost_LIBRARY_DIRS is: " ${Boost_LIBRARY_DIRS})
  MESSAGE(STATUS "Boost_LIBRARIES is: " ${Boost_LIBRARIES})
endif()

#####
# find OpenCV
FIND_PACKAGE( OpenCV REQUIRED )
  if(OpenCV_FOUND)
    MESSAGE(STATUS "Found OpenCV libraries at ${OpenCV_LIBRARIES} and include files at ${OpenCV_INCLUDE_DIRS}")
    set(SPEC_OPENCV_LIBS libopencv_features2d.so libopencv_imgproc.so libopencv_calib3d.so libopencv_highgui.so libopencv_core.so libopencv_ml.so)
  endif(OpenCV_FOUND)
include_directories(${OpenCV2_INCLUDE_DIRS})

#####
# gomp lib requirement:
set(SPEC_GOMP_LIBS libgomp.so)


include_directories (submodular_graphcut/include/ m3n/include/ ${EIGEN_INCLUDE_PATH})

add_library(submodular_graphcut SHARED
  submodular_graphcut/src/submodular_graphcut.cc
  submodular_graphcut/src/graphcut_bgl.cc
)

add_library(${PROJECT_NAME} SHARED
  m3n/src/m3n_model.cc
  m3n/src/m3n_model_inference.cc
  m3n/src/m3n_model_learning.cc
  m3n/src/functional_m3n.cc
  m3n/src/parametric_m3n.cc
  m3n/src/random_field.cc
  m3n/src/random_field_io_wg.cc
  m3n/src/regressors/linear_regression.cc
  m3n/src/regressors/regressor_wrapper.cc
  m3n/src/regressors/ocv_rtree_wrapper.cc
)

add_executable(example m3n/examples/example.cc)
target_link_libraries(example ${PROJECT_NAME} submodular_graphcut ${SPEC_OPENCV_LIBS} ${SPEC_GOMP_LIBS})
