[英]How do I use CMake to build an ispc file?
I have a simple project.我有一个简单的项目。 It contains two files:
它包含两个文件:
main.c
kernel.ispc
(ispc files are source for https://ispc.github.io/ ) (ispc 文件是https://ispc.github.io/的来源)
To manually compile the file I would just use:要手动编译我只使用的文件:
ispc --target=sse2 kernel.ispc -o kernel.o
gcc -c main.c -o main.o
gcc main.o kernel.o -o my_program
So for my cmake file it would look intially look like所以对于我的 cmake 文件,它最初看起来像
project(my_program)
add_executable(my_program main.c)
but of course it wont link as it's missing symbols that are in kernel.o但当然它不会链接,因为它缺少 kernel.o 中的符号
So the question is: How do I get cmake to compile kernel.ispc
using the ispc
compiler, and how do I get cmake to then link it into my_program
?所以问题是:如何让 cmake 使用
kernel.ispc
编译器编译ispc
,以及如何让 cmake 将其链接到my_program
?
How do I get cmake to compile kernel.ispc using the ispc compiler?
如何让 cmake 使用 ispc 编译器编译 kernel.ispc?
Just use add_custom_command :只需使用add_custom_command :
add_custom_command(OUTPUT kernel.o
COMMAND ispc --target=sse2 ${CMAKE_SOURCE_DIR}/kernel.ispc -o kernel.o
DEPENDS kernel.ispc)
How do I get cmake to then link it into
my_program
?我如何让 cmake 将其链接到
my_program
?
From CMake view, .o
files are just another sources for executable:从 CMake 的角度来看,
.o
文件只是可执行文件的另一个来源:
add_executable(my_program main.c kernel.o)
I know this is an old question, but CMAKE 3.19 now has built in support for ISPC.我知道这是一个老问题,但 CMAKE 3.19 现在内置了对 ISPC 的支持。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.