llvm.org GIT mirror llvm / 41bdedf
CMake: Builds a native tblgen when cross-compiling and the user didn't set LLVM_TABLEGEN. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58953 91177308-0d34-0410-b5e6-96231b3b80d8 Oscar Fuentes 10 years ago
2 changed file(s) with 17 addition(s) and 28 deletion(s). Raw diff Collapse all Expand all
138138 set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${LLVM_LIBS} )
139139
140140 set(LLVM_TABLEGEN "tblgen" CACHE
141 STRING "Native TableGen executable.")
141 STRING "Native TableGen executable. Saves building one when cross-compiling.")
142142
143143 add_subdirectory(utils/TableGen)
144144
0
11 if( ${LLVM_TABLEGEN} STREQUAL "tblgen" )
2 # TODO: remove this when autobuilding the native tblgen works.
3 message(FATAL_ERROR
4 "Set LLVM_TABLEGEN to the full route to a native tblgen executable")
2 set(LLVM_TABLEGEN "${CX_NATIVE_TG_DIR}/bin/tblgen")
53
6 message(STATUS "Configuring native TableGen...")
7 set(CX_NATIVE_TG_DIR "${CMAKE_BINARY_DIR}/native")
4 message(STATUS "CX_NATIVE_TG_DIR : ${CX_NATIVE_TG_DIR}")
5 add_custom_command(OUTPUT ${CX_NATIVE_TG_DIR}
6 COMMAND ${CMAKE_COMMAND} -E make_directory ${CX_NATIVE_TG_DIR}
7 COMMENT "Creating ${CX_NATIVE_TG_DIR}...")
88
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(
9 add_custom_command(OUTPUT ${CX_NATIVE_TG_DIR}/CMakeCache.txt
1610 COMMAND ${CMAKE_COMMAND} -UMAKE_TOOLCHAIN_FILE -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR}
1711 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")
12 DEPENDS ${CX_NATIVE_TG_DIR}
13 COMMENT "Configuring native TableGen...")
2814
2915 add_custom_command(OUTPUT ${LLVM_TABLEGEN}
30 COMMAND ${CMAKE_BUILD_TOOL} -C ${CX_NATIVE_TG_DIR}/utils/TableGen
16 COMMAND ${CMAKE_BUILD_TOOL}
17 DEPENDS ${CX_NATIVE_TG_DIR}/CMakeCache.txt
18 WORKING_DIRECTORY ${CX_NATIVE_TG_DIR}/utils/TableGen
3119 COMMENT "Building native TableGen...")
3220 add_custom_target(NativeTableGen DEPENDS ${LLVM_TABLEGEN})
21
3322 add_dependencies(tblgen NativeTableGen)
3423
3524 # TODO: We should clean the native build when the `clean target
3625 # 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...")
26 # add_custom_command(TARGET clean
27 # COMMAND ${CMAKE_BUILD_TOOL} -C ${CX_NATIVE_TG_DIR}/utils/TableGen clean
28 # POST_BUILD
29 # COMMENT "Cleaning native TableGen...")
4130 endif()