CMake: Fixed cross-compiling.
[opencl/llvm.git] / cmake / modules / CrossCompileLLVM.cmake
1 \r
2 if( ${LLVM_TABLEGEN} STREQUAL "tblgen" )\r
3   set(CX_NATIVE_TG_DIR "${CMAKE_BINARY_DIR}/native")\r
4   set(LLVM_TABLEGEN "${CX_NATIVE_TG_DIR}/bin/tblgen")\r
5 \r
6   add_custom_command(OUTPUT ${CX_NATIVE_TG_DIR}\r
7     COMMAND ${CMAKE_COMMAND} -E make_directory ${CX_NATIVE_TG_DIR}\r
8     COMMENT "Creating ${CX_NATIVE_TG_DIR}...")\r
9 \r
10   add_custom_command(OUTPUT ${CX_NATIVE_TG_DIR}/CMakeCache.txt\r
11     COMMAND ${CMAKE_COMMAND} -UMAKE_TOOLCHAIN_FILE -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR}\r
12     WORKING_DIRECTORY ${CX_NATIVE_TG_DIR}\r
13     DEPENDS ${CX_NATIVE_TG_DIR}\r
14     COMMENT "Configuring native TableGen...")\r
15 \r
16   add_custom_command(OUTPUT ${LLVM_TABLEGEN}\r
17     COMMAND ${CMAKE_BUILD_TOOL}\r
18     DEPENDS ${CX_NATIVE_TG_DIR}/CMakeCache.txt\r
19     WORKING_DIRECTORY ${CX_NATIVE_TG_DIR}/utils/TableGen\r
20     COMMENT "Building native TableGen...")\r
21   add_custom_target(NativeTableGen DEPENDS ${LLVM_TABLEGEN})\r
22 \r
23   add_dependencies(tblgen NativeTableGen)\r
24 \r
25   set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CX_NATIVE_TG_DIR})\r
26 endif()\r