Skip to content

Commit 49c3708

Browse files
authored
Merge branch 'develop' into threading-target
2 parents a79ffb6 + 4311b89 commit 49c3708

File tree

3 files changed

+95
-59
lines changed

3 files changed

+95
-59
lines changed

cmake/Modules/FindZeroMQ.cmake

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
2+
find_package(PkgConfig)
3+
pkg_check_modules(PC_LIBZMQ QUIET libzmq)
4+
5+
set(ZeroMQ_VERSION ${PC_LIBZMQ_VERSION})
6+
find_path(ZeroMQ_INCLUDE_DIR zmq.h PATHS ${PC_LIBZMQ_INCLUDE_DIRS} $ENV{ZMQDIR})
7+
8+
find_library(ZeroMQ_LIBRARY NAMES libzmq.so libzmq.dylib libzmq.dll
9+
PATHS ${PC_LIBZMQ_LIBDIR} ${PC_LIBZMQ_LIBRARY_DIRS} $ENV{ZMQDIR})
10+
find_library(ZeroMQ_STATIC_LIBRARY NAMES libzmq-static.a libzmq.a libzmq.dll.a
11+
PATHS ${PC_LIBZMQ_LIBDIR} ${PC_LIBZMQ_LIBRARY_DIRS} $ENV{ZMQDIR})
12+
13+
if(ZeroMQ_LIBRARY OR ZeroMQ_STATIC_LIBRARY)
14+
set(ZeroMQ_FOUND ON)
15+
endif()
16+
17+
if (TARGET libzmq)
18+
# avoid errors defining targets twice
19+
return()
20+
endif()
21+
22+
set(ZeroMQ_INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIR})
23+
list(APPEND ZeroMQ_INCLUDE_DIRS ${PC_LIBZMQ_INCLUDE_DIRS})
24+
list(REMOVE_DUPLICATES ZeroMQ_INCLUDE_DIRS)
25+
26+
add_library(libzmq SHARED IMPORTED)
27+
set_property(TARGET libzmq PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ZeroMQ_INCLUDE_DIRS})
28+
set_property(TARGET libzmq PROPERTY IMPORTED_LOCATION ${ZeroMQ_LIBRARY})
29+
30+
add_library(libzmq-static STATIC IMPORTED ${ZeroMQ_INCLUDE_DIRS})
31+
set_property(TARGET libzmq-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ZeroMQ_INCLUDE_DIRS})
32+
set_property(TARGET libzmq-static PROPERTY IMPORTED_LOCATION ${ZeroMQ_STATIC_LIBRARY})
33+
34+
include(FindPackageHandleStandardArgs)
35+
find_package_handle_standard_args(ZeroMQ
36+
REQUIRED_VARS
37+
ZeroMQ_LIBRARY ZeroMQ_INCLUDE_DIRS
38+
VERSION_VAR
39+
ZeroMQ_VERSION)

src/CMakeLists.txt

Lines changed: 56 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ include(FeatureSummary)
3232

3333
################ OPTIONS ##################
3434
# Optional build settings for libopenshot
35-
OPTION(USE_SYSTEM_JSONCPP "Use system installed JsonCpp" OFF)
35+
option(USE_SYSTEM_JSONCPP "Use system installed JsonCpp, if found" ON)
36+
option(DISABLE_BUNDLED_JSONCPP "Don't fall back to bundled JsonCpp" OFF)
3637
option(ENABLE_IWYU "Enable 'Include What You Use' scanner (CMake 3.3+)" OFF)
3738

3839
################ WINDOWS ##################
@@ -122,19 +123,6 @@ IF (ENABLE_BLACKMAGIC)
122123
ENDIF (BLACKMAGIC_FOUND)
123124
ENDIF (ENABLE_BLACKMAGIC)
124125

125-
################### ZEROMQ #####################
126-
# Find ZeroMQ library (used for socket communication & logging)
127-
128-
# Some platforms package the header-only cppzmq C++ bindings separately,
129-
# others (Ubuntu) bundle them in with libzmq itself
130-
find_package(cppzmq QUIET)
131-
find_package(ZMQ REQUIRED)
132-
133-
# Include ZeroMQ headers (needed for compile)
134-
include_directories(${ZMQ_INCLUDE_DIRS})
135-
if (cppzmq_FOUND)
136-
include_directories(${cppzmq_INCLUDE_DIRS})
137-
endif()
138126

