@@ -173,7 +173,9 @@ set( VVENC_ENABLE_BUILD_TYPE_POSTFIX OFF CACHE BOOL "Enable or disable
173173
174174set ( VVENC_ENABLE_LINK_TIME_OPT ON CACHE BOOL "Enable link time optimization for release and profile builds" )
175175
176- set ( VVENC_ENABLE_THIRDPARTY_JSON ON CACHE BOOL "Enable use of thirdparty json library" )
176+ set ( VVENC_ENABLE_THIRDPARTY_JSON ON CACHE STRING "Enable use of thirdparty json library, pass in SYSTEM to rely on an external nlohmann_json" )
177+
178+ set_property ( CACHE VVENC_ENABLE_THIRDPARTY_JSON PROPERTY STRINGS OFF SYSTEM ON )
177179
178180set ( VVENC_INSTALL_FULLFEATURE_APP OFF CACHE BOOL "Install the full-feature app: vvencFFapp" )
179181
@@ -368,10 +370,20 @@ if( CCACHE_FOUND )
368370 set_property ( GLOBAL PROPERTY RULE_LAUNCH_LINK ccache )
369371endif ()
370372
371-
373+ # handle thirdparty json
372374if ( VVENC_ENABLE_THIRDPARTY_JSON )
375+ string ( TOUPPER "${VVENC_ENABLE_THIRDPARTY_JSON} " VVENC_ENABLE_THIRDPARTY_JSON )
376+ message ( STATUS "VVENC_ENABLE_THIRDPARTY_JSON: ${VVENC_ENABLE_THIRDPARTY_JSON} " )
373377 set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVVENC_ENABLE_THIRDPARTY_JSON" )
374378 set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVVENC_ENABLE_THIRDPARTY_JSON" )
379+ if ( VVENC_ENABLE_THIRDPARTY_JSON STREQUAL "SYSTEM" )
380+ find_package ( nlohmann_json REQUIRED ) # Provides nlohmann_json::nlohmann_json
381+ elseif ( NOT TARGET nlohmann_json::nlohmann_json ) # Implies either ON, TRUE, or 1
382+ add_library ( nlohmann_json::nlohmann_json INTERFACE IMPORTED )
383+ set_target_properties ( nlohmann_json::nlohmann_json PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR} /thirdparty/nlohmann_json/single_include )
384+ endif ()
385+ else ()
386+ message ( STATUS "VVENC_ENABLE_THIRDPARTY_JSON is disabled" )
375387endif ()
376388
377389# handle rpath correctly
0 commit comments