Skip to content

Commit

Permalink
Merge pull request #9676 from hudokkow/cmake_fixes_2
Browse files Browse the repository at this point in the history
[cmake] Some more fixes
  • Loading branch information
fetzerch committed Apr 25, 2016
2 parents eddf7ee + 220f507 commit 160b7b3
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 121 deletions.
2 changes: 1 addition & 1 deletion project/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ else()
endif()

# testing
copy_files_from_filelist_to_buildtree(${PROJECT_SOURCE_DIR}/installdata/test-reference-data.txt 1)
copy_files_from_filelist_to_buildtree(${PROJECT_SOURCE_DIR}/installdata/test-reference-data.txt NO_INSTALL)
add_executable(${APP_NAME_LC}-test EXCLUDE_FROM_ALL ${CORE_SOURCE_DIR}/xbmc/test/xbmc-test.cpp $<TARGET_OBJECTS:compileinfo>)
whole_archive(_TEST_LIBRARIES ${core_DEPENDS} gtest ${test_archives})
target_link_libraries(${APP_NAME_LC}-test ${SYSTEM_LDFLAGS} ${_TEST_LIBRARIES} ${DEPLIBS} ${CMAKE_DL_LIBS})
Expand Down
94 changes: 0 additions & 94 deletions project/cmake/addons/README

This file was deleted.

