Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -847,6 +847,7 @@ # when crosscompiling import the executable targets from a file if(LLVM_USE_HOST_TOOLS) include(CrossCompile) + llvm_create_cross_target(NATIVE_LLVM ${CMAKE_SOURCE_DIR} "" Release) endif(LLVM_USE_HOST_TOOLS) if(LLVM_TARGET_IS_CROSSCOMPILE_HOST) # Dummy use to avoid CMake Warning: Manually-specified variables were not used Index: cmake/modules/CrossCompile.cmake =================================================================== --- cmake/modules/CrossCompile.cmake +++ cmake/modules/CrossCompile.cmake @@ -1,6 +1,7 @@ include(LLVMExternalProjectUtils) -function(llvm_create_cross_target_internal target_name toolchain buildtype) + +function(llvm_create_cross_target target_name project_dir toolchain buildtype) if(NOT DEFINED LLVM_${target_name}_BUILD) set(LLVM_${target_name}_BUILD "${CMAKE_BINARY_DIR}/${target_name}") @@ -53,7 +54,7 @@ add_custom_command(OUTPUT ${LLVM_${target_name}_BUILD}/CMakeCache.txt COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -DCMAKE_MAKE_PROGRAM="${CMAKE_MAKE_PROGRAM}" - ${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_SOURCE_DIR} + ${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${project_dir} -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE -DLLVM_TARGETS_TO_BUILD="${targets_to_build_arg}" -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="${experimental_targets_to_build_arg}" @@ -63,42 +64,37 @@ -DLLVM_EXTERNAL_PROJECTS="${llvm_external_projects_arg}" -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN="${LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN}" ${build_type_flags} ${linker_flag} ${external_clang_dir} + ${ARGN} WORKING_DIRECTORY ${LLVM_${target_name}_BUILD} DEPENDS CREATE_LLVM_${target_name} - COMMENT "Configuring ${target_name} LLVM...") + COMMENT "Configuring ${target_name}...") add_custom_target(CONFIGURE_LLVM_${target_name} DEPENDS ${LLVM_${target_name}_BUILD}/CMakeCache.txt) endfunction() -function(llvm_create_cross_target target_name sysroot) - llvm_create_cross_target_internal(${target_name} ${sysroot} ${CMAKE_BUILD_TYPE}) -endfunction() - # Sets up a native build for a tool, used e.g. for cross-compilation and # LLVM_OPTIMIZED_TABLEGEN. Always builds in Release. # - target: The target to build natively # - output_path_var: A variable name which receives the path to the built target # - DEPENDS: Any additional dependencies for the target -function(build_native_tool target output_path_var) +function(build_native_llvm_tool target output_path_var) cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN}) if(CMAKE_CONFIGURATION_TYPES) - set(output_path "${LLVM_NATIVE_BUILD}/Release/bin/${target}") + set(output_path "${LLVM_NATIVE_LLVM_BUILD}/Release/bin/${target}") else() - set(output_path "${LLVM_NATIVE_BUILD}/bin/${target}") + set(output_path "${LLVM_NATIVE_LLVM_BUILD}/bin/${target}") endif() - llvm_ExternalProject_BuildCmd(build_cmd ${target} ${LLVM_NATIVE_BUILD} + llvm_ExternalProject_BuildCmd(build_cmd ${target} ${LLVM_NATIVE_LLVM_BUILD} CONFIGURATION Release) add_custom_command(OUTPUT "${output_path}" COMMAND ${build_cmd} - DEPENDS CONFIGURE_LLVM_NATIVE ${ARG_DEPENDS} - WORKING_DIRECTORY "${LLVM_NATIVE_BUILD}" + DEPENDS CONFIGURE_LLVM_NATIVE_LLVM ${ARG_DEPENDS} + WORKING_DIRECTORY "${LLVM_NATIVE_LLVM_BUILD}" COMMENT "Building native ${target}..." USES_TERMINAL) set(${output_path_var} "${output_path}" PARENT_SCOPE) endfunction() - -llvm_create_cross_target_internal(NATIVE "" Release) Index: cmake/modules/TableGen.cmake =================================================================== --- cmake/modules/TableGen.cmake +++ cmake/modules/TableGen.cmake @@ -125,7 +125,7 @@ if(LLVM_USE_HOST_TOOLS) if( ${${project}_TABLEGEN} STREQUAL "${target}" ) - build_native_tool(${target} ${project}_TABLEGEN_EXE) + build_native_llvm_tool(${target} ${project}_TABLEGEN_EXE) set(${project}_TABLEGEN_EXE ${${project}_TABLEGEN_EXE} PARENT_SCOPE) add_custom_target(${project}-tablegen-host DEPENDS ${${project}_TABLEGEN_EXE}) Index: tools/llvm-config/CMakeLists.txt =================================================================== --- tools/llvm-config/CMakeLists.txt +++ tools/llvm-config/CMakeLists.txt @@ -75,7 +75,7 @@ add_file_dependencies(${CMAKE_CURRENT_SOURCE_DIR}/llvm-config.cpp ${BUILDVARIABLES_OBJPATH}) if(CMAKE_CROSSCOMPILING AND NOT LLVM_CONFIG_PATH) - build_native_tool(llvm-config LLVM_CONFIG_PATH) + build_native_llvm_tool(llvm-config LLVM_CONFIG_PATH) set(LLVM_CONFIG_PATH "${LLVM_CONFIG_PATH}" CACHE STRING "") add_custom_target(NativeLLVMConfig DEPENDS ${LLVM_CONFIG_PATH}) Index: tools/llvm-shlib/CMakeLists.txt =================================================================== --- tools/llvm-shlib/CMakeLists.txt +++ tools/llvm-shlib/CMakeLists.txt @@ -168,7 +168,7 @@ set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/libllvm-c.exports) if(CMAKE_CROSSCOMPILING) - build_native_tool(llvm-nm llvm_nm) + build_native_llvm_tool(llvm-nm llvm_nm) set(llvm_nm_target "${llvm_nm}") else() set(llvm_nm $)