[llvm] 1dbb7a3 - [CMake] Fix cross-compiling with LLVM as CMake subproject
Sebastian Neubauer via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 30 07:55:13 PDT 2020
Author: Sebastian Neubauer
Date: 2020-04-30T16:54:20+02:00
New Revision: 1dbb7a3518bb7e82403d57238273283310d9e9e1
URL: https://github.com/llvm/llvm-project/commit/1dbb7a3518bb7e82403d57238273283310d9e9e1
DIFF: https://github.com/llvm/llvm-project/commit/1dbb7a3518bb7e82403d57238273283310d9e9e1.diff
LOG: [CMake] Fix cross-compiling with LLVM as CMake subproject
When embedding LLVM as a CMake subproject, using cross-compiling does
not work at the moment. This also affects -DLLVM_OPTIMIZED_TABLEGEN=1,
which uses the same CMake infrastructure.
This patch replaces global CMake variables with the current version,
which allows cross-compilation to work in a subproject.
CMAKE_BINARY_DIR -> CMAKE_CURRENT_BINARY_DIR
CMAKE_SOURCE_DIR -> CMAKE_CURRENT_SOURCE_DIR
CMAKE_PROJECT_NAME -> PROJECT_NAME
Differential Revision: https://reviews.llvm.org/D78913
Added:
Modified:
llvm/cmake/modules/CrossCompile.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/CrossCompile.cmake b/llvm/cmake/modules/CrossCompile.cmake
index 8a6e880c4e21..01cd37124841 100644
--- a/llvm/cmake/modules/CrossCompile.cmake
+++ b/llvm/cmake/modules/CrossCompile.cmake
@@ -6,7 +6,7 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)
if(NOT DEFINED ${project_name}_${target_name}_BUILD)
set(${project_name}_${target_name}_BUILD
- "${CMAKE_BINARY_DIR}/${target_name}")
+ "${CMAKE_CURRENT_BINARY_DIR}/${target_name}")
set(${project_name}_${target_name}_BUILD
${${project_name}_${target_name}_BUILD} PARENT_SCOPE)
message(STATUS "Setting native build dir to " ${${project_name}_${target_name}_BUILD})
@@ -68,7 +68,7 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)
add_custom_command(OUTPUT ${${project_name}_${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}} ${CMAKE_CURRENT_SOURCE_DIR}
${CROSS_TOOLCHAIN_FLAGS_${project_name}_${target_name}}
-DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
-DLLVM_TARGETS_TO_BUILD="${targets_to_build_arg}"
@@ -99,17 +99,17 @@ function(build_native_tool target output_path_var)
cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
if(CMAKE_CONFIGURATION_TYPES)
- set(output_path "${${CMAKE_PROJECT_NAME}_NATIVE_BUILD}/Release/bin/${target}")
+ set(output_path "${${PROJECT_NAME}_NATIVE_BUILD}/Release/bin/${target}")
else()
- set(output_path "${${CMAKE_PROJECT_NAME}_NATIVE_BUILD}/bin/${target}")
+ set(output_path "${${PROJECT_NAME}_NATIVE_BUILD}/bin/${target}")
endif()
- llvm_ExternalProject_BuildCmd(build_cmd ${target} ${${CMAKE_PROJECT_NAME}_NATIVE_BUILD}
+ llvm_ExternalProject_BuildCmd(build_cmd ${target} ${${PROJECT_NAME}_NATIVE_BUILD}
CONFIGURATION Release)
add_custom_command(OUTPUT "${output_path}"
COMMAND ${build_cmd}
- DEPENDS CONFIGURE_${CMAKE_PROJECT_NAME}_NATIVE ${ARG_DEPENDS}
- WORKING_DIRECTORY "${${CMAKE_PROJECT_NAME}_NATIVE_BUILD}"
+ DEPENDS CONFIGURE_${PROJECT_NAME}_NATIVE ${ARG_DEPENDS}
+ WORKING_DIRECTORY "${${PROJECT_NAME}_NATIVE_BUILD}"
COMMENT "Building native ${target}..."
USES_TERMINAL)
set(${output_path_var} "${output_path}" PARENT_SCOPE)
More information about the llvm-commits
mailing list