aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt4
-rw-r--r--cmake/modules/FindRapidJSON.cmake86
-rw-r--r--tools/depends/target/rapidjson/002-cmake-standardise_config_installpath.patch15
-rw-r--r--tools/depends/target/rapidjson/003-cmake-removedocs-examples.patch (renamed from tools/depends/target/rapidjson/002-cmake-removedocs-examples.patch)0
-rw-r--r--tools/depends/target/rapidjson/004-win-arm64.patch (renamed from tools/depends/target/rapidjson/003-win-arm64.patch)0
-rw-r--r--tools/depends/target/rapidjson/Makefile10
6 files changed, 83 insertions, 32 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a7acd26853..b5b9da0d96 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -73,7 +73,6 @@ option(ENABLE_TESTING "Enable testing support?" ON)
# These are required enabled for all CI platforms, and recommended for all builds
option(ENABLE_INTERNAL_CROSSGUID "Enable internal crossguid?" ON)
-option(ENABLE_INTERNAL_RapidJSON "Enable internal rapidjson?" ON)
# use ffmpeg from depends or system
option(ENABLE_INTERNAL_FFMPEG "Enable internal ffmpeg?" OFF)
@@ -83,6 +82,7 @@ dependent_option(ENABLE_INTERNAL_FLATBUFFERS "Enable internal flatbuffers?")
dependent_option(ENABLE_INTERNAL_FMT "Enable internal fmt?")
dependent_option(ENABLE_INTERNAL_NFS "Enable internal libnfs?")
dependent_option(ENABLE_INTERNAL_PCRE "Enable internal pcre?")
+dependent_option(ENABLE_INTERNAL_RapidJSON "Enable internal rapidjson?")
dependent_option(ENABLE_INTERNAL_SPDLOG "Enable internal spdlog?")
dependent_option(ENABLE_INTERNAL_TAGLIB "Enable internal taglib?")
if(KODI_DEPENDSBUILD OR WIN32 OR WINDOWS_STORE)
@@ -195,7 +195,7 @@ set(required_deps ASS>=0.15.0
Lzo2
OpenSSL>=1.1.0
PCRE
- RapidJSON
+ RapidJSON>=1.0.2
Spdlog
Sqlite3
TagLib
diff --git a/cmake/modules/FindRapidJSON.cmake b/cmake/modules/FindRapidJSON.cmake
index 19405867bd..377273151f 100644
--- a/cmake/modules/FindRapidJSON.cmake
+++ b/cmake/modules/FindRapidJSON.cmake
@@ -9,18 +9,15 @@
#
if(NOT TARGET RapidJSON::RapidJSON)
- if(ENABLE_INTERNAL_RapidJSON)
- include(cmake/scripts/common/ModuleHelpers.cmake)
-
- set(MODULE_LC rapidjson)
-
- SETUP_BUILD_VARS()
+ include(cmake/scripts/common/ModuleHelpers.cmake)
+ macro(buildrapidjson)
set(RapidJSON_VERSION ${${MODULE}_VER})
set(patches "${CORE_SOURCE_DIR}/tools/depends/target/rapidjson/001-remove_custom_cxx_flags.patch"
- "${CORE_SOURCE_DIR}/tools/depends/target/rapidjson/002-cmake-removedocs-examples.patch"
- "${CORE_SOURCE_DIR}/tools/depends/target/rapidjson/003-win-arm64.patch")
+ "${CORE_SOURCE_DIR}/tools/depends/target/rapidjson/002-cmake-standardise_config_installpath.patch"
+ "${CORE_SOURCE_DIR}/tools/depends/target/rapidjson/003-cmake-removedocs-examples.patch"
+ "${CORE_SOURCE_DIR}/tools/depends/target/rapidjson/004-win-arm64.patch")
generate_patchcommand("${patches}")
@@ -29,34 +26,54 @@ if(NOT TARGET RapidJSON::RapidJSON)
-DRAPIDJSON_BUILD_TESTS=OFF
-DRAPIDJSON_BUILD_THIRDPARTY_GTEST=OFF)
- set(BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/include/rapidjson/rapidjson.h)
+ set(BUILD_BYPRODUCTS ${DEPENDS_PATH}/include/rapidjson/rapidjson.h)
BUILD_DEP_TARGET()
set(RAPIDJSON_INCLUDE_DIRS ${${MODULE}_INCLUDE_DIR})
+ endmacro()
- else()
- if(PKG_CONFIG_FOUND)
- pkg_check_modules(PC_RapidJSON RapidJSON>=1.0.2 QUIET)
- endif()
+ set(MODULE_LC rapidjson)
- if(CORE_SYSTEM_NAME STREQUAL windows OR CORE_SYSTEM_NAME STREQUAL windowsstore)
- set(RapidJSON_VERSION 1.1.0)
+ SETUP_BUILD_VARS()
+
+ if(RapidJSON_FIND_VERSION)
+ if(RapidJSON_FIND_VERSION_EXACT)
+ set(RapidJSON_FIND_SPEC "=${RapidJSON_FIND_VERSION_COMPLETE}")
+ set(RapidJSON_CONFIG_SPEC "${RapidJSON_FIND_VERSION_COMPLETE}" EXACT)
else()
- if(PC_RapidJSON_VERSION)
+ set(RapidJSON_FIND_SPEC ">=${RapidJSON_FIND_VERSION_COMPLETE}")
+ set(RapidJSON_CONFIG_SPEC "${RapidJSON_FIND_VERSION_COMPLETE}")
+ endif()
+ endif()
+
+ find_package(RapidJSON CONFIG ${RapidJSON_CONFIG_SPEC}
+ HINTS ${DEPENDS_PATH}/lib/cmake
+ ${${CORE_PLATFORM_NAME_LC}_SEARCH_CONFIG})
+
+ # Check for existing RAPIDJSON. If version >= RAPIDJSON-VERSION file version, dont build
+ # A corner case, but if a linux/freebsd user WANTS to build internal tinyxml2, build anyway
+ if((RAPIDJSON_VERSION VERSION_LESS ${${MODULE}_VER} AND ENABLE_INTERNAL_RapidJSON) OR
+ ((CORE_SYSTEM_NAME STREQUAL linux OR CORE_SYSTEM_NAME STREQUAL freebsd) AND ENABLE_INTERNAL_RapidJSON))
+ # Build internal rapidjson
+ buildrapidjson()
+ else()
+ # If RAPIDJSON_INCLUDE_DIRS exists, then the find_package command found a config
+ # and suitable version. If its not, we fall back to a pkgconfig/manual search
+ if(NOT DEFINED RAPIDJSON_INCLUDE_DIRS)
+ find_package(PkgConfig)
+ # Fallback to pkg-config and individual lib/include file search
+ # Do not use pkgconfig on windows
+ if(PKG_CONFIG_FOUND AND NOT WIN32)
+ pkg_check_modules(PC_RapidJSON RapidJSON${RapidJSON_FIND_SPEC} QUIET)
set(RapidJSON_VERSION ${PC_RapidJSON_VERSION})
- else()
- find_package(RapidJSON 1.1.0 CONFIG REQUIRED
- QUIET
- HINTS ${DEPENDS_PATH}/lib
- ${${CORE_PLATFORM_NAME_LC}_SEARCH_CONFIG})
endif()
- endif()
- find_path(RAPIDJSON_INCLUDE_DIRS NAMES rapidjson/rapidjson.h
- HINTS ${DEPENDS_PATH}/include ${PC_RapidJSON_INCLUDEDIR}
- ${${CORE_PLATFORM_NAME_LC}_SEARCH_CONFIG}
- NO_CACHE)
+ find_path(RAPIDJSON_INCLUDE_DIRS NAMES rapidjson/rapidjson.h
+ HINTS ${DEPENDS_PATH}/include ${PC_RapidJSON_INCLUDEDIR}
+ ${${CORE_PLATFORM_NAME_LC}_SEARCH_CONFIG}
+ NO_CACHE)
+ endif()
endif()
include(FindPackageHandleStandardArgs)
@@ -71,6 +88,23 @@ if(NOT TARGET RapidJSON::RapidJSON)
if(TARGET rapidjson)
add_dependencies(RapidJSON::RapidJSON rapidjson)
endif()
+
+ # Add internal build target when a Multi Config Generator is used
+ # We cant add a dependency based off a generator expression for targeted build types,
+ # https://gitlab.kitware.com/cmake/cmake/-/issues/19467
+ # therefore if the find heuristics only find the library, we add the internal build
+ # target to the project to allow user to manually trigger for any build type they need
+ # in case only a specific build type is actually available (eg Release found, Debug Required)
+ # This is mainly targeted for windows who required different runtime libs for different
+ # types, and they arent compatible
+ if(_multiconfig_generator)
+ if(NOT TARGET rapidjson)
+ buildrapidjson()
+ set_target_properties(rapidjson PROPERTIES EXCLUDE_FROM_ALL TRUE)
+ endif()
+ add_dependencies(build_internal_depends rapidjson)
+ endif()
+
set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP RapidJSON::RapidJSON)
endif()
endif()
diff --git a/tools/depends/target/rapidjson/002-cmake-standardise_config_installpath.patch b/tools/depends/target/rapidjson/002-cmake-standardise_config_installpath.patch
new file mode 100644
index 0000000000..937d19e8e3
--- /dev/null
+++ b/tools/depends/target/rapidjson/002-cmake-standardise_config_installpath.patch
@@ -0,0 +1,15 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -94,11 +94,7 @@
+ SET(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE STRING "Directory where lib will install")
+ SET(DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}" CACHE PATH "Path to the documentation")
+
+-IF(UNIX OR CYGWIN)
+- SET(_CMAKE_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME}")
+-ELSEIF(WIN32)
+- SET(_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/cmake")
+-ENDIF()
++SET(_CMAKE_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME}")
+ SET(CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" CACHE PATH "The directory cmake fiels are installed in")
+
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
diff --git a/tools/depends/target/rapidjson/002-cmake-removedocs-examples.patch b/tools/depends/target/rapidjson/003-cmake-removedocs-examples.patch
index 4bf06da59c..4bf06da59c 100644
--- a/tools/depends/target/rapidjson/002-cmake-removedocs-examples.patch
+++ b/tools/depends/target/rapidjson/003-cmake-removedocs-examples.patch
diff --git a/tools/depends/target/rapidjson/003-win-arm64.patch b/tools/depends/target/rapidjson/004-win-arm64.patch
index 2d045dcaf6..2d045dcaf6 100644
--- a/tools/depends/target/rapidjson/003-win-arm64.patch
+++ b/tools/depends/target/rapidjson/004-win-arm64.patch
diff --git a/tools/depends/target/rapidjson/Makefile b/tools/depends/target/rapidjson/Makefile
index 233d3a3571..1e0a2d2e75 100644
--- a/tools/depends/target/rapidjson/Makefile
+++ b/tools/depends/target/rapidjson/Makefile
@@ -1,8 +1,9 @@
-include ../../Makefile.include
include RAPIDJSON-VERSION
DEPS = Makefile RAPIDJSON-VERSION 001-remove_custom_cxx_flags.patch ../../download-files.include \
- 002-cmake-removedocs-examples.patch \
- 003-win-arm64.patch
+ 002-cmake-standardise_config_installpath.patch \
+ 003-cmake-removedocs-examples.patch \
+ 004-win-arm64.patch
CMAKE_OPTIONS=-DRAPIDJSON_HAS_STDSTRING=ON -DRAPIDJSON_BUILD_DOC=OFF -DRAPIDJSON_BUILD_EXAMPLES=OFF -DRAPIDJSON_BUILD_TESTS=OFF -DRAPIDJSON_BUILD_THIRDPARTY_GTEST=OFF
@@ -42,8 +43,9 @@ endif
cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE)
cd $(PLATFORM); rm -rf build; mkdir -p build
cd $(PLATFORM); patch -p1 -i ../001-remove_custom_cxx_flags.patch
- cd $(PLATFORM); patch -p1 -i ../002-cmake-removedocs-examples.patch
- cd $(PLATFORM); patch -p1 -i ../003-win-arm64.patch
+ cd $(PLATFORM); patch -p1 -i ../002-cmake-standardise_config_installpath.patch
+ cd $(PLATFORM); patch -p1 -i ../003-cmake-removedocs-examples.patch
+ cd $(PLATFORM); patch -p1 -i ../004-win-arm64.patch
cd $(PLATFORM)/build; $(CMAKE) $(CMAKE_OPTIONS) ..
.installed-$(PLATFORM): $(PLATFORM)