[MIR][NFC] Use `std::move` to avoid copying (#125930)
[llvm-project.git] / offload / liboffload / API / CMakeLists.txt
blob8fd6cb539374a57db78355e0d868b66280d69bed
1 # The OffloadGenerate target is used to regenerate the generated files in the
2 # include directory. These files are checked in with the rest of the source,
3 # therefore it is only needed when making changes to the API.
5 find_program(CLANG_FORMAT clang-format PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH)
6 if (CLANG_FORMAT)
7     set(LLVM_TARGET_DEFINITIONS ${CMAKE_CURRENT_SOURCE_DIR}/OffloadAPI.td)
9     tablegen(OFFLOAD OffloadAPI.h -gen-api)
10     tablegen(OFFLOAD OffloadEntryPoints.inc -gen-entry-points)
11     tablegen(OFFLOAD OffloadFuncs.inc -gen-func-names)
12     tablegen(OFFLOAD OffloadImplFuncDecls.inc -gen-impl-func-decls)
13     tablegen(OFFLOAD OffloadPrint.hpp -gen-print-header)
15     set(OFFLOAD_GENERATED_FILES ${TABLEGEN_OUTPUT})
16     add_public_tablegen_target(OffloadGenerate)
17     add_custom_command(TARGET OffloadGenerate POST_BUILD COMMAND ${CLANG_FORMAT}
18         -i ${OFFLOAD_GENERATED_FILES})
19     add_custom_command(TARGET OffloadGenerate POST_BUILD COMMAND ${CMAKE_COMMAND}
20         -E copy_if_different ${OFFLOAD_GENERATED_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/../include/generated")
21 else()
22     message(WARNING "clang-format was not found, so the OffloadGenerate target\
23         will not be available. Offload will still build, but you will not be\
24         able to make changes to the API.")
25 endif()