Only run C preprocessor in cmake?

I'm trying to use cmake to simplify distributing my OpenCL program. I have a kernel file which includes several headers and other source files, and I want to have a single self contained executable.

My plan is to have cmake run the C preprocessor on the kernel source, turning the cl file and its includes into a single unit which is easier to work with.

I can use add_custom_command to do it by calling gcc/clang with -E, but then I don't get the flags to include the right directories to find the various header files in the command, and I don't see an easy way to find all current include directories to use in the custom call to the compiler.

Is there a way to run only the C preprocessor on a file with the current cmake environment?

14
задан Brian Tompsett - 汤莱恩 26 February 2016 в 19:57
поделиться

1 ответ

Я бы предложил другой подход.

  1. Соберите ядро ​​в двоичный файл (пример для ATI Stream: http://developer.amd.com/support/KnowledgeBase/Lists/KnowledgeBase/DispForm.aspx?ID=115)

  2. Скомпилируйте эти двоичные данные в свою программу (как большой двоичный объект char[]) и загрузите их при запуске вашей программы.

С cmake и пользовательскими целями это должно быть довольно просто.

0
ответ дан 1 December 2019 в 13:58
поделиться
Другие вопросы по тегам:

Похожие вопросы: