diff options
Diffstat (limited to 'cmake/scripts/common/GenerateVersionedFiles.cmake')
| -rw-r--r-- | cmake/scripts/common/GenerateVersionedFiles.cmake | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/cmake/scripts/common/GenerateVersionedFiles.cmake b/cmake/scripts/common/GenerateVersionedFiles.cmake new file mode 100644 index 0000000..90b2173 --- /dev/null +++ b/cmake/scripts/common/GenerateVersionedFiles.cmake | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | include(${CORE_SOURCE_DIR}/cmake/scripts/common/Macros.cmake) | ||
| 2 | |||
| 3 | core_find_versions() | ||
| 4 | |||
| 5 | # configure_file without dependency tracking | ||
| 6 | # configure_file would register additional file dependencies that interfere | ||
| 7 | # with the ones from add_custom_command (and the generation would happen twice) | ||
| 8 | function(generate_versioned_file _SRC _DEST) | ||
| 9 | file(READ ${CORE_SOURCE_DIR}/${_SRC} file_content) | ||
| 10 | string(CONFIGURE "${file_content}" file_content @ONLY) | ||
| 11 | file(WRITE ${CMAKE_BINARY_DIR}/${_DEST} "${file_content}") | ||
| 12 | endfunction() | ||
| 13 | |||
| 14 | # add-on xml's | ||
| 15 | file(GLOB ADDON_XML_IN_FILE ${CORE_SOURCE_DIR}/addons/*/addon.xml.in) | ||
| 16 | foreach(loop_var ${ADDON_XML_IN_FILE}) | ||
| 17 | # prevent 'xbmc.json'; will be obtained from 'xbmc/interfaces/json-rpc/schema/CMakeLists.txt'. | ||
| 18 | if(loop_var MATCHES "xbmc.json") | ||
| 19 | continue() | ||
| 20 | endif() | ||
| 21 | |||
| 22 | list(GET loop_var 0 xml_name) | ||
| 23 | |||
| 24 | string(REPLACE "/addon.xml.in" "" source_dir ${xml_name}) | ||
| 25 | string(REPLACE ${CORE_SOURCE_DIR} ${CMAKE_BINARY_DIR} dest_dir ${source_dir}) | ||
| 26 | file(MAKE_DIRECTORY ${dest_dir}) | ||
| 27 | |||
| 28 | # copy everything except addon.xml.in to build folder | ||
| 29 | file(COPY "${source_dir}" DESTINATION "${CMAKE_BINARY_DIR}/addons" REGEX ".xml.in" EXCLUDE) | ||
| 30 | |||
| 31 | configure_file(${source_dir}/addon.xml.in ${dest_dir}/addon.xml @ONLY) | ||
| 32 | |||
| 33 | unset(source_dir) | ||
| 34 | unset(dest_dir) | ||
| 35 | unset(xml_name) | ||
| 36 | endforeach() | ||
| 37 | |||
| 38 | generate_versioned_file(xbmc/CompileInfo.cpp.in ${CORE_BUILD_DIR}/xbmc/CompileInfo.cpp) | ||
