diff options
author | Oscar Fuentes <ofv@wanadoo.es> | 2008-11-10 02:35:55 +0000 |
---|---|---|
committer | Oscar Fuentes <ofv@wanadoo.es> | 2008-11-10 02:35:55 +0000 |
commit | c9a325949880b1209d3b6041932875b32d1803ae (patch) | |
tree | a4ad984039399e557277603ed32cf278ac8b38a5 | |
parent | b0ebcb43e367a797d056e1450bf0171aa0c4763f (diff) | |
download | external_llvm-c9a325949880b1209d3b6041932875b32d1803ae.zip external_llvm-c9a325949880b1209d3b6041932875b32d1803ae.tar.gz external_llvm-c9a325949880b1209d3b6041932875b32d1803ae.tar.bz2 |
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
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | cmake/modules/CrossCompileLLVM.cmake | 43 |
2 files changed, 17 insertions, 28 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f477ad..15dcf7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,7 +139,7 @@ add_subdirectory(lib/System) set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${LLVM_LIBS} ) set(LLVM_TABLEGEN "tblgen" CACHE - STRING "Native TableGen executable.") + STRING "Native TableGen executable. Saves building one when cross-compiling.") add_subdirectory(utils/TableGen) diff --git a/cmake/modules/CrossCompileLLVM.cmake b/cmake/modules/CrossCompileLLVM.cmake index 36ae306..1c00f39 100644 --- a/cmake/modules/CrossCompileLLVM.cmake +++ b/cmake/modules/CrossCompileLLVM.cmake @@ -1,42 +1,31 @@ if( ${LLVM_TABLEGEN} STREQUAL "tblgen" )
- # TODO: remove this when autobuilding the native tblgen works.
- message(FATAL_ERROR
- "Set LLVM_TABLEGEN to the full route to a native tblgen executable")
-
- message(STATUS "Configuring native TableGen...")
- set(CX_NATIVE_TG_DIR "${CMAKE_BINARY_DIR}/native")
+ set(LLVM_TABLEGEN "${CX_NATIVE_TG_DIR}/bin/tblgen")
- execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CX_NATIVE_TG_DIR}
- RESULT_VARIABLE CX_NATIVE_TG_RV)
- if( NOT CX_NATIVE_TG_RV EQUAL 0 )
- message(FATAL_ERROR "Failed to create directory ${CX_NATIVE_TG_DIR}")
- endif()
+ message(STATUS "CX_NATIVE_TG_DIR : ${CX_NATIVE_TG_DIR}")
+ add_custom_command(OUTPUT ${CX_NATIVE_TG_DIR}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CX_NATIVE_TG_DIR}
+ COMMENT "Creating ${CX_NATIVE_TG_DIR}...")
- execute_process(
+ add_custom_command(OUTPUT ${CX_NATIVE_TG_DIR}/CMakeCache.txt
COMMAND ${CMAKE_COMMAND} -UMAKE_TOOLCHAIN_FILE -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${CX_NATIVE_TG_DIR}
- RESULT_VARIABLE CX_NATIVE_TG_RV
- ERROR_VARIABLE CX_NATIVE_TG_ERROR)
- if( NOT CX_NATIVE_TG_RV EQUAL 0 )
- message(FATAL_ERROR
- "Error while configuring native TableGen:\n${CX_NATIVE_TG_ERROR}")
- endif()
-
- message(STATUS "Native TableGen configured.")
-
- set(LLVM_TABLEGEN "${CX_NATIVE_TG_DIR}/bin/tblgen")
+ DEPENDS ${CX_NATIVE_TG_DIR}
+ COMMENT "Configuring native TableGen...")
add_custom_command(OUTPUT ${LLVM_TABLEGEN}
- COMMAND ${CMAKE_BUILD_TOOL} -C ${CX_NATIVE_TG_DIR}/utils/TableGen
+ COMMAND ${CMAKE_BUILD_TOOL}
+ DEPENDS ${CX_NATIVE_TG_DIR}/CMakeCache.txt
+ WORKING_DIRECTORY ${CX_NATIVE_TG_DIR}/utils/TableGen
COMMENT "Building native TableGen...")
add_custom_target(NativeTableGen DEPENDS ${LLVM_TABLEGEN})
+
add_dependencies(tblgen NativeTableGen)
# TODO: We should clean the native build when the `clean target
# is invoked. This doesn't work.
-# add_custom_command(TARGET clean
-# COMMAND ${CMAKE_BUILD_TOOL} -C ${CX_NATIVE_TG_DIR}/utils/TableGen clean
-# POST_BUILD
-# COMMENT "Cleaning native TableGen...")
+ # add_custom_command(TARGET clean
+ # COMMAND ${CMAKE_BUILD_TOOL} -C ${CX_NATIVE_TG_DIR}/utils/TableGen clean
+ # POST_BUILD
+ # COMMENT "Cleaning native TableGen...")
endif()
|