# This file is part of the Owl Positioning System (OwlPS) project.
# It is subject to the copyright notice and license terms in the
# COPYRIGHT.t2t file found in the top-level directory of this
# distribution and at
#   https://code.lm7.fr/mcy/owlps/src/master/COPYRIGHT.t2t
# No part of the OwlPS Project, including this file, may be copied,
# modified, propagated, or distributed except according to the terms
# contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be
# distributed along with this file, either separately or by replacing
# this notice by the COPYRIGHT.t2t file's contents.

### Options ###

option(OWLPS_CLIENT_RECEIVES_POSITION
  "Enable -l (receive the computed position from the Positioner)"
  off)

configure_file(
  owlps-client-config.h.in
  "${GENERATED_INCLUDE}/owlps-client-config.h")


### Targets ###

add_executable(owlps-client owlps-client.c)
target_link_libraries(owlps-client
  libowlps.so
  libowlps-client.so)
if (OWLPS_CLIENT_RECEIVES_POSITION)
  target_link_libraries(owlps-client
    libowlps-resultreader.so)
endif()
install(
  TARGETS owlps-client
  DESTINATION bin)

add_executable(owlps-client.semistatic EXCLUDE_FROM_ALL
  owlps-client.c)
target_link_libraries(owlps-client.semistatic
  libowlps.a
  libowlps-client.a)
if (OWLPS_CLIENT_RECEIVES_POSITION)
  target_link_libraries(owlps-client.semistatic
    libowlps-resultreader.a)
endif()
# Add the semistatic target to the global list of semistatic targets
list(APPEND OWLPS_SEMISTATIC_TARGETS owlps-client.semistatic)
set(OWLPS_SEMISTATIC_TARGETS ${OWLPS_SEMISTATIC_TARGETS} PARENT_SCOPE)

add_executable(owlps-client.static EXCLUDE_FROM_ALL
  owlps-client.c)
set_target_properties(owlps-client.static
  PROPERTIES LINK_FLAGS -static)
target_link_libraries(owlps-client.static
  libowlps.a
  libowlps-client.a)
if (OWLPS_CLIENT_RECEIVES_POSITION)
  target_link_libraries(owlps-client.static
    libowlps-resultreader.a)
endif()
# Add the static target to the global list of static targets
list(APPEND OWLPS_STATIC_TARGETS owlps-client.static)
set(OWLPS_STATIC_TARGETS ${OWLPS_STATIC_TARGETS} PARENT_SCOPE)

# Add compile flags for the above targets
set_target_properties(
  owlps-client
  owlps-client.semistatic
  owlps-client.static
  PROPERTIES COMPILE_FLAGS ${EXE_FLAGS})
