Skip to content

Commit 5c40094

Browse files
authored
Merge branch 'develop' into zmq-targets
2 parents 04724cf + 43bc0eb commit 5c40094

File tree

2 files changed

+42
-31
lines changed

2 files changed

+42
-31
lines changed

src/CMakeLists.txt

Lines changed: 42 additions & 23 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 ##################
@@ -136,18 +137,6 @@ if (RESVG_FOUND)
136137
SET(CMAKE_SWIG_FLAGS "-DUSE_RESVG=1")
137138
endif(RESVG_FOUND)
138139

139-
################### JSONCPP #####################
140-
# Include jsoncpp headers (needed for JSON parsing)
141-
if (USE_SYSTEM_JSONCPP)
142-
message(STATUS "Discovering system JsonCPP (USE_SYSTEM_JSONCPP enabled)")
143-
find_package(JsonCpp REQUIRED)
144-
include_directories(${JSONCPP_INCLUDE_DIRS})
145-
message(STATUS "Discovering system JsonCPP - done")
146-
else()
147-
message(STATUS "Using embedded JsonCpp (USE_SYSTEM_JSONCPP not enabled)")
148-
include_directories("../thirdparty/jsoncpp")
149-
endif(USE_SYSTEM_JSONCPP)
150-
151140
############### PROFILING #################
152141
#set(PROFILER "/usr/lib/libprofiler.so.0.3.2")
153142
#set(PROFILER "/usr/lib/libtcmalloc.so.4")
@@ -223,12 +212,6 @@ SET ( OPENSHOT_SOURCE_FILES
223212
${QT_PLAYER_FILES}
224213
${MOC_FILES})
225214

226-
IF (NOT USE_SYSTEM_JSONCPP)
227-
# Third Party JSON Parser
228-
SET ( OPENSHOT_SOURCE_FILES ${OPENSHOT_SOURCE_FILES}
229-
../thirdparty/jsoncpp/jsoncpp.cpp )
230-
ENDIF (NOT USE_SYSTEM_JSONCPP)
231-
232215
# ImageMagic related files
233216
IF (ImageMagick_FOUND)
234217
SET ( OPENSHOT_SOURCE_FILES ${OPENSHOT_SOURCE_FILES}
@@ -267,6 +250,43 @@ set_target_properties(openshot
267250
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
268251
)
269252

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 ()
270290

271291
################### FFMPEG #####################
272292
# Find FFmpeg libraries (used for video encoding / decoding)
@@ -278,6 +298,7 @@ foreach(ff_comp avcodec avdevice avformat avfilter avutil postproc swscale swres
278298
endif()
279299
endforeach()
280300

301+
281302
################### OPENMP #####################
282303
# Check for OpenMP (used for multi-core processing)
283304

@@ -316,7 +337,6 @@ SET ( REQUIRED_LIBRARIES
316337
${LIBOPENSHOT_AUDIO_LIBRARIES}
317338
${QT_LIBRARIES}
318339
${PROFILER}
319-
${JSONCPP_LIBRARY}
320340
)
321341

322342
IF (RESVG_FOUND)
@@ -384,9 +404,8 @@ add_subdirectory(bindings)
384404
########### PRINT FEATURE SUMMARY ##############
385405
feature_summary(WHAT ALL
386406
INCLUDE_QUIET_PACKAGES
387-
DESCRIPTION "Build configuration:"
388-
VAR featuresText)
389-
message("\n${featuresText}")
407+
FATAL_ON_MISSING_REQUIRED_PACKAGES
408+
DESCRIPTION "Displaying feature summary\n\nBuild configuration:")
390409

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

tests/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,6 @@ if (RESVG_FOUND)
123123
include_directories(${RESVG_INCLUDE_DIRS})
124124
endif(RESVG_FOUND)
125125

126-
################### JSONCPP #####################
127-
# Include jsoncpp headers (needed for JSON parsing)
128-
if (USE_SYSTEM_JSONCPP)
129-
find_package(JsonCpp REQUIRED)
130-
include_directories(${JSONCPP_INCLUDE_DIRS})
131-
else()
132-
include_directories("../thirdparty/jsoncpp")
133-
endif(USE_SYSTEM_JSONCPP)
134126

135127
############### SET TEST SOURCE FILES #################
136128
SET ( OPENSHOT_TEST_FILES

0 commit comments

Comments
 (0)