summaryrefslogtreecommitdiffstats
path: root/cmake/scripts/common/GenerateVersionedFiles.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/scripts/common/GenerateVersionedFiles.cmake')
-rw-r--r--cmake/scripts/common/GenerateVersionedFiles.cmake38
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 @@
1include(${CORE_SOURCE_DIR}/cmake/scripts/common/Macros.cmake)
2
3core_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)
8function(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}")
12endfunction()
13
14# add-on xml's
15file(GLOB ADDON_XML_IN_FILE ${CORE_SOURCE_DIR}/addons/*/addon.xml.in)
16foreach(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)
36endforeach()
37
38generate_versioned_file(xbmc/CompileInfo.cpp.in ${CORE_BUILD_DIR}/xbmc/CompileInfo.cpp)