Merge pull request #348 from ferdnyc/zmq-targets

ZeroMQ: Use IMPORTED targets
This commit is contained in:
Frank Dana
2019-11-01 14:50:52 -04:00
committed by GitHub
3 changed files with 53 additions and 28 deletions

View File

@@ -0,0 +1,39 @@
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
find_package(PkgConfig)
pkg_check_modules(PC_LIBZMQ QUIET libzmq)
set(ZeroMQ_VERSION ${PC_LIBZMQ_VERSION})
find_path(ZeroMQ_INCLUDE_DIR zmq.h PATHS ${PC_LIBZMQ_INCLUDE_DIRS} $ENV{ZMQDIR})
find_library(ZeroMQ_LIBRARY NAMES libzmq.so libzmq.dylib libzmq.dll
PATHS ${PC_LIBZMQ_LIBDIR} ${PC_LIBZMQ_LIBRARY_DIRS} $ENV{ZMQDIR})
find_library(ZeroMQ_STATIC_LIBRARY NAMES libzmq-static.a libzmq.a libzmq.dll.a
PATHS ${PC_LIBZMQ_LIBDIR} ${PC_LIBZMQ_LIBRARY_DIRS} $ENV{ZMQDIR})
if(ZeroMQ_LIBRARY OR ZeroMQ_STATIC_LIBRARY)
set(ZeroMQ_FOUND ON)
endif()
if (TARGET libzmq)
# avoid errors defining targets twice
return()
endif()
set(ZeroMQ_INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIR})
list(APPEND ZeroMQ_INCLUDE_DIRS ${PC_LIBZMQ_INCLUDE_DIRS})
list(REMOVE_DUPLICATES ZeroMQ_INCLUDE_DIRS)
add_library(libzmq SHARED IMPORTED)
set_property(TARGET libzmq PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ZeroMQ_INCLUDE_DIRS})
set_property(TARGET libzmq PROPERTY IMPORTED_LOCATION ${ZeroMQ_LIBRARY})
add_library(libzmq-static STATIC IMPORTED ${ZeroMQ_INCLUDE_DIRS})
set_property(TARGET libzmq-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ZeroMQ_INCLUDE_DIRS})
set_property(TARGET libzmq-static PROPERTY IMPORTED_LOCATION ${ZeroMQ_STATIC_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ZeroMQ
REQUIRED_VARS
ZeroMQ_LIBRARY ZeroMQ_INCLUDE_DIRS
VERSION_VAR
ZeroMQ_VERSION)

View File

@@ -123,19 +123,6 @@ IF (ENABLE_BLACKMAGIC)
ENDIF (BLACKMAGIC_FOUND)
ENDIF (ENABLE_BLACKMAGIC)
################### ZEROMQ #####################
# Find ZeroMQ library (used for socket communication & logging)
# Some platforms package the header-only cppzmq C++ bindings separately,
# others (Ubuntu) bundle them in with libzmq itself
find_package(cppzmq QUIET)
find_package(ZMQ REQUIRED)
# Include ZeroMQ headers (needed for compile)
include_directories(${ZMQ_INCLUDE_DIRS})
if (cppzmq_FOUND)
include_directories(${cppzmq_INCLUDE_DIRS})
endif()
################### RESVG #####################
# Find resvg library (used for rendering svg files)
@@ -330,13 +317,26 @@ endif()
target_link_libraries(openshot PUBLIC OpenMP::OpenMP_CXX)
################### ZEROMQ #####################
# Find ZeroMQ library (used for socket communication & logging)
find_package(ZeroMQ REQUIRED) # Creates libzmq target
# Some platforms package the header-only cppzmq C++ bindings separately,
# others (Ubuntu) bundle them in with libzmq itself
find_package(cppzmq QUIET) # Creates cppzmq target
# Include ZeroMQ headers (needed for compile)
target_link_libraries(openshot PUBLIC libzmq)
if (TARGET cppzmq)
target_link_libraries(openshot PUBLIC cppzmq)
endif()
############### LINK LIBRARY #################
SET ( REQUIRED_LIBRARIES
${LIBOPENSHOT_AUDIO_LIBRARIES}
${QT_LIBRARIES}
${PROFILER}
${ZMQ_LIBRARIES}
)
IF (RESVG_FOUND)

View File

@@ -114,20 +114,6 @@ IF (ENABLE_BLACKMAGIC)
ENDIF (ENABLE_BLACKMAGIC)
################### ZEROMQ #####################
# Find ZeroMQ library (used for socket communication & logging)
# Some platforms package the header-only cppzmq C++ bindings separately,
# others (Ubuntu) bundle them in with libzmq itself
find_package(cppzmq QUIET)
FIND_PACKAGE(ZMQ REQUIRED)
# Include ZeroMQ headers (needed for compile)
include_directories(${ZMQ_INCLUDE_DIRS})
if (cppzmq_FOUND)
include_directories(${cppzmq_INCLUDE_DIRS})
endif()
################### RESVG #####################
# Find resvg library (used for rendering svg files)
FIND_PACKAGE(RESVG)