From 4830f27a40323fe859dc166337a2b861877b7121 Mon Sep 17 00:00:00 2001 From: manuel Date: Mon, 1 Jan 2018 13:40:09 +0100 Subject: sync with upstream --- cmake/scripts/common/AddonHelpers.cmake | 19 ++++++-- cmake/scripts/common/ArchSetup.cmake | 3 ++ cmake/scripts/common/GenerateVersionedFiles.cmake | 10 ++--- cmake/scripts/common/HandleDepends.cmake | 13 ++++++ cmake/scripts/common/Macros.cmake | 54 +++++++++++++++++++---- cmake/scripts/common/Platform.cmake | 9 +++- cmake/scripts/common/PrepareEnv.cmake | 14 ++---- 7 files changed, 93 insertions(+), 29 deletions(-) (limited to 'cmake/scripts/common') diff --git a/cmake/scripts/common/AddonHelpers.cmake b/cmake/scripts/common/AddonHelpers.cmake index 2fafe79..c11923e 100644 --- a/cmake/scripts/common/AddonHelpers.cmake +++ b/cmake/scripts/common/AddonHelpers.cmake @@ -52,7 +52,8 @@ macro (build_addon target prefix libs) # Read used headers from addon, needed to identitfy used kodi addon interface headers if(${prefix}_HEADERS) # Add the used header files defined with CMakeLists.txt from addon itself - if(${prefix}_HEADERS MATCHES ${PROJECT_SOURCE_DIR}) + string(FIND "${${prefix}_HEADERS}" "${PROJECT_SOURCE_DIR}" position) + if(position GREATER -1) # include path name already complete list(APPEND USED_SOURCES ${${prefix}_HEADERS}) else() @@ -75,7 +76,8 @@ macro (build_addon target prefix libs) endif() # Add the used source files defined with CMakeLists.txt from addon itself - if(${prefix}_SOURCES MATCHES ${PROJECT_SOURCE_DIR}) + string(FIND "${${prefix}_SOURCES}" "${PROJECT_SOURCE_DIR}" position) + if(position GREATER -1) # include path name already complete list(APPEND USED_SOURCES ${${prefix}_SOURCES}) else() @@ -228,7 +230,9 @@ macro (build_addon target prefix libs) set(CPACK_COMPONENTS_IGNORE_GROUPS 1) list(APPEND CPACK_COMPONENTS_ALL ${target}-${${prefix}_VERSION}) # Pack files together to create an archive - install(DIRECTORY ${target} DESTINATION ./ COMPONENT ${target}-${${prefix}_VERSION} PATTERN "*.xml.in" EXCLUDE) + install(DIRECTORY ${target} DESTINATION ./ + COMPONENT ${target}-${${prefix}_VERSION} + REGEX ".+\\.xml\\.in(clude)?$" EXCLUDE) if(WIN32) if(NOT CPACK_PACKAGE_DIRECTORY) # determine the temporary path @@ -321,7 +325,8 @@ macro (build_addon target prefix libs) if (${prefix}_CUSTOM_BINARY) install(FILES ${LIBRARY_LOCATION} DESTINATION ${CMAKE_INSTALL_LIBDIR}/addons/${target} RENAME ${LIBRARY_FILENAME}) endif() - install(DIRECTORY ${target} DESTINATION ${CMAKE_INSTALL_DATADIR}/addons PATTERN "*.xml.in" EXCLUDE) + install(DIRECTORY ${target} DESTINATION ${CMAKE_INSTALL_DATADIR}/addons + REGEX ".+\\.xml\\.in(clude)?$" EXCLUDE) if(${prefix}_CUSTOM_DATA) install(DIRECTORY ${${prefix}_CUSTOM_DATA} DESTINATION ${CMAKE_INSTALL_DATADIR}/addons/${target}/resources) endif() @@ -348,6 +353,12 @@ macro (build_addon target prefix libs) COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_LOCATION} ${${APP_NAME_UC}_BUILD_DIR}/addons/${target}/${LIBRARY_FILENAME}) + if(${prefix}_ADDITIONAL_BINARY) + add_custom_command(TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${${prefix}_ADDITIONAL_BINARY} + ${${APP_NAME_UC}_BUILD_DIR}/addons/${target}) + endif() endif() endmacro() diff --git a/cmake/scripts/common/ArchSetup.cmake b/cmake/scripts/common/ArchSetup.cmake index 357c14c..3b81533 100644 --- a/cmake/scripts/common/ArchSetup.cmake +++ b/cmake/scripts/common/ArchSetup.cmake @@ -11,6 +11,9 @@ # DEP_DEFINES - compiler definitions for system dependencies (e.g. LIRC) # + the results of compiler tests etc. +# workaround a bug in older cmake, where binutils wouldn't be set after deleting CMakeCache.txt +include(CMakeFindBinUtils) + include(CheckCXXSourceCompiles) include(CheckSymbolExists) include(CheckFunctionExists) diff --git a/cmake/scripts/common/GenerateVersionedFiles.cmake b/cmake/scripts/common/GenerateVersionedFiles.cmake index 90b2173..011f495 100644 --- a/cmake/scripts/common/GenerateVersionedFiles.cmake +++ b/cmake/scripts/common/GenerateVersionedFiles.cmake @@ -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}) @@ -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) diff --git a/cmake/scripts/common/HandleDepends.cmake b/cmake/scripts/common/HandleDepends.cmake index 85d2cf4..49e5ac8 100644 --- a/cmake/scripts/common/HandleDepends.cmake +++ b/cmake/scripts/common/HandleDepends.cmake @@ -7,6 +7,10 @@ function(add_addon_depends addon searchpath) set(OUTPUT_DIR ${ADDON_DEPENDS_PATH}) # look for platform-specific dependencies file(GLOB_RECURSE cmake_input_files ${searchpath}/${CORE_SYSTEM_NAME}/*.txt) + # backward compatibility + if(NOT cmake_input_files AND CORE_SYSTEM_NAME STREQUAL windowsstore) + file(GLOB_RECURSE cmake_input_files ${searchpath}/windows/*.txt) + endif() file(GLOB_RECURSE cmake_input_files2 ${searchpath}/common/*.txt) list(APPEND cmake_input_files ${cmake_input_files2}) @@ -67,6 +71,11 @@ function(add_addon_depends addon searchpath) -DCORE_SYSTEM_NAME=${CORE_SYSTEM_NAME} -DENABLE_STATIC=1 -DBUILD_SHARED_LIBS=0) + # windows store args + if (CMAKE_SYSTEM_NAME STREQUAL WindowsStore) + list(APPEND BUILD_ARGS -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + -DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}) + endif() # if there are no make rules override files available take care of manually passing on ARCH_DEFINES if(NOT CMAKE_USER_MAKE_RULES_OVERRIDE AND NOT CMAKE_USER_MAKE_RULES_OVERRIDE_CXX) # make sure we create strings, not lists @@ -147,6 +156,10 @@ function(add_addon_depends addon searchpath) if(EXISTS ${dir}/${CORE_SYSTEM_NAME}-deps.txt) file(STRINGS ${dir}/${CORE_SYSTEM_NAME}-deps.txt deps) message(STATUS "${id} depends: ${deps}") + # backward compatibility + elseif(CORE_SYSTEM_NAME STREQUAL windowsstore AND EXISTS ${dir}/windows-deps.txt) + file(STRINGS ${dir}/windows-deps.txt deps) + message(STATUS "${id} depends: ${deps}") elseif(EXISTS ${dir}/deps.txt) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/deps.txt) file(STRINGS ${dir}/deps.txt deps) diff --git a/cmake/scripts/common/Macros.cmake b/cmake/scripts/common/Macros.cmake index 9f00bb7..d508f87 100644 --- a/cmake/scripts/common/Macros.cmake +++ b/cmake/scripts/common/Macros.cmake @@ -72,11 +72,15 @@ function(core_add_library name) add_library(${name} STATIC ${SOURCES} ${HEADERS} ${OTHERS}) set_target_properties(${name} PROPERTIES PREFIX "") set(core_DEPENDS ${name} ${core_DEPENDS} CACHE STRING "" FORCE) - add_dependencies(${name} libcpluff ffmpeg dvdnav crossguid ${PLATFORM_GLOBAL_TARGET_DEPS}) + set(lib_DEPS libcpluff ffmpeg crossguid ${PLATFORM_GLOBAL_TARGET_DEPS}) + if(NOT CORE_SYSTEM_NAME STREQUAL windowsstore) + list(APPEND lib_DEPS dvdnav) + endif() + add_dependencies(${name} ${lib_DEPS}) set(CORE_LIBRARY ${name} PARENT_SCOPE) # Add precompiled headers to Kodi main libraries - if(CORE_SYSTEM_NAME STREQUAL windows) + if(CORE_SYSTEM_NAME MATCHES windows) add_precompiled_header(${name} pch.h ${CMAKE_SOURCE_DIR}/xbmc/platform/win32/pch.cpp PCH_TARGET kodi) set_language_cxx(${name}) target_link_libraries(${name} PUBLIC effects11) @@ -102,7 +106,11 @@ function(core_add_test_library name) set_target_properties(${name} PROPERTIES PREFIX "" EXCLUDE_FROM_ALL 1 FOLDER "Build Utilities/tests") - add_dependencies(${name} libcpluff ffmpeg dvdnav crossguid) + set(lib_DEPS libcpluff ffmpeg crossguid ${PLATFORM_GLOBAL_TARGET_DEPS}) + if(NOT CORE_SYSTEM_NAME STREQUAL windowsstore) + list(APPEND lib_DEPS dvdnav) + endif() + add_dependencies(${name} ${lib_DEPS}) set(test_archives ${test_archives} ${name} CACHE STRING "" FORCE) endif() foreach(src IN LISTS SOURCES SUPPORTED_SOURCES HEADERS OTHERS) @@ -314,6 +322,7 @@ function(copy_files_from_filelist_to_buildtree pattern) copy_file_to_buildtree(${CMAKE_SOURCE_DIR}/${file} DIRECTORY ${dest} ${DIR_OPTION}) endif() endforeach() + set(DIR_OPTION) endforeach() endforeach() endforeach() @@ -583,7 +592,8 @@ function(core_find_git_rev stamp) else() find_package(Git) if(GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git) - execute_process(COMMAND ${GIT_EXECUTABLE} update-index --ignore-submodules --refresh -q) + execute_process(COMMAND ${GIT_EXECUTABLE} update-index --ignore-submodules -q --refresh + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) execute_process(COMMAND ${GIT_EXECUTABLE} diff-files --ignore-submodules --quiet -- RESULT_VARIABLE status_code WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) @@ -610,7 +620,11 @@ function(core_find_git_rev stamp) string(REPLACE "-" "" DATE ${DATE}) else() string(TIMESTAMP DATE "%Y%m%d" UTC) - set(HASH "nogitfound") + if(EXISTS ${CMAKE_SOURCE_DIR}/VERSION) + file(STRINGS ${CMAKE_SOURCE_DIR}/VERSION HASH LIMIT_INPUT 16) + else() + set(HASH "nogitfound") + endif() endif() cmake_parse_arguments(arg "FULL" "" "" ${ARGN}) if(arg_FULL) @@ -637,6 +651,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) @@ -651,9 +666,28 @@ 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(REGEX REPLACE "([^ ;]*) ([^;]*)" "\\1;\\2" version_list "${version_list};${json_version}") + set(version_props + ADDON_API + APP_NAME + APP_PACKAGE + COMPANY_NAME + JSONRPC_VERSION + PACKAGE_DESCRIPTION + PACKAGE_IDENTITY + PACKAGE_PUBLISHER + VERSION_MAJOR + VERSION_MINOR + VERSION_TAG + VERSION_CODE + WEBSITE + ) + cmake_parse_arguments(APP "" "${version_props}" "" ${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}$'") + endif() set(APP_NAME ${APP_APP_NAME}) # inconsistency but APP_APP_NAME looks weird string(TOLOWER ${APP_APP_NAME} APP_NAME_LC) string(TOUPPER ${APP_APP_NAME} APP_NAME_UC) @@ -665,6 +699,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 @@ -689,6 +724,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 diff --git a/cmake/scripts/common/Platform.cmake b/cmake/scripts/common/Platform.cmake index b19b7e5..5ac233a 100644 --- a/cmake/scripts/common/Platform.cmake +++ b/cmake/scripts/common/Platform.cmake @@ -2,14 +2,17 @@ if(NOT CORE_SYSTEM_NAME) string(TOLOWER ${CMAKE_SYSTEM_NAME} CORE_SYSTEM_NAME) endif() -if(CORE_SYSTEM_NAME STREQUAL linux) +if(CORE_SYSTEM_NAME STREQUAL linux OR CORE_SYSTEM_NAME STREQUAL freebsd) # Set default CORE_PLATFORM_NAME to X11 # This is overridden by user setting -DCORE_PLATFORM_NAME= set(_DEFAULT_PLATFORM X11) + option(ENABLE_APP_AUTONAME "Enable renaming the binary according to windowing?" ON) else() string(TOLOWER ${CORE_SYSTEM_NAME} _DEFAULT_PLATFORM) endif() +set(APP_BINARY_SUFFIX ".bin") + # # Note: please do not use CORE_PLATFORM_NAME in any checks, # use the normalized to lower case CORE_PLATFORM_NAME_LC (see below) instead @@ -23,10 +26,12 @@ string(TOLOWER ${CORE_PLATFORM_NAME} CORE_PLATFORM_NAME_LC) list(APPEND final_message "Platform: ${CORE_PLATFORM_NAME}") if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_NAME_LC}.cmake) include(${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_NAME_LC}.cmake) + if(ENABLE_APP_AUTONAME) + set(APP_BINARY_SUFFIX "-${CORE_PLATFORM_NAME_LC}") + endif() else() file(GLOB _platformnames RELATIVE ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/ ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/*.cmake) string(REPLACE ".cmake" " " _platformnames ${_platformnames}) message(FATAL_ERROR "invalid CORE_PLATFORM_NAME: ${CORE_PLATFORM_NAME_LC}\nValid platforms: ${_platformnames}") endif() - diff --git a/cmake/scripts/common/PrepareEnv.cmake b/cmake/scripts/common/PrepareEnv.cmake index 5a6066b..1426148 100644 --- a/cmake/scripts/common/PrepareEnv.cmake +++ b/cmake/scripts/common/PrepareEnv.cmake @@ -40,17 +40,11 @@ file(COPY ${CORE_SOURCE_DIR}/cmake/scripts/common/AddonHelpers.cmake ${CORE_SOURCE_DIR}/cmake/scripts/common/AddOptions.cmake DESTINATION ${APP_LIB_DIR}) -# copy standard add-on include files -file(COPY ${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi/ - DESTINATION ${APP_INCLUDE_DIR} REGEX ".txt" EXCLUDE) - ### copy all the addon binding header files to include/kodi -# parse addon-bindings.mk to get the list of header files to copy -core_file_read_filtered(bindings ${CORE_SOURCE_DIR}/xbmc/addons/addon-bindings.mk) -foreach(header ${bindings}) - # copy the header file to include/kodi - configure_file(${CORE_SOURCE_DIR}/${header} ${APP_INCLUDE_DIR} COPYONLY) -endforeach() +include(${CORE_SOURCE_DIR}/xbmc/addons/AddonBindings.cmake) +file(COPY ${CORE_ADDON_BINDINGS_FILES} ${CORE_ADDON_BINDINGS_DIRS}/ + DESTINATION ${APP_INCLUDE_DIR} + REGEX ".txt" EXCLUDE) ### processing additional tools required by the platform if(EXISTS ${CORE_SOURCE_DIR}/cmake/scripts/${CORE_SYSTEM_NAME}/tools/) -- cgit v1.2.3