[lldb] Move create_relative_symlink function up in CMake hierarchy

Configuring lldb with `LLDB_ENABLE_PYTHON=OFF` and `LLDB_ENABLE_LUA=ON` results in a CMake error:

    CMake Error at lldb/bindings/lua/CMakeLists.txt:47 (create_relative_symlink):
      Unknown CMake command "create_relative_symlink".
    Call Stack (most recent call first):
      lldb/CMakeLists.txt:117 (finish_swig_lua)

This is because the CMake function `create_relative_symlink` only exists in `lldb/bindings/python/CMakeLists.txt`, and not in `lldb/bindings/lua/CMakeLists.txt`.

Move the function to `lldb/bindings/CMakeLists.txt`, so it is available for all language bindings.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D114465
This commit is contained in:
Dimitry Andric 2021-11-23 20:47:38 +01:00
parent b80affb8a1
commit b5a927b972
2 changed files with 14 additions and 14 deletions

View File

@ -31,6 +31,20 @@ set(SWIG_COMMON_FLAGS
${DARWIN_EXTRAS}
)
function(create_relative_symlink swig_target dest_file output_dir output_name)
get_filename_component(dest_file ${dest_file} ABSOLUTE)
get_filename_component(output_dir ${output_dir} ABSOLUTE)
file(RELATIVE_PATH rel_dest_file ${output_dir} ${dest_file})
if(CMAKE_HOST_UNIX)
set(LLVM_LINK_OR_COPY create_symlink)
else()
set(LLVM_LINK_OR_COPY copy)
endif()
add_custom_command(TARGET ${swig_target} POST_BUILD VERBATIM
COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} ${rel_dest_file} ${output_name}
WORKING_DIRECTORY ${output_dir})
endfunction()
if (LLDB_ENABLE_PYTHON)
add_subdirectory(python)
endif()

View File

@ -52,20 +52,6 @@ function(create_python_package swig_target working_dir pkg_dir)
WORKING_DIRECTORY ${working_dir})
endfunction()
function(create_relative_symlink swig_target dest_file output_dir output_name)
get_filename_component(dest_file ${dest_file} ABSOLUTE)
get_filename_component(output_dir ${output_dir} ABSOLUTE)
file(RELATIVE_PATH rel_dest_file ${output_dir} ${dest_file})
if(CMAKE_HOST_UNIX)
set(LLVM_LINK_OR_COPY create_symlink)
else()
set(LLVM_LINK_OR_COPY copy)
endif()
add_custom_command(TARGET ${swig_target} POST_BUILD VERBATIM
COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} ${rel_dest_file} ${output_name}
WORKING_DIRECTORY ${output_dir})
endfunction()
function(finish_swig_python swig_target lldb_python_bindings_dir lldb_python_target_dir)
# Add a Post-Build Event to copy over Python files and create the symlink to
# liblldb.so for the Python API(hardlink on Windows).