TCM 1.1.0
A CMake module to reduce boilerplate
Loading...
Searching...
No Matches
ISPC

Since CMake 3.19, ISPC is straightforward to use :

  • make sure to install ISPC and add its executable to path,
  • .ispc files can be added as regular sources files to a target, e.g. for tests/ispc/ :
project(TEST_Ispc
LANGUAGES
C CXX
ISPC # REQUIRED
)
add_library(ispc_lib STATIC simple.ispc)

Following properties are overridable:

  • ISPC_HEADER_DIRECTORY per target, or CMAKE_ISPC_HEADER_DIRECTORY globally (default CMAKE_CURRENT_BINARY).
  • ISPC_HEADER_SUFFIX per target, or CMAKE_ISPC_HEADER_SUFFIX globally (default _ispc.h).
  • ISPC_INSTRUCTION_SETS per target, or CMAKE_ISPC_INSTRUCTION_SETS globally (default should be the most capable one if we follow ispc's documentation).

There are nothing else to do for executable targets. However, by default, a library with .ispc files doesn't include ISPC_HEADER_DIRECTORY, so the following is needed:

target_include_directories(ispc_lib PUBLIC $<TARGET_PROPERTY:ISPC_HEADER_DIRECTORY>)

If you want to change a property, use

set_target_property(ispc_lib PROPERTIES ISPC_HEADER_DIRECTORY ...)

TCM provide a single convenience function to set these for a target through function's parameters.

tcm_target_setup_ispc(your_target
[ISPC_HEADER_DIRECTORY $<TARGET_PROPERTY:ISPC_HEADER_DIRECTORY>]
[ISPC_HEADER_SUFFIX "_ispc.h"]
[ISPC_INSTRUCTION_SETS "most capable one by default"]
)