aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorNuno Senica <nsenica@gmail.com>2017-05-24 08:11:19 +0000
committerNuno Senica <nsenica@gmail.com>2017-08-30 19:57:02 +0000
commit91973dbfcf1f6ddd53e85b8505f9758730a90905 (patch)
tree71342f1efd6d7d2570a9e71112f66fe9e64e0b33 /cmake
parent206d03443bf9e955f406e68c215fdf1e9ad576d8 (diff)
RapidJSON can now be compiled internally
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindRapidJSON.cmake42
1 files changed, 42 insertions, 0 deletions
diff --git a/cmake/modules/FindRapidJSON.cmake b/cmake/modules/FindRapidJSON.cmake
index d41985b583..3c3dc3f721 100644
--- a/cmake/modules/FindRapidJSON.cmake
+++ b/cmake/modules/FindRapidJSON.cmake
@@ -8,6 +8,47 @@
# RapidJSON_FOUND - system has RapidJSON parser
# RapidJSON_INCLUDE_DIRS - the RapidJSON parser include directory
#
+if(ENABLE_INTERNAL_RapidJSON)
+ include(ExternalProject)
+ file(STRINGS ${CMAKE_SOURCE_DIR}/tools/depends/target/rapidjson/Makefile VER REGEX MATCH "^[ ]*VERSION[ ]*=.+$")
+ string(REGEX REPLACE "^[ ]*VERSION[ ]*=[ ]*" "" RJSON_VER "${VER}")
+
+ # allow user to override the download URL with a local tarball
+ # needed for offline build envs
+ if(RapidJSON_URL)
+ get_filename_component(RapidJSON_URL "${RapidJSON_URL}" ABSOLUTE)
+ else()
+ set(RapidJSON_URL http://mirrors.kodi.tv/build-deps/sources/rapidjson-${RJSON_VER}.tar.gz)
+ endif()
+ if(VERBOSE)
+ message(STATUS "RapidJSON_URL: ${RapidJSON_URL}")
+ endif()
+
+ if(APPLE)
+ set(EXTRA_ARGS "-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}")
+ endif()
+
+ set(RapidJSON_LIBRARY ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/lib/librapidjson.a)
+ set(RapidJSON_INCLUDE_DIR ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/include)
+ externalproject_add(rapidjson
+ URL ${RapidJSON_URL}
+ DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/download
+ PREFIX ${CORE_BUILD_DIR}/rapidjson
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}
+ -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
+ "${EXTRA_ARGS}"
+ PATCH_COMMAND patch -p1 < ${CORE_SOURCE_DIR}/tools/depends/target/rapidjson/0001-remove_custom_cxx_flags.patch
+ BUILD_BYPRODUCTS ${RapidJSON_LIBRARY})
+ set_target_properties(rapidjson PROPERTIES FOLDER "External Projects")
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(rapidjson
+ REQUIRED_VARS RapidJSON_LIBRARY RapidJSON_INCLUDE_DIR
+ VERSION_VAR RJSON_VER)
+
+ set(RapidJSON_LIBRARIES ${RapidJSON_LIBRARY})
+ set(RapidJSON_INCLUDE_DIRS ${RapidJSON_INCLUDE_DIR})
+else()
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_RapidJSON RapidJSON>=1.0.2 QUIET)
@@ -38,3 +79,4 @@ endif()
mark_as_advanced(RapidJSON_INCLUDE_DIR)
+endif()