set(binary)

add_subdirectory(idl )
add_subdirectory(utils )
add_subdirectory(monitor )
add_subdirectory(libraries )
add_subdirectory(examples )

# Directories for includes (-I)
include_directories(
  ${OMNIORB4_INCLUDE_DIR}
  ${PROJECT_BINARY_DIR}/src/idl
  ${PROJECT_SOURCE_DIR}/src/utils
)

# List of all sources files for forwarder
set(Forwarder_SOURCES
  SSHTunnel.cc
  Options.cc
  LogForwarder.cc
  LogORBMgr.cc
)



install(FILES LogORBMgr.hh DESTINATION ${INCLUDE_INSTALL_DIR})

# Creation de l'executable logForwarder
add_executable(logForwarder
  logFwdr.cc
)

## Creation d'une librairie LogForwarder
add_library(LogForwarderUtils
  ${Forwarder_SOURCES}
 )

set_target_properties (LogForwarderUtils PROPERTIES VERSION ${LOGSERVICE_VERSION})
find_package (AR)

# If building a static lib, gathering all the objects with ar (cannot link .a together)
if (NOT BUILD_SHARED_LIBS)

  get_target_property (AR_RES LogForwarderUtils LOCATION)

  ADD_CUSTOM_COMMAND(
    TARGET LogForwarderUtils
    COMMAND ${CMAKE_AR}
    ARGS ${AR_ARGS} ${AR_RES} ${binary}
   )
endif (NOT BUILD_SHARED_LIBS)

target_link_libraries(LogForwarderUtils
  ${OMNIORB4_LIBRARIES}
  LogServiceMonitor
  pthread
 )

add_dependencies(LogForwarderUtils CORBAFiles)

install(TARGETS LogForwarderUtils DESTINATION ${LIB_INSTALL_DIR})


target_link_libraries(logForwarder
  ${OMNIORB4_LIBRARIES}
  LogForwarderUtils
)

install(TARGETS logForwarder DESTINATION ${BIN_INSTALL_DIR})
