blob: 36ae306d01f2d353f72e747c74adacbcad1d61f2 [file] [log] [blame]
Oscar Fuentes02516ba2008-11-10 01:32:14 +00001
2if( ${LLVM_TABLEGEN} STREQUAL "tblgen" )
3 # TODO: remove this when autobuilding the native tblgen works.
Oscar Fuentes3ab40ca2008-11-09 18:53:19 +00004 message(FATAL_ERROR
5 "Set LLVM_TABLEGEN to the full route to a native tblgen executable")
Oscar Fuentes02516ba2008-11-10 01:32:14 +00006
7 message(STATUS "Configuring native TableGen...")
8 set(CX_NATIVE_TG_DIR "${CMAKE_BINARY_DIR}/native")
9
10 execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CX_NATIVE_TG_DIR}
11 RESULT_VARIABLE CX_NATIVE_TG_RV)
12 if( NOT CX_NATIVE_TG_RV EQUAL 0 )
13 message(FATAL_ERROR "Failed to create directory ${CX_NATIVE_TG_DIR}")
14 endif()
15
16 execute_process(
17 COMMAND ${CMAKE_COMMAND} -UMAKE_TOOLCHAIN_FILE -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR}
18 WORKING_DIRECTORY ${CX_NATIVE_TG_DIR}
19 RESULT_VARIABLE CX_NATIVE_TG_RV
20 ERROR_VARIABLE CX_NATIVE_TG_ERROR)
21 if( NOT CX_NATIVE_TG_RV EQUAL 0 )
22 message(FATAL_ERROR
23 "Error while configuring native TableGen:\n${CX_NATIVE_TG_ERROR}")
24 endif()
25
26 message(STATUS "Native TableGen configured.")
27
28 set(LLVM_TABLEGEN "${CX_NATIVE_TG_DIR}/bin/tblgen")
29
30 add_custom_command(OUTPUT ${LLVM_TABLEGEN}
31 COMMAND ${CMAKE_BUILD_TOOL} -C ${CX_NATIVE_TG_DIR}/utils/TableGen
32 COMMENT "Building native TableGen...")
33 add_custom_target(NativeTableGen DEPENDS ${LLVM_TABLEGEN})
34 add_dependencies(tblgen NativeTableGen)
35
36 # TODO: We should clean the native build when the `clean target
37 # is invoked. This doesn't work.
38# add_custom_command(TARGET clean
39# COMMAND ${CMAKE_BUILD_TOOL} -C ${CX_NATIVE_TG_DIR}/utils/TableGen clean
40# POST_BUILD
41# COMMENT "Cleaning native TableGen...")
Oscar Fuentes3ab40ca2008-11-09 18:53:19 +000042endif()