CMake: defines and uses macro add_llvm_definitions for keeping track
[opencl/llvm.git] / cmake / modules / TableGen.cmake
1 # LLVM_TARGET_DEFINITIONS must contain the name of the .td file to process.
2 # Extra parameters for `tblgen' may come after `ofn' parameter.
3 # Adds the name of the generated file to TABLEGEN_OUTPUT.
5 macro(tablegen ofn)
6   file(GLOB all_tds "*.td")
8   add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
9     COMMAND ${LLVM_TABLEGEN} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
10     -I ${LLVM_MAIN_SRC_DIR}/lib/Target -I ${LLVM_MAIN_INCLUDE_DIR}
11     ${CMAKE_CURRENT_SOURCE_DIR}/${LLVM_TARGET_DEFINITIONS} 
12     -o ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
13     DEPENDS ${LLVM_TABLEGEN} ${all_tds}
14     COMMENT "Building ${ofn}.tmp..."
15     )
16   add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
17     COMMAND ${CMAKE_COMMAND} -E copy_if_different 
18     ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
19     DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
20     COMMENT "Building ${ofn}..."
21     )
22   set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn})
23 endmacro(tablegen)