139127
################### RESVG #####################
140128
# Find resvg library (used for rendering svg files)
@@ -149,18 +137,6 @@ if (RESVG_FOUND)
149137
SET(CMAKE_SWIG_FLAGS "-DUSE_RESVG=1")
150138
endif(RESVG_FOUND)
151139

152-
################### JSONCPP #####################
153-
# Include jsoncpp headers (needed for JSON parsing)
154-
if (USE_SYSTEM_JSONCPP)
155-
message(STATUS "Discovering system JsonCPP (USE_SYSTEM_JSONCPP enabled)")
156-
find_package(JsonCpp REQUIRED)
157-
include_directories(${JSONCPP_INCLUDE_DIRS})
158-
message(STATUS "Discovering system JsonCPP - done")
159-
else()
160-
message(STATUS "Using embedded JsonCpp (USE_SYSTEM_JSONCPP not enabled)")
161-
include_directories("../thirdparty/jsoncpp")
162-
endif(USE_SYSTEM_JSONCPP)
163-
164140
############### PROFILING #################
165141
#set(PROFILER "/usr/lib/libprofiler.so.0.3.2")
166142
#set(PROFILER "/usr/lib/libtcmalloc.so.4")
@@ -236,12 +212,6 @@ SET ( OPENSHOT_SOURCE_FILES
236212
${QT_PLAYER_FILES}
237213
${MOC_FILES})
238214

239-
IF (NOT USE_SYSTEM_JSONCPP)
240-
# Third Party JSON Parser
241-
SET ( OPENSHOT_SOURCE_FILES ${OPENSHOT_SOURCE_FILES}
242-
../thirdparty/jsoncpp/jsoncpp.cpp )
243-
ENDIF (NOT USE_SYSTEM_JSONCPP)
244-
245215
# ImageMagic related files
246216
IF (ImageMagick_FOUND)
247217
SET ( OPENSHOT_SOURCE_FILES ${OPENSHOT_SOURCE_FILES}
@@ -280,6 +250,44 @@ set_target_properties(openshot
280250
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
281251
)
282252

253+
################### JSONCPP #####################
254+
# Include jsoncpp headers (needed for JSON parsing)
255+
if (USE_SYSTEM_JSONCPP)
256+
message(STATUS "Looking for system JsonCpp")
257+
find_package(JsonCpp)
258+
if (JSONCPP_FOUND AND NOT TARGET jsoncpp_lib)
259+
# Create the expected target, for older installs that don't
260+
add_library(jsoncpp_lib INTERFACE)
261+
target_include_directories(jsoncpp_lib INTERFACE
262+
${JSONCPP_INCLUDE_DIRS})
263+
target_link_libraries(jsoncpp_lib INTERFACE ${JSONCPP_LIBRARY})
264+
endif ()
265+
endif ()
266+
267+
if (NOT JSONCPP_FOUND AND NOT DISABLE_BUNDLED_JSONCPP)
268+
message(STATUS "Using embedded JsonCpp (not found or USE_SYSTEM_JSONCPP disabled)")
269+
if (NOT TARGET jsoncpp_lib)
270+
add_library(jsoncpp_lib INTERFACE)
271+
target_include_directories(jsoncpp_lib INTERFACE
272+
"${PROJECT_SOURCE_DIR}/thirdparty/jsoncpp")
273+
target_sources(jsoncpp_lib INTERFACE "${PROJECT_SOURCE_DIR}/thirdparty/jsoncpp/jsoncpp.cpp")
274+
# Because this satisfies the requirement, an installed JsonCpp is optional
275+
set_package_properties(JsonCpp PROPERTIES TYPE OPTIONAL)
276+
endif ()
277+
add_feature_info("JsonCpp (embedded)" TRUE "JsonCpp will be compiled from the bundled sources")
278+
endif ()
279+
280+
if (JSONCPP_FOUND)
281+
# JsonCpp is actually required, even though we probe for it optionally
282+
# (This tells feature_summary() to bail if it's not found, later)
283+
set_package_properties(JsonCpp PROPERTIES TYPE REQUIRED)
284+
endif ()
285+
286+
# If we found any usable JsonCpp, use it. Otherwise, bail.
287+
if (TARGET jsoncpp_lib)
288+
target_link_libraries(openshot PUBLIC jsoncpp_lib)
289+
endif ()
290+
283291
################### FFMPEG #####################
284292
# Find FFmpeg libraries (used for video encoding / decoding)
285293
FIND_PACKAGE(FFmpeg REQUIRED COMPONENTS avcodec avdevice avformat avutil swscale)
@@ -314,14 +322,26 @@ endif()
314322

315323
target_link_libraries(openshot PUBLIC OpenMP::OpenMP_CXX)
316324

325+
################### ZEROMQ #####################
326+
# Find ZeroMQ library (used for socket communication & logging)
327+
find_package(ZeroMQ REQUIRED) # Creates libzmq target
328+
329+
# Some platforms package the header-only cppzmq C++ bindings separately,
330+
# others (Ubuntu) bundle them in with libzmq itself
331+
find_package(cppzmq QUIET) # Creates cppzmq target
332+
333+
# Include ZeroMQ headers (needed for compile)
334+
target_link_libraries(openshot PUBLIC libzmq)
335+
if (TARGET cppzmq)
336+
target_link_libraries(openshot PUBLIC cppzmq)
337+
endif()
338+
317339

318340
############### LINK LIBRARY #################
319341
SET ( REQUIRED_LIBRARIES
320342
${LIBOPENSHOT_AUDIO_LIBRARIES}
321343
${QT_LIBRARIES}
322344
${PROFILER}
323-
${JSONCPP_LIBRARY}
324-
${ZMQ_LIBRARIES}
325345
)
326346

327347
IF (RESVG_FOUND)
@@ -389,9 +409,8 @@ add_subdirectory(bindings)
389409
########### PRINT FEATURE SUMMARY ##############
390410
feature_summary(WHAT ALL
391411
INCLUDE_QUIET_PACKAGES
392-
DESCRIPTION "Build configuration:"
393-
VAR featuresText)
394-
message("\n${featuresText}")
412+
FATAL_ON_MISSING_REQUIRED_PACKAGES
413+
DESCRIPTION "Displaying feature summary\n\nBuild configuration:")
395414

