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}
  ${LOGSERVICE_BINARY_DIR}/src/idl
  ${LOGSERVICE_SOURCE_DIR}/src/utils
)

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


## Compile CorbaCommon static library
add_library(CorbaCommon STATIC
  LogORBMgr.cc
)


install( FILES LogORBMgr.hh DESTINATION include/ )

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

# CorbaCommon library depends on CORBA files
add_dependencies(CorbaCommon CORBAFiles)

## 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}
  CorbaCommon
  LogServiceMonitor
  pthread
  )

install(TARGETS LogForwarderUtils DESTINATION lib)


target_link_libraries(logForwarder
  ${OMNIORB4_LIBRARIES}
  LogForwarderUtils
)

install(TARGETS logForwarder DESTINATION bin)
