graphitemaster / incbin

Include binary files in C/C++
The Unlicense
938 stars 87 forks source link

Add cmake #42

Open SMP33 opened 3 years ago

SMP33 commented 3 years ago

When I used INCBIN with CMake I have an error like this:

  "C:\Users\UserName\AppData\Local\Temp\ccgFslxv.s: Assembler messages:"
  "C:\Users\UserName\AppData\Local\Temp\ccgFslxv.s:2549: Error: file not found: FileName.txt" .

This happens because the compiler cannot find the file in the build directory. With this macro you can automatically copy used files with a template [filename].incbin.[file extension] from directory [input_dir_absolute_path] to directory [output_dir_absolute_path]. Сopied files will looks like [filename].[file extension]. Usage: 1) move_incbin_to_destination([input_dir_absolute_path] [output_dir_absolute_path]) This copy files from [input_dir_absolute_path] to [output_dir_absolute_path] and remove ".incbin" from them names. 2) move_incbin_to_destination([input_dir_absolute_path] [output_dir_absolute_path] RECURSE) This copy files from [input_dir_absolute_path]/[recursive all child folders] to [output_dir_absolute_path]/[recursive all child folders from input dir] and remove ".incbin" from them names. Typical usage is (including quotes): move_incbin_to_destination( "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" RECURSE) You can find examples in folder "test".