# -*- mode: cmake; coding: utf-8; cmake-tab-width: 4; indent-tabs-mode: nil; -*- vim:fenc=utf-8:ft=cmake:et:sw=4:ts=4:sts=4

#========================================================================
# Discover if Octave is available and usable
#========================================================================
if (APPLE AND UNIX AND NOT DEFINED ENABLE_SWIG_OCTAVE)
    #--------------------------------------------------------------------
    # Currently there is an issue were SWIG and Octave are incompatable
    #   under MacPorts
    #--------------------------------------------------------------------
    set(ENABLE_SWIG_OCTAVE FALSE)
endif()
if ( NOT DEFINED ENABLE_SWIG_OCTAVE OR ENABLE_SWIG_OCTAVE )
    find_package(HDF5)
    find_package(Octave)
endif( )

if (OCTAVE_FOUND AND SWIG_FOUND)

  set( OCTAVE_VERSION_STRING ${OCTAVE_VERSION_STRING} PARENT_SCOPE )

  set( ENABLE_SWIG_OCTAVE "yes"
       CACHE BOOL "Control the building of the SWIG bindings for Octave" )
  find_library( OCTAVE_OCTAVE_LIBRARY
                NAMES octave
		HINTS ${OCTAVE_LINK_DIRS} )
  find_library( OCTAVE_INTERP_LIBRARY
                NAMES octinterp
		HINTS ${OCTAVE_LINK_DIRS} )
  set( OCTAVE_LIBRARIES
       ${OCTAVE_INTERP_LIBRARY}
       ${OCTAVE_OCTAVE_LIBRARY} )

else( )
  set( ENABLE_SWIG_OCTAVE "no"
       CACHE BOOL "Control the building of the SWIG bindings for Octave" FORCE )
endif(OCTAVE_FOUND AND SWIG_FOUND)

add_subdirectory(module)
add_subdirectory(test)

#========================================================================
# Provide additional information regarding components
#========================================================================

cpack_add_component(Octave
    DISPLAY_NAME "Octave extensions"
    DESCRIPTION
        "Pieces needed to use the nds2 client from Octave"
    GROUP Runtime)
