summaryrefslogtreecommitdiffstats
path: root/mmc_updater/cmake/modules/GenerateCppResourceFile.cmake
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-12-09 12:04:05 -0600
committerAndrew <forkk@forkk.net>2013-12-09 12:04:05 -0600
commit7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c (patch)
tree52097b57dc7d18ec4e35ef3a8e554af2d91545e8 /mmc_updater/cmake/modules/GenerateCppResourceFile.cmake
parent9410dd042ea62224fa3e0eb3b525abbdf0c316ee (diff)
parent220e07aef4a34dca9f31ae0c5bb994e5c594125d (diff)
downloadMultiMC-7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c.tar
MultiMC-7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c.tar.gz
MultiMC-7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c.tar.lz
MultiMC-7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c.tar.xz
MultiMC-7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c.zip
Merge branch 'feature_updater' into develop
Diffstat (limited to 'mmc_updater/cmake/modules/GenerateCppResourceFile.cmake')
-rw-r--r--mmc_updater/cmake/modules/GenerateCppResourceFile.cmake23
1 files changed, 23 insertions, 0 deletions
diff --git a/mmc_updater/cmake/modules/GenerateCppResourceFile.cmake b/mmc_updater/cmake/modules/GenerateCppResourceFile.cmake
new file mode 100644
index 00000000..59adfd58
--- /dev/null
+++ b/mmc_updater/cmake/modules/GenerateCppResourceFile.cmake
@@ -0,0 +1,23 @@
+
+# Convert a binary data file into a C++
+# source file for embedding into an application binary
+#
+# Currently only implemented for Unix. Requires the 'xxd'
+# tool to be installed.
+#
+# TARGET_NAME : The name of the target to generate
+#
+# INPUT_DIR : The directory containing the input binary data file
+#
+# INPUT_FILE : The name of the binary data file in ${INPUT_DIR} to be converted into a C++
+# source file. The name of the input file will be used as the basis for the
+# symbols in the generated C++ file referring to the data buffer and its length.
+#
+# CPP_FILE : The path of the C++ source file to be generated.
+# See the documentation for xxd for information on
+# the structure of the generated source file.
+#
+function (generate_cpp_resource_file TARGET_NAME INPUT_FILE CPP_FILE)
+ add_custom_command(OUTPUT ${CPP_FILE} COMMAND cd `dirname ${INPUT_FILE}` && xxd -i `basename ${INPUT_FILE}` ${CPP_FILE} DEPENDS ${INPUT_FILE})
+ add_custom_target(${TARGET_NAME} ALL DEPENDS ${CPP_FILE})
+endfunction()