
#
# I've split this into two libraries, because it was annoying that dozens of
# programs that only need stuff in seabedcommon had to be recompiled when I
# changes some slam stuff.
#
# Maybe it would be better to move the slam stuff into the tools/seabed_slam 
# directory, however the tests would need to be moved there
#
# The library seabedcommon shouldn't really exist. This stuff should be removed
# or moved into auv_data_tools or somewhere else
#
MESSAGE ("SEABED COMMON ${BUILD_SEABED_SLAM}")
SET( SEABED_COMMON_SRCS seabed_common.cpp 
                        speed_of_sound.cpp 
                        seabed_slam_file_io.cpp
                        colour_data.cpp )

ADD_LIBRARY( seabedcommon SHARED ${SEABED_COMMON_SRCS} )

TARGET_LINK_LIBRARIES( seabedcommon adt::adt
                                    libsnapper::snapper
                                    )

TARGET_INCLUDE_DIRECTORIES(seabedcommon INTERFACE $<INSTALL_INTERFACE:include/libseabedcommon>)


# Install the library on 'make install'
# this should be kept in sync with the binary package name
# and be updated when the ABI (not just API) changes
SET_PROPERTY(TARGET seabedcommon PROPERTY VERSION ${LIBSEABEDCOMMON_VERSION})
SET_PROPERTY(TARGET seabedcommon PROPERTY SOVERSION 1)
# Install the library on 'make install'
INSTALL(TARGETS seabedcommon EXPORT LibSeabedSlamTargets LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

IF (BUILD_SEABED_SLAM)
	SET( SEABED_SLAM_SRC stereo_match_image.cpp 
                     mission_processing.cpp
                     seabed_slam_renderer.cpp
                     seabed_slam_display.cpp
                     seabed_slam_params.cpp
                     seabed_interface.cpp
                     ellipse_intersect.cpp 
                     overlap_probability.cpp 
                     circle_overlap.cpp
                     relative_pose_manager.cpp 
                     stereo_feature_manager.cpp 
                     lc_hypoth_generator.cpp
                     lc_search.cpp
                     odom_search.cpp
                     pose_cache_reader.cpp
                     relative_pose_cache.cpp 
                     stereo_feature_cache.cpp )

	ADD_LIBRARY( seabedslam SHARED ${SEABED_SLAM_SRC} )
	TARGET_LINK_LIBRARIES( seabedslam seabedcommon 
                                  libplankton::plankton
                                  libflounder::flounder
                                  libkeypoint::keypoint

                                  ${Boost_THREAD_LIBRARY}
                                  ${Boost_SYSTEM_LIBRARY}
                                  ${OPENCV_LIBRARIES}
                                  ${HDF5_LIBRARIES}
                                  ${CHOLMOD_LIB}
                                  ${UF_LIBRARY}
                                  ${LAPACK_LIBRARY}

                                  lib3drender::3dRender
                                  lib3dobjects::3dObjects
                                  ${SDL_LIBRARY}
                                  ${GTK2_LIBRARIES}
                                  ${GTKGLEXT_LIBRARIES} 
                                  ${OPENGL_LIBRARIES}
                                )

	TARGET_INCLUDE_DIRECTORIES(seabedslam INTERFACE $<INSTALL_INTERFACE:include/libseabedcommon>)


	
	# Install the library on 'make install'
	# this should be kept in sync with the binary package name
	# and be updated when the ABI (not just API) changes
	SET_PROPERTY(TARGET seabedslam PROPERTY VERSION ${LIBSEABEDSLAM_VERSION})
	SET_PROPERTY(TARGET seabedslam PROPERTY SOVERSION 1)
	# Install the library on 'make install'
	INSTALL(TARGETS seabedslam EXPORT LibSeabedSlamTargets LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
ENDIF(BUILD_SEABED_SLAM)

