llvm.org GIT mirror llvm / 02516ba
CMake: Non-working code for auto-building the native tblgen util when cross-compiling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58950 91177308-0d34-0410-b5e6-96231b3b80d8 Oscar Fuentes 10 years ago
2 changed file(s) with 42 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
113113 set(LLVM_TABLEGEN "tblgen" CACHE
114114 STRING "Native TableGen executable.")
115115
116 add_subdirectory(utils/TableGen)
117
116118 if( CMAKE_CROSSCOMPILING )
119 # This adds a dependency on target `tblgen', so must go after utils/TableGen
117120 include( CrossCompileLLVM )
118121 endif( CMAKE_CROSSCOMPILING )
119
120 add_subdirectory(utils/TableGen)
121122
122123 add_custom_command(OUTPUT ${llvm_builded_incs_dir}/Intrinsics.gen
123124 COMMAND ${LLVM_TABLEGEN} -gen-intrinsic -I ${LLVM_MAIN_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR}/llvm/Intrinsics.td -o ${llvm_builded_incs_dir}/Intrinsics.gen
None # TODO: Build a native tblgen when cross-compiling, if the user
1 # didn't set LLVM_TABLEGEN. Then, remove this check:
2 if( CMAKE_CROSSCOMPILING AND ${LLVM_TABLEGEN} STREQUAL "tblgen" )
0
1 if( ${LLVM_TABLEGEN} STREQUAL "tblgen" )
2 # TODO: remove this when autobuilding the native tblgen works.
33 message(FATAL_ERROR
44 "Set LLVM_TABLEGEN to the full route to a native tblgen executable")
5
6 message(STATUS "Configuring native TableGen...")
7 set(CX_NATIVE_TG_DIR "${CMAKE_BINARY_DIR}/native")
8
9 execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CX_NATIVE_TG_DIR}
10 RESULT_VARIABLE CX_NATIVE_TG_RV)
11 if( NOT CX_NATIVE_TG_RV EQUAL 0 )
12 message(FATAL_ERROR "Failed to create directory ${CX_NATIVE_TG_DIR}")
13 endif()
14
15 execute_process(
16 COMMAND ${CMAKE_COMMAND} -UMAKE_TOOLCHAIN_FILE -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR}
17 WORKING_DIRECTORY ${CX_NATIVE_TG_DIR}
18 RESULT_VARIABLE CX_NATIVE_TG_RV
19 ERROR_VARIABLE CX_NATIVE_TG_ERROR)
20 if( NOT CX_NATIVE_TG_RV EQUAL 0 )
21 message(FATAL_ERROR
22 "Error while configuring native TableGen:\n${CX_NATIVE_TG_ERROR}")
23 endif()
24
25 message(STATUS "Native TableGen configured.")
26
27 set(LLVM_TABLEGEN "${CX_NATIVE_TG_DIR}/bin/tblgen")
28
29 add_custom_command(OUTPUT ${LLVM_TABLEGEN}
30 COMMAND ${CMAKE_BUILD_TOOL} -C ${CX_NATIVE_TG_DIR}/utils/TableGen
31 COMMENT "Building native TableGen...")
32 add_custom_target(NativeTableGen DEPENDS ${LLVM_TABLEGEN})
33 add_dependencies(tblgen NativeTableGen)
34
35 # TODO: We should clean the native build when the `clean target
36 # is invoked. This doesn't work.
37 # add_custom_command(TARGET clean
38 # COMMAND ${CMAKE_BUILD_TOOL} -C ${CX_NATIVE_TG_DIR}/utils/TableGen clean
39 # POST_BUILD
40 # COMMENT "Cleaning native TableGen...")
541 endif()