option(Boost_USE_STATIC_LIBS "Use static version of Boost" ${LIB3DV_Boost_USE_STATIC_LIBS})

# this is to make sure we are going to use the same version of boost as lib3dv
set(BOOST_INCLUDEDIR ${LIB3DV_Boost_INCLUDE_DIR} CACHE STRING "")
set(BOOST_LIBRARYDIR ${LIB3DV_Boost_LIBRARY_DIR} CACHE STRING "")
set(BOOST_NO_SYSTEM_PATHS ON CACHE BOOL "")

option(USE_ARCHIVE "Use LibArchive for zip and tar support" ON)

if(USE_ARCHIVE)
    option(LibArchive_USE_STATIC_LIBS "Use static version of LibArchive" OFF)
    find_package(LibArchive REQUIRED)
    add_definitions(-DARCHIVE)

    if(BUILD_STATIC_EXECUTABLE)
        find_package(ZLIB REQUIRED)
    endif()
endif()

option(USE_PCL "Use PCL for live data display" ON)

if(USE_PCL)
    set(PCL_DIR "" CACHE STRING "PCL installation directory")
    find_package(PCL 1.7 REQUIRED COMPONENTS common io visualization)
    add_definitions(-DPCL ${PCL_DEFINITIONS})
    set(PCL_SOURCES display.cc interactor_style_3dv.cc playback.cc)
endif()

find_package(Boost COMPONENTS date_time filesystem program_options serialization system thread REQUIRED)
find_package(Threads REQUIRED)

if(UNIX)
    set(LINUX_X11 X11)
endif()

if(WIN32)
    add_definitions(-DBOOST_ALL_NO_LIB -D_WIN32_WINNT=0x0501 -DNOMINMAX)
    set(WIN32_LIBRARIES iphlpapi)
endif()

add_executable(3dv-client file.cc main.cc utils.cc disk_writer.cc ${PCL_SOURCES})

include_directories(${Boost_INCLUDE_DIR} ${LibArchive_INCLUDE_DIR} ${PCL_INCLUDE_DIRS} ${LIB3DV_INCLUDE_DIRS})

target_link_libraries(3dv-client
    ${LIB3DV_LIBRARIES}
    ${Boost_DATE_TIME_LIBRARY}
    ${Boost_FILESYSTEM_LIBRARY}
    ${Boost_PROGRAM_OPTIONS_LIBRARY}
    ${Boost_SERIALIZATION_LIBRARY}
    ${Boost_SYSTEM_LIBRARY}
    ${Boost_THREAD_LIBRARY}
    ${CMAKE_THREAD_LIBS_INIT}
    ${LibArchive_LIBRARY}
    ${PCL_COMMON_LIBRARIES}
    ${PCL_IO_LIBRARIES}
    ${PCL_VISUALIZATION_LIBRARIES} vtkFiltering
    ${ZLIB_LIBRARY}
    ${WIN32_LIBRARIES}
    ${LINUX_X11})

set_target_properties(3dv-client PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
