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
This commit is contained in:
Oscar Fuentes 2008-11-09 18:53:19 +00:00
parent 22b91d7fc4
commit 3ab40ca3d5
6 changed files with 26 additions and 5 deletions

View File

@ -111,10 +111,17 @@ add_subdirectory(lib/System)
# Everything else depends on Support and System: # Everything else depends on Support and System:
set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${LLVM_LIBS} ) set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${LLVM_LIBS} )
set(LLVM_TABLEGEN "tblgen" CACHE
STRING "Native TableGen executable.")
if( CMAKE_CROSSCOMPILING )
include( CrossCompileLLVM )
endif( CMAKE_CROSSCOMPILING )
add_subdirectory(utils/TableGen) add_subdirectory(utils/TableGen)
add_custom_command(OUTPUT ${llvm_builded_incs_dir}/Intrinsics.gen add_custom_command(OUTPUT ${llvm_builded_incs_dir}/Intrinsics.gen
COMMAND tblgen -gen-intrinsic -I ${LLVM_MAIN_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR}/llvm/Intrinsics.td -o ${llvm_builded_incs_dir}/Intrinsics.gen COMMAND ${LLVM_TABLEGEN} -gen-intrinsic -I ${LLVM_MAIN_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR}/llvm/Intrinsics.td -o ${llvm_builded_incs_dir}/Intrinsics.gen
DEPENDS tblgen DEPENDS tblgen
COMMENT "Building intrinsics.gen...") COMMENT "Building intrinsics.gen...")

View File

@ -24,7 +24,7 @@ macro(add_partially_linked_object lib)
DEPENDS ${lib} DEPENDS ${lib}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp_lib WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp_lib
COMMAND ar x ${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX} COMMAND ar x ${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}
COMMAND ld "${LLVM_PLO_FLAGS}" -r "*${CMAKE_CXX_OUTPUT_EXTENSION}" -o ${pll} COMMAND ${CMAKE_LINKER} "${LLVM_PLO_FLAGS}" -r "*${CMAKE_CXX_OUTPUT_EXTENSION}" -o ${pll}
COMMAND rm -f *${CMAKE_CXX_OUTPUT_EXTENSION} COMMAND rm -f *${CMAKE_CXX_OUTPUT_EXTENSION}
) )
target_name_of_partially_linked_object(${lib} tnplo) target_name_of_partially_linked_object(${lib} tnplo)

View File

@ -0,0 +1,6 @@
# TODO: Build a native tblgen when cross-compiling, if the user
# didn't set LLVM_TABLEGEN. Then, remove this check:
if( CMAKE_CROSSCOMPILING AND ${LLVM_TABLEGEN} STREQUAL "tblgen" )
message(FATAL_ERROR
"Set LLVM_TABLEGEN to the full route to a native tblgen executable")
endif()

View File

@ -4,7 +4,7 @@
macro(tablegen ofn) macro(tablegen ofn)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn} add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
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} 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}
DEPENDS tblgen ${CMAKE_CURRENT_SOURCE_DIR}/${LLVM_TARGET_DEFINITIONS} DEPENDS tblgen ${CMAKE_CURRENT_SOURCE_DIR}/${LLVM_TARGET_DEFINITIONS}
COMMENT "Building ${ofn}..." COMMENT "Building ${ofn}..."
) )

View File

@ -63,8 +63,16 @@ set(LLVM_CONFIG_IN ${CMAKE_CURRENT_BINARY_DIR}/llvm-config.in)
# set(LIBDEPS_TMP LibDeps.txt.tmp) # set(LIBDEPS_TMP LibDeps.txt.tmp)
# set(FINAL_LIBDEPS FinalLibDeps.txt) # set(FINAL_LIBDEPS FinalLibDeps.txt)
if( CMAKE_CROSSCOMPILING )
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
endif()
if( NOT NM_PATH )
message(FATAL_ERROR "`nm' was not found")
endif()
add_custom_command(OUTPUT ${LIBDEPS_TMP} add_custom_command(OUTPUT ${LIBDEPS_TMP}
COMMAND ${PERL_EXECUTABLE} ${LLVM_MAIN_SRC_DIR}/utils/GenLibDeps.pl -flat ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} > ${LIBDEPS_TMP} COMMAND ${PERL_EXECUTABLE} ${LLVM_MAIN_SRC_DIR}/utils/GenLibDeps.pl -flat ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} ${NM_PATH} > ${LIBDEPS_TMP}
COMMENT "Regenerating ${LIBDEPS_TMP}") COMMENT "Regenerating ${LIBDEPS_TMP}")
add_custom_command(OUTPUT ${LIBDEPS} add_custom_command(OUTPUT ${LIBDEPS}

View File

@ -3,7 +3,7 @@ set(LLVM_REQUIRES_EH 1)
macro(tgen ofn) macro(tgen ofn)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn} add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
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} 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}
DEPENDS DEPENDS
tblgen tblgen
${LLVM_MAIN_INCLUDE_DIR}/llvm/CompilerDriver/Common.td ${LLVM_MAIN_INCLUDE_DIR}/llvm/CompilerDriver/Common.td