396415
############### INSTALL HEADERS & LIBRARY ################
397416
set(LIB_INSTALL_DIR lib${LIB_SUFFIX}) # determine correct lib folder

tests/CMakeLists.txt

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,6 @@ IF (ENABLE_BLACKMAGIC)
114114
ENDIF (ENABLE_BLACKMAGIC)
115115

116116

117-
################### ZEROMQ #####################
118-
# Find ZeroMQ library (used for socket communication & logging)
119-
120-
# Some platforms package the header-only cppzmq C++ bindings separately,
121-
# others (Ubuntu) bundle them in with libzmq itself
122-
find_package(cppzmq QUIET)
123-
FIND_PACKAGE(ZMQ REQUIRED)
124-
125-
# Include ZeroMQ headers (needed for compile)
126-
include_directories(${ZMQ_INCLUDE_DIRS})
127-
if (cppzmq_FOUND)
128-
include_directories(${cppzmq_INCLUDE_DIRS})
129-
endif()
130-
131117
################### RESVG #####################
132118
# Find resvg library (used for rendering svg files)
133119
FIND_PACKAGE(RESVG)
@@ -137,14 +123,6 @@ if (RESVG_FOUND)
137123
include_directories(${RESVG_INCLUDE_DIRS})
138124
endif(RESVG_FOUND)
139125

140-
################### JSONCPP #####################
141-
# Include jsoncpp headers (needed for JSON parsing)
142-
if (USE_SYSTEM_JSONCPP)
143-
find_package(JsonCpp REQUIRED)
144-
include_directories(${JSONCPP_INCLUDE_DIRS})
145-
else()
146-
include_directories("../thirdparty/jsoncpp")
147-
endif(USE_SYSTEM_JSONCPP)
148126

149127
############### SET TEST SOURCE FILES #################
150128
SET ( OPENSHOT_TEST_FILES

0 commit comments

Comments
 (0)