# Author:
#   Sven Czarnian <devel@svcz.de>
# License:
#   GPLv3
# Brief:
#   Creates the 3rd-party import targets

# include the external project library
INCLUDE(ExternalProject)

# define the import target of libsodium
ADD_LIBRARY(libsodium STATIC IMPORTED)
IF (MSVC)
    SET_TARGET_PROPERTIES(libsodium PROPERTIES
        IMPORTED_IMPLIB_DEBUG "${CMAKE_SOURCE_DIR}/external/lib/libsodiumd.lib"
        IMPORTED_IMPLIB_RELEASE "${CMAKE_SOURCE_DIR}/external/lib/libsodium.lib"
    )
    TARGET_INCLUDE_DIRECTORIES(libsodium INTERFACE "${CMAKE_SOURCE_DIR}/external/include")
ELSE ()
    MESSAGE(FATAL_ERROR "Unsupported compiler")
ENDIF ()

# define the import target of libzmq
ADD_LIBRARY(libzmq STATIC IMPORTED)
ADD_DEPENDENCIES(libzmq libsodium)
IF (MSVC)
    SET_TARGET_PROPERTIES(libzmq PROPERTIES
        IMPORTED_IMPLIB_DEBUG "${CMAKE_SOURCE_DIR}/external/lib/libzmqd.lib"
        IMPORTED_IMPLIB_RELEASE "${CMAKE_SOURCE_DIR}/external/lib/libzmq.lib"
    )
    TARGET_INCLUDE_DIRECTORIES(libzmq INTERFACE "${CMAKE_SOURCE_DIR}/external/include")
ELSE ()
    MESSAGE(FATAL_ERROR "Unsupported compiler")
ENDIF ()

# define the import target of cppzmq
ADD_LIBRARY(cppzmq INTERFACE)
TARGET_INCLUDE_DIRECTORIES(cppzmq INTERFACE "${CMAKE_SOURCE_DIR}/external/include")
ADD_DEPENDENCIES(cppzmq libzmq)

# define the import target of GSL
ADD_LIBRARY(GSL INTERFACE)
TARGET_INCLUDE_DIRECTORIES(GSL INTERFACE "${CMAKE_SOURCE_DIR}/external/include")

# define the import target of protobuf
ADD_LIBRARY(protobuf STATIC IMPORTED)
IF (MSVC)
    SET_TARGET_PROPERTIES(protobuf PROPERTIES
        IMPORTED_LOCATION_DEBUG "${CMAKE_INSTALL_PREFIX}/lib/libprotobufd.lib"
        IMPORTED_LOCATION_RELEASE "${CMAKE_INSTALL_PREFIX}/lib/libprotobuf.lib"
    )
    TARGET_INCLUDE_DIRECTORIES(protobuf INTERFACE "${CMAKE_INSTALL_PREFIX}/include")
ELSE ()
    MESSAGE(FATAL_ERROR "Unsupported compiler")
ENDIF ()
