llvm.org GIT mirror llvm / 3ab40ca
CMake: Support for cross-compiling. For now, requires a previously built native tblgen which is passed to cmake in the variable LLVM_TABLEGEN. See http://www.cmake.org/Wiki/CmakeMingw for a quick example on how to cross-compile with CMake. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58939 91177308-0d34-0410-b5e6-96231b3b80d8 Oscar Fuentes 10 years ago
6 changed file(s) with 26 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
110110 # Everything else depends on Support and System:
111111 set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${LLVM_LIBS} )
112112
113 set(LLVM_TABLEGEN "tblgen" CACHE
114 STRING "Native TableGen executable.")
115
116 if( CMAKE_CROSSCOMPILING )
117 include( CrossCompileLLVM )
118 endif( CMAKE_CROSSCOMPILING )
119
113120 add_subdirectory(utils/TableGen)
114121
115122 add_custom_command(OUTPUT ${llvm_builded_incs_dir}/Intrinsics.gen
116 COMMAND tblgen -gen-intrinsic -I ${LLVM_MAIN_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR}/llvm/Intrinsics.td -o ${llvm_builded_incs_dir}/Intrinsics.gen
123 COMMAND ${LLVM_TABLEGEN} -gen-intrinsic -I ${LLVM_MAIN_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR}/llvm/Intrinsics.td -o ${llvm_builded_incs_dir}/Intrinsics.gen
117124 DEPENDS tblgen
118125 COMMENT "Building intrinsics.gen...")
119126
2323 DEPENDS ${lib}
2424 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp_lib
2525 COMMAND ar x ${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}
26 COMMAND ld "${LLVM_PLO_FLAGS}" -r "*${CMAKE_CXX_OUTPUT_EXTENSION}" -o ${pll}
26 COMMAND ${CMAKE_LINKER} "${LLVM_PLO_FLAGS}" -r "*${CMAKE_CXX_OUTPUT_EXTENSION}" -o ${pll}
2727 COMMAND rm -f *${CMAKE_CXX_OUTPUT_EXTENSION}
2828 )
2929 target_name_of_partially_linked_object(${lib} tnplo)
0 # 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" )
3 message(FATAL_ERROR
4 "Set LLVM_TABLEGEN to the full route to a native tblgen executable")
5 endif()
33
44 macro(tablegen ofn)
55 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
6 COMMAND tblgen ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR} -I ${CMAKE_SOURCE_DIR}/lib/Target -I ${LLVM_MAIN_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${LLVM_TARGET_DEFINITIONS} -o ${ofn}
6 COMMAND ${LLVM_TABLEGEN} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR} -I ${CMAKE_SOURCE_DIR}/lib/Target -I ${LLVM_MAIN_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${LLVM_TARGET_DEFINITIONS} -o ${ofn}
77 DEPENDS tblgen ${CMAKE_CURRENT_SOURCE_DIR}/${LLVM_TARGET_DEFINITIONS}
88 COMMENT "Building ${ofn}..."
99 )
6262 # set(LIBDEPS_TMP LibDeps.txt.tmp)
6363 # set(FINAL_LIBDEPS FinalLibDeps.txt)
6464
65 if( CMAKE_CROSSCOMPILING )
66 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
67 endif()
68
69 if( NOT NM_PATH )
70 message(FATAL_ERROR "`nm' was not found")
71 endif()
72
6573 add_custom_command(OUTPUT ${LIBDEPS_TMP}
66 COMMAND ${PERL_EXECUTABLE} ${LLVM_MAIN_SRC_DIR}/utils/GenLibDeps.pl -flat ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} > ${LIBDEPS_TMP}
74 COMMAND ${PERL_EXECUTABLE} ${LLVM_MAIN_SRC_DIR}/utils/GenLibDeps.pl -flat ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} ${NM_PATH} > ${LIBDEPS_TMP}
6775 COMMENT "Regenerating ${LIBDEPS_TMP}")
6876
6977 add_custom_command(OUTPUT ${LIBDEPS}
22
33 macro(tgen ofn)
44 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
5 COMMAND tblgen ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR} -I ${CMAKE_SOURCE_DIR}/lib/Target -I ${LLVM_MAIN_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Graph.td -o ${ofn}
5 COMMAND ${LLVM_TABLEGEN} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR} -I ${CMAKE_SOURCE_DIR}/lib/Target -I ${LLVM_MAIN_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Graph.td -o ${ofn}
66 DEPENDS
77 tblgen
88 ${LLVM_MAIN_INCLUDE_DIR}/llvm/CompilerDriver/Common.td