61 changes: 61 additions & 0 deletions project/cmake/addons/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
![Kodi logo](https://raw.githubusercontent.com/xbmc/xbmc-forum/master/xbmc/images/logo-sbs-black.png)
# Kodi add-ons CMake based buildsystem
This directory contains the cmake-based buildsystem for Kodi add-ons. It looks into the directory pointed to by the *ADDONS_DEFINITION_DIR* option (which defaults to the *addons* sub-directory) and parses all *.txt files recursively. Each add-on must have its own `<addon-id>.txt` file in a separate sub-directory that must follow one of the defined formats:

- `<addon-id> <git-url> <git-revision>`
- `<addon-id> <tarball-url>`
- `<addon-id> <file://path>`

where
- `<addon-id>` must be identical to the add-on's ID as defined in the add-on's addon.xml
- `<git-url>` must be the URL of the git repository containing the add-on
- `<git-revision>` must be a valid git tag/branch/commit in the add-on's git repository which will be used for the build
- `<tarball-url>` must be the URL to a .tar.gz tarball containing the add-on
- `<file://path>` must be a *file://* based path to the directory containing the add-on

## Reserved filenames
- **platforms.txt**

List of platforms to build an add-on for (or *all*). Negating platforms is supported using a leading exclamation mark, e.g. *!windows*.

Available platforms are: linux, windows, osx, ios, android, rbpi and freebsd.

#### Attention
If no add-on definitions could be found, the buildsystem assumes that the bootstrapping of the add-on definition repositories hasn't been performed yet and automatically executes the add-on bootstrapping buildsystem located in the *bootstrap* sub-directory with the default settings (i.e. *all* add-ons from all pre-defined add-on definition repositories are bootstrapped into the directory pointed to by the *ADDONS_DEFINITION_DIR* option).

## Buildsystem variables
The buildsystem uses the following variables (which can be passed into it when executing cmake with the -D`<variable-name>=<value>` format) to manipulate the build process:
- `ADDONS_TO_BUILD` has two variations, which are tested in order:
- a quoted, space delimited list of `<addon-id>s` that you want to build (default is *all*)
- a regular expression that every `<addon-id>` is matched against (e.g. `ADDONS_TO_BUILD="pvr.*"`) to build all pvr add-ons
- `ADDONS_DEFINITION_DIR` points to the directory containing the definitions for the addons to be built
- `ADDON_SRC_PREFIX` can be used to override the add-on repository location. It must point to the locally available parent directory of the add-on(s) to build. `<addon-id>` will be appended to this path automatically
- `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 add-ons and their additional files (addon.xml, resources, ...) will be installed to (defaults to `<DEPENDS_PATH>`)
- `CMAKE_TOOLCHAIN_FILE` can be used to pass a toolchain file into the add-on builds
- `DEPENDS_PATH` points to the directory containing the *include* and *lib* directories of the add-ons' dependencies.
- `APP_ROOT` points to the root directory of the project (default is the absolute representation of ../../.. starting from this directory)
- `BUILD_DIR` points to the directory where the add-ons and their dependencies will be downloaded and built
- `PACKAGE_ZIP=ON` means that the add-ons will be 'packaged' into a common folder, rather than being placed in `<CMAKE_INSTALL_PREFIX>/lib/kodi/addons` and `<CMAKE_INSTALL_PREFIX>/share/kodi/addons`
- `PACKAGE_DIR` points to the directory where the ZIP archived add-ons will be stored after they have been packaged (defaults to `<BUILD_DIR>/zips`)
- `ARCH_DEFINES` specifies the platform-specific C/C++ preprocessor defines (defaults to empty)
- `ADDON_TARBALL_CACHING` specifies whether downloaded add-on source tarballs should be cached or not (defaults to *ON*)

## Building
The buildsystem makes some assumptions about the environment which must be met by whoever uses it:
- Any dependencies of the add-ons must already be built and their include and library files must be present in the path pointed to by `<CMAKE_PREFIX_PATH>` (in *include* and *lib* sub-directories)

To trigger the cmake-based buildsystem the following command must be executed with `<path>` set to this directory (absolute or relative) allowing for in-source and out-of-source builds

`cmake <path> -G <generator>`

CMake supports multiple generators. See [here] (https://cmake.org/cmake/help/v3.1/manual/cmake-generators.7.html) for a list.

In case of additional options the call might look like this:

cmake `<path>` [-G `<generator>`] \
-DCMAKE_BUILD_TYPE=Release \
-DAPP_ROOT="`<path-to-app-root>`" \
-DARCH_DEFINES="-DTARGET_LINUX" \
-DDEPENDS_PATH=`<path-to-built-depends>` \
-DCMAKE_INSTALL_PREFIX="`<path-to-install-directory`"
2 changes: 2 additions & 0 deletions project/cmake/installdata/common/addons.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ addons/kodi.game/*
addons/kodi.inputstream/*
addons/kodi.peripheral/*
addons/kodi.resource/*
addons/xbmc.addon/metadata.xsd
addons/xbmc.addon/repository.xsd
addons/xbmc.audioencoder/*
addons/xbmc.codec/*
addons/xbmc.core/*
Expand Down
37 changes: 15 additions & 22 deletions project/cmake/scripts/common/macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -319,22 +319,15 @@ macro(today RESULT)
endmacro()

function(core_find_git_rev)
# this is dead code. It should be version.txt
# revisit later after some more light reading about cmake's string parsing
# and filtering.
if(EXISTS ${CORE_SOURCE_DIR}/VERSION)
file(STRINGS ${CORE_SOURCE_DIR}/VERSION VERSION_FILE)
string(SUBSTRING "${VERSION_FILE}" 1 16 GIT_REV)
else()
find_package(Git)
if(GIT_FOUND AND EXISTS ${CORE_SOURCE_DIR}/.git)
execute_process(COMMAND ${GIT_EXECUTABLE} diff-files --ignore-submodules --quiet --
RESULT_VARIABLE status_code
WORKING_DIRECTORY ${CORE_SOURCE_DIR})
find_package(Git)
if(GIT_FOUND AND EXISTS ${CORE_SOURCE_DIR}/.git)
execute_process(COMMAND ${GIT_EXECUTABLE} diff-files --ignore-submodules --quiet --
RESULT_VARIABLE status_code
WORKING_DIRECTORY ${CORE_SOURCE_DIR})
if (NOT status_code)
execute_process(COMMAND ${GIT_EXECUTABLE} diff-index --ignore-submodules --quiet HEAD --
RESULT_VARIABLE status_code
WORKING_DIRECTORY ${CORE_SOURCE_DIR})
RESULT_VARIABLE status_code
WORKING_DIRECTORY ${CORE_SOURCE_DIR})
endif()
if (status_code)
execute_process(COMMAND ${GIT_EXECUTABLE} log -n 1 --pretty=format:"%h-dirty" HEAD
Expand All @@ -347,16 +340,16 @@ function(core_find_git_rev)
WORKING_DIRECTORY ${CORE_SOURCE_DIR})
string(SUBSTRING ${HASH} 1 7 HASH)
endif()
execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:"%cd" --date=short HEAD
OUTPUT_VARIABLE DATE
WORKING_DIRECTORY ${CORE_SOURCE_DIR})
string(SUBSTRING ${DATE} 1 10 DATE)
else()
execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:"%cd" --date=short HEAD
OUTPUT_VARIABLE DATE
WORKING_DIRECTORY ${CORE_SOURCE_DIR})
string(SUBSTRING ${DATE} 1 10 DATE)
else()
today(DATE)
endif()
string(REPLACE "-" "" DATE ${DATE})
set(GIT_REV "${DATE}-${HASH}")
set(HASH "nogitfound")
endif()
string(REPLACE "-" "" DATE ${DATE})
set(GIT_REV "${DATE}-${HASH}")
if(GIT_REV)
set(APP_SCMID ${GIT_REV} PARENT_SCOPE)
endif()
Expand Down
11 changes: 7 additions & 4 deletions project/cmake/scripts/common/projectmacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ function(copy_skin_to_buildtree skin relative)
endforeach()
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${dest}/media)
string(REPLACE "${relative}/" "" dest ${skin})
pack_xbt(${skin}/media
${CMAKE_BINARY_DIR}/${dest}/media/Textures.xbt
${CMAKE_BINARY_DIR})

pack_xbt(${skin}/media ${CMAKE_BINARY_DIR}/${dest}/media/Textures.xbt)

file(GLOB THEMES RELATIVE ${skin}/themes ${skin}/themes/*)
foreach(theme ${THEMES})
pack_xbt(${skin}/themes/${theme} ${CMAKE_BINARY_DIR}/${dest}/media/${theme}.xbt)
endforeach()

set(XBT_FILES ${XBT_FILES} PARENT_SCOPE)
set(install_data ${install_data} PARENT_SCOPE)
endfunction()
Expand Down

0 comments on commit 160b7b3

Please sign in to comment.