Skip to content

Commit

Permalink
[cmake] support building with ninja on posix platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
wsnipex committed Nov 1, 2017
1 parent 150591e commit 64b82bb
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion addons/xbmc.json/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="xbmc.json" version="@jsonrpc_version@" provider-name="Team XBMC">
<addon id="xbmc.json" version="@JSONRPC_VERSION@" provider-name="Team XBMC">
<backwards-compatibility abi="6.0.0"/>
<requires>
<import addon="xbmc.core" version="0.1.0"/>
Expand Down
10 changes: 5 additions & 5 deletions cmake/scripts/common/GenerateVersionedFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ endfunction()

# add-on xml's
file(GLOB ADDON_XML_IN_FILE ${CORE_SOURCE_DIR}/addons/*/addon.xml.in)
foreach(loop_var ${ADDON_XML_IN_FILE})
# prevent 'xbmc.json'; will be obtained from 'xbmc/interfaces/json-rpc/schema/CMakeLists.txt'.
if(loop_var MATCHES "xbmc.json")
continue()
endif()

# remove 'xbmc.json', will be created from 'xbmc/interfaces/json-rpc/schema/CMakeLists.txt'
list(REMOVE_ITEM ADDON_XML_IN_FILE xbmc.json)

foreach(loop_var ${ADDON_XML_IN_FILE})
list(GET loop_var 0 xml_name)

string(REPLACE "/addon.xml.in" "" source_dir ${xml_name})
Expand All @@ -35,4 +34,5 @@ foreach(loop_var ${ADDON_XML_IN_FILE})
unset(xml_name)
endforeach()


generate_versioned_file(xbmc/CompileInfo.cpp.in ${CORE_BUILD_DIR}/xbmc/CompileInfo.cpp)
10 changes: 8 additions & 2 deletions cmake/scripts/common/Macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ endfunction()
# APP_VERSION - the app version (${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}-${APP_VERSION_TAG})
# APP_ADDON_API - the addon API version in the form of 16.9.702
# FILE_VERSION - file version in the form of 16,9,702,0 - Windows only
# JSONRPC_VERSION - the json api version in the form of 8.3.0
#
# Set various variables defined in "versions.h"
macro(core_find_versions)
Expand All @@ -657,8 +658,9 @@ macro(core_find_versions)

include(CMakeParseArguments)
core_file_read_filtered(version_list ${CORE_SOURCE_DIR}/version.txt)
string(REPLACE " " ";" version_list "${version_list}")
cmake_parse_arguments(APP "" "APP_NAME;COMPANY_NAME;WEBSITE;VERSION_MAJOR;VERSION_MINOR;VERSION_TAG;VERSION_CODE;ADDON_API;APP_PACKAGE" "" ${version_list})
core_file_read_filtered(json_version ${CORE_SOURCE_DIR}/xbmc/interfaces/json-rpc/schema/version.txt)
string(REPLACE " " ";" version_list "${version_list} ${json_version}")
cmake_parse_arguments(APP "" "APP_NAME;COMPANY_NAME;WEBSITE;VERSION_MAJOR;VERSION_MINOR;VERSION_TAG;VERSION_CODE;ADDON_API;APP_PACKAGE;JSONRPC_VERSION" "" ${version_list})

if(NOT ${APP_VERSION_CODE} MATCHES "^[0-9]+\\.[0-9][0-9]?\\.[0-9][0-9]?[0-9]?$")
message(FATAL_ERROR "VERSION_CODE was set to ${APP_VERSION_CODE} in version.txt, but it has to match '^\\d+\\.\\d{1,2}\\.\\d{1,3}$'")
Expand All @@ -674,6 +676,7 @@ macro(core_find_versions)
string(TOLOWER ${APP_VERSION_TAG} APP_VERSION_TAG_LC)
endif()
string(REPLACE "." "," FILE_VERSION ${APP_ADDON_API}.0)
set(JSONRPC_VERSION ${APP_JSONRPC_VERSION})

# Set defines used in addon.xml.in and read from versions.h to set add-on
# version parts automatically
Expand All @@ -698,6 +701,9 @@ macro(core_find_versions)
if(NOT DEFINED APP_VERSION_MAJOR OR NOT DEFINED APP_VERSION_MINOR)
message(FATAL_ERROR "Could not determine app version! Make sure that ${CORE_SOURCE_DIR}/version.txt exists")
endif()
if(NOT DEFINED JSONRPC_VERSION)
message(FATAL_ERROR "Could not determine json-rpc version! Make sure that ${CORE_SOURCE_DIR}/xbmc/interfaces/json-rpc/schema/version.txt exists")
endif()
endmacro()

# add-on xml's
Expand Down
1 change: 1 addition & 0 deletions xbmc/interfaces/json-rpc/schema/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/addons/xbmc.json/addon.xml
COMMAND ${CMAKE_COMMAND}
-DCMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
-DCORE_BINARY_DIR=${CMAKE_BINARY_DIR}
-DCORE_SYSTEM_NAME=${CORE_SYSTEM_NAME}
-P ${CMAKE_CURRENT_SOURCE_DIR}/GenerateAddonXml.cmake
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
DEPENDS ${JSON_SRCS} ${CMAKE_SOURCE_DIR}/addons/xbmc.json/addon.xml.in
Expand Down
5 changes: 3 additions & 2 deletions xbmc/interfaces/json-rpc/schema/GenerateAddonXml.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
file(STRINGS ${CMAKE_SOURCE_DIR}/xbmc/interfaces/json-rpc/schema/version.txt jsonrpc_version)
include(${CMAKE_SOURCE_DIR}/cmake/scripts/common/Macros.cmake)
core_find_versions()

execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${CORE_BINARY_DIR}/addons/xbmc.json/addon.xml)
file(REMOVE ${CORE_BINARY_DIR}/addons/xbmc.json/addon.xml)
configure_file(${CMAKE_SOURCE_DIR}/addons/xbmc.json/addon.xml.in
${CORE_BINARY_DIR}/addons/xbmc.json/addon.xml @ONLY)
2 changes: 1 addition & 1 deletion xbmc/interfaces/json-rpc/schema/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.3.0
JSONRPC_VERSION 8.3.0

0 comments on commit 64b82bb

Please sign in to comment.