Merge pull request #23092 from webosbrew/feature/webOS
[xbmc.git] / cmake / modules / FindRapidJSON.cmake
blob2db5e687c21d15a894a719c6eccb1bd9af0a9490
1 #.rst:
2 # FindRapidJSON
3 # -----------
4 # Finds the RapidJSON library
6 # This will define the following variables::
8 # RapidJSON_FOUND - system has RapidJSON parser
9 # RapidJSON_INCLUDE_DIRS - the RapidJSON parser include directory
11 if(ENABLE_INTERNAL_RapidJSON)
12   include(cmake/scripts/common/ModuleHelpers.cmake)
14   set(MODULE_LC rapidjson)
16   SETUP_BUILD_VARS()
18   set(RapidJSON_VERSION ${${MODULE}_VER})
20   set(patches "${CORE_SOURCE_DIR}/tools/depends/target/rapidjson/001-remove_custom_cxx_flags.patch"
21               "${CORE_SOURCE_DIR}/tools/depends/target/rapidjson/002-cmake-removedocs-examples.patch"
22               "${CORE_SOURCE_DIR}/tools/depends/target/rapidjson/003-win-arm64.patch")
24   generate_patchcommand("${patches}")
26   set(CMAKE_ARGS -DRAPIDJSON_BUILD_DOC=OFF
27                  -DRAPIDJSON_BUILD_EXAMPLES=OFF
28                  -DRAPIDJSON_BUILD_TESTS=OFF
29                  -DRAPIDJSON_BUILD_THIRDPARTY_GTEST=OFF)
31   set(BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/include/rapidjson/rapidjson.h)
33   BUILD_DEP_TARGET()
35   set(RapidJSON_INCLUDE_DIR ${${MODULE}_INCLUDE_DIR})
37   # Add dependency to libkodi to build
38   set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP rapidjson)
39 else()
40   if(PKG_CONFIG_FOUND)
41     pkg_check_modules(PC_RapidJSON RapidJSON>=1.0.2 QUIET)
42   endif()
44   if(CORE_SYSTEM_NAME STREQUAL windows OR CORE_SYSTEM_NAME STREQUAL windowsstore)
45     set(RapidJSON_VERSION 1.1.0)
46   else()
47     if(PC_RapidJSON_VERSION)
48       set(RapidJSON_VERSION ${PC_RapidJSON_VERSION})
49     else()
50       find_package(RapidJSON 1.1.0 CONFIG REQUIRED QUIET)
51     endif()
52   endif()
54   find_path(RapidJSON_INCLUDE_DIR NAMES rapidjson/rapidjson.h
55                                   PATHS ${PC_RapidJSON_INCLUDEDIR})
56 endif()
58 include(FindPackageHandleStandardArgs)
59 find_package_handle_standard_args(RapidJSON
60                                   REQUIRED_VARS RapidJSON_INCLUDE_DIR RapidJSON_VERSION
61                                   VERSION_VAR RapidJSON_VERSION)
63 if(RAPIDJSON_FOUND)
64   set(RAPIDJSON_INCLUDE_DIRS ${RapidJSON_INCLUDE_DIR})
65 endif()
67 mark_as_advanced(RapidJSON_INCLUDE_DIR)