mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[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
This commit is contained in:
parent
1fc62e740a
commit
138b7b6167
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user