aboutsummaryrefslogtreecommitdiff
path: root/project/cmake
diff options
context:
space:
mode:
authormontellese <montellese@xbmc.org>2014-07-12 16:43:13 +0200
committermontellese <montellese@xbmc.org>2014-07-30 11:15:58 +0200
commit83d9abf8a8a16ec8ba1188f737109f1f973527f7 (patch)
treec8fa95bacde32edeaaac183d6ac66ff2f017f765 /project/cmake
parent574c27ecb95befc3207580346d963eb638e3a798 (diff)
cmake: add xbmc-addons-depends buildsystem
Diffstat (limited to 'project/cmake')
-rw-r--r--project/cmake/addons/depends/CMakeLists.txt150
-rw-r--r--project/cmake/addons/depends/README59
2 files changed, 209 insertions, 0 deletions
diff --git a/project/cmake/addons/depends/CMakeLists.txt b/project/cmake/addons/depends/CMakeLists.txt
new file mode 100644
index 0000000000..3e3f6caa3c
--- /dev/null
+++ b/project/cmake/addons/depends/CMakeLists.txt
@@ -0,0 +1,150 @@
+project(xbmc-addons-depends)
+
+cmake_minimum_required(VERSION 2.8)
+
+list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
+
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Release)
+endif()
+
+if(NOT CORE_SYSTEM_NAME)
+ string(TOLOWER ${CMAKE_SYSTEM_NAME} CORE_SYSTEM_NAME)
+endif()
+
+include(ExternalProject)
+
+if(NOT CMAKE_INSTALL_PREFIX)
+ set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/../output/depends)
+else()
+ file(TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}" CMAKE_INSTALL_PREFIX)
+endif()
+get_filename_component(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" ABSOLUTE)
+list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX})
+
+## handle dependencies with a cmake based buildsystem which need to be downloaded, built and installed
+file(GLOB_RECURSE cmake_input_files ${CORE_SYSTEM_NAME}/cmake/*.txt)
+file(GLOB_RECURSE cmake_input_files2 common/*.txt)
+list(APPEND cmake_input_files ${cmake_input_files2})
+foreach(file ${cmake_input_files})
+ if(NOT (file MATCHES CMakeLists.txt OR
+ file MATCHES install.txt OR
+ file MATCHES noinstall.txt OR
+ file MATCHES flags.txt OR
+ file MATCHES deps.txt))
+ message(STATUS "Processing ${file}")
+ file(STRINGS ${file} def)
+ string(REPLACE " " ";" def ${def})
+ list(LENGTH def deflength)
+ get_filename_component(dir ${file} PATH)
+
+ # get the id and url of the dependency
+ set(url "")
+ if(NOT "${def}" STREQUAL "")
+ # read the id and the url from the file
+ list(GET def 0 id)
+ if(deflength GREATER 1)
+ list(GET def 1 url)
+ message(STATUS "${id} url: ${url}")
+ endif()
+ else()
+ # read the id from the filename
+ get_filename_component(id ${file} NAME_WE)
+ endif()
+
+ # check if there are any library specific flags that need to be passed on
+ if(EXISTS ${dir}/flags.txt})
+ file(STRINGS ${dir}/flags.txt extraflags)
+ message(STATUS "${id} extraflags: ${extraflags}")
+ endif()
+
+ set(BUILD_ARGS -DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}
+ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+ -DCMAKE_USER_MAKE_RULES_OVERRIDE=${CMAKE_USER_MAKE_RULES_OVERRIDE}
+ -DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX=${CMAKE_USER_MAKE_RULES_OVERRIDE_CXX}
+ -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
+ -DARCH_DEFINES=${ARCH_DEFINES}
+ -DENABLE_STATIC=1
+ -DBUILD_SHARED_LIBS=0
+ "${extraflags}")
+
+ if(CMAKE_TOOLCHAIN_FILE)
+ list(APPEND BUILD_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE})
+ MESSAGE("toolchain specified")
+ MESSAGE(${BUILD_ARGS})
+ endif()
+
+ # if there's a CMakeLists.txt use it to prepare the build
+ if(EXISTS ${dir}/CMakeLists.txt)
+ set(PATCH_COMMAND ${CMAKE_COMMAND} -E copy
+ ${dir}/CMakeLists.txt
+ ${CMAKE_BINARY_DIR}/build/${id}/src/${id})
+ else()
+ set(PATCH_COMMAND "")
+ endif()
+
+ # if there's an install.txt use it to properly install the built files
+ if(EXISTS ${dir}/install.txt)
+ set(INSTALL_COMMAND INSTALL_COMMAND ${CMAKE_COMMAND}
+ -DINPUTDIR=${CMAKE_BINARY_DIR}/build/${id}/src/${id}-build/
+ -DINPUTFILE=${dir}/install.txt
+ -DDESTDIR=${CMAKE_INSTALL_PREFIX}
+ -DENABLE_STATIC=1
+ "${extraflags}"
+ -P ${PROJECT_SOURCE_DIR}/install.cmake)
+ elseif(EXISTS ${dir}/noinstall.txt)
+ set(INSTALL_COMMAND INSTALL_COMMAND "")
+ else()
+ set(INSTALL_COMMAND "")
+ endif()
+
+ # check if there's a deps.txt containing dependencies on other libraries
+ if(EXISTS ${dir}/deps.txt})
+ file(STRINGS ${dir}/deps.txt deps)
+ message(STATUS "${id} dependencies: ${deps}")
+ set(DEPENDS_COMMAND DEPENDS ${deps})
+ else()
+ set(DEPENDS_COMMAND "")
+ endif()
+
+ # prepare the setup of the call to externalproject_add()
+ set(EXTERNALPROJECT_SETUP PREFIX build/${id}
+ CMAKE_ARGS ${BUILD_ARGS}
+ PATCH_COMMAND ${PATCH_COMMAND}
+ "${INSTALL_COMMAND}"
+ "${DEPENDS_COMMAND}")
+
+ # if there's an url defined we need to pass that to externalproject_add()
+ if(DEFINED url AND NOT "${url}" STREQUAL "")
+ # check if there's a third parameter in the file
+ if(deflength GREATER 2)
+ # the third parameter is considered as a revision of a git repository
+ list(GET def 2 revision)
+
+ externalproject_add(${id}
+ GIT_REPOSITORY ${url}
+ GIT_TAG ${revision}
+ "${EXTERNALPROJECT_SETUP}"
+ )
+ else()
+ externalproject_add(${id}
+ URL ${url}
+ "${EXTERNALPROJECT_SETUP}"
+ )
+ endif()
+ else()
+ externalproject_add(${id}
+ SOURCE_DIR ${dir}
+ "${EXTERNALPROJECT_SETUP}"
+ )
+ endif()
+ endif()
+endforeach()
+
+## if there's a platform-specific sub-directory containing a CMakeLists.txt, add it to the build as well
+if(EXISTS ${PROJECT_SOURCE_DIR}/${CORE_SYSTEM_NAME}/CMakeLists.txt)
+ message(STATUS "Processing ${CORE_SYSTEM_NAME}")
+ add_subdirectory(${CORE_SYSTEM_NAME})
+else()
+ message(FATAL_ERROR "CORE_SYSTEM_NAME: ${PROJECT_SOURCE_DIR}/${CORE_SYSTEM_NAME}/CMakeLists.txt")
+endif() \ No newline at end of file
diff --git a/project/cmake/addons/depends/README b/project/cmake/addons/depends/README
new file mode 100644
index 0000000000..f80a7a1566
--- /dev/null
+++ b/project/cmake/addons/depends/README
@@ -0,0 +1,59 @@
+XBMC ADDON DEPENDENCIES
+=======================
+This directory contains the cmake-based buildsystem for addon dependencies. It
+looks into the "common" and the "<platform>/cmake" sub-directories and parses
+all *.txt files recursively. Each dependency must have its own <dependency>.txt
+file (either in the main sub-directory or in a separate subdirectory of the main
+subdirectory) which must follow one of the defined formats:
+ * an empty file means that no extra downloads are necessary
+ * <dependency>
+ * <dependency> <url>
+ * <dependency> <git-url> <git-revision>
+where
+ * <dependency> must be identical to the filename
+ * <url> must be the URL to an archive that is downloaded and extracted.
+ * <git-url> must be the URL of the git repository containing the
+ dependency.
+ * <git-revision> must be a valid git tag/branch/commit in the dependency's git
+ repository which will be used for the build.
+
+Reserved filenames (for additional information on how to build a dependency)
+are:
+ * CMakeLists.txt: build instructions for the dependency
+ * install.txt: instructions on how to install the dependency's built files
+ * noinstall.txt: no installation step required (content is ignored)
+ * flags.txt: additional build flags
+ * deps.txt: whitespace separated list of dependencies of this dependency
+
+The buildsystem uses the following variables (which can be passed into it when
+executing cmake with the -D<variable-name>=<value> option) to e.g. access
+specific paths:
+ * CMAKE_BUILD_TYPE specifies the type of the build. This can be either "Debug"
+ or "Release" (default is "Release").
+ * CMAKE_INSTALL_PREFIX points to the directory where the built dependencies
+ (their include and library file) will be installed to.
+ * CMAKE_TOOLCHAIN_FILE can be used to pass a toolchain file into the add-on
+ builds.
+ * CORE_SYSTEM_NAME is the name of the platform (e.g. "linux" or "android") in
+ lower-case (defaults to lowercase(CMAKE_SYSTEM_NAME)).
+ * XBMCROOT points to the root directory of the xbmc project (default is the
+ absolute representation of ../../.. starting from this directory).
+ * ARCH_DEFINES specifies the platform-specific C/C++ preprocessor defines
+ (defaults to empty).
+
+To trigger the cmake-based buildsystem the following command must be executed
+with <path> being the path to this directory (absolute or relative, allowing for
+in-source and out-of-source builds).
+
+ cmake <path> -G <generator>
+
+cmake supports multiple generators, see
+http://www.cmake.org/cmake/help/v2.8.8/cmake.html#section_Generators for a list.
+
+In case of additional options the call might look like this
+
+ cmake <path> [-G <generator>] \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DXBMCROOT="<path-to-xbmc-root>" \
+ -DARCH_DEFINES="-DTARGET_LINUX" \
+ -DCMAKE_INSTALL_PREFIX="<path-to-install-directory"