# see https://github.com/zeromq/czmq/blob/master/Findlibzmq.cmake

find_path(LIBZMQ_INCLUDE_DIR NAMES zmq.h PATHS ${CONAN_INCLUDE_DIRS_ZMQ} NO_CMAKE_FIND_ROOT_PATH)
find_library(LIBZMQ_LIBRARY NAMES ${CONAN_LIBS_ZMQ} PATHS ${CONAN_LIB_DIRS_ZMQ} NO_CMAKE_FIND_ROOT_PATH)
set(LIBZMQ_FOUND ON)
set(LIBZMQ_INCLUDE_DIRS ${LIBZMQ_INCLUDE_DIR})
set(LIBZMQ_LIBRARIES ${LIBZMQ_LIBRARY})

message(STATUS "libzmq found by conan!")
message(STATUS "LIBZMQ_INCLUDE_DIR: ${LIBZMQ_INCLUDE_DIR}")
message(STATUS "LIBZMQ_LIBRARY: ${LIBZMQ_LIBRARY}")

if (DEFINED CONAN_LIBSODIUM_ROOT)
    find_library(SODIUM_LIBRARY NAMES ${CONAN_LIBS_LIBSODIUM} PATHS ${CONAN_LIB_DIRS_LIBSODIUM} NO_CMAKE_FIND_ROOT_PATH)

    set(LIBZMQ_LIBRARIES "${LIBZMQ_LIBRARIES};${SODIUM_LIBRARY}")

    if(DEFINED CONAN_LIBCXX)
      if(CONAN_LIBCXX STREQUAL "libstdc++" OR CONAN_LIBCXX STREQUAL "libstdc++11")
        set(LIBZMQ_LIBRARIES "${LIBZMQ_LIBRARIES};stdc++")
      elseif(CONAN_LIBCXX STREQUAL "libc++")
        set(LIBZMQ_LIBRARIES "${LIBZMQ_LIBRARIES};c++")
      endif()
    endif()

endif()
