[PATCH] D78913: [CMake] Fix cross-compiling with LLVM as CMake subproject
Sebastian Neubauer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 27 04:15:21 PDT 2020
Flakebi created this revision.
Flakebi added reviewers: chandlerc, stoklund, nhaehnle, tpr, dstuttard.
Herald added subscribers: llvm-commits, mgorny.
Herald added a project: LLVM.
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
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D78913
Files:
llvm/cmake/modules/CrossCompile.cmake
Index: llvm/cmake/modules/CrossCompile.cmake
===================================================================
--- llvm/cmake/modules/CrossCompile.cmake
+++ llvm/cmake/modules/CrossCompile.cmake
@@ -6,7 +6,7 @@
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 @@
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 @@
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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78913.260270.patch
Type: text/x-patch
Size: 2375 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200427/ea9cf285/attachment.bin>
More information about the llvm-commits
mailing list