From b5a927b972b2c07b4597e93ed0b57803bfc0e6ae Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Tue, 23 Nov 2021 20:47:38 +0100 Subject: [PATCH] [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 --- lldb/bindings/CMakeLists.txt | 14 ++++++++++++++ lldb/bindings/python/CMakeLists.txt | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lldb/bindings/CMakeLists.txt b/lldb/bindings/CMakeLists.txt index 9759b069fdc4..c8aa0bcf9681 100644 --- a/lldb/bindings/CMakeLists.txt +++ b/lldb/bindings/CMakeLists.txt @@ -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() diff --git a/lldb/bindings/python/CMakeLists.txt b/lldb/bindings/python/CMakeLists.txt index 1f7ed18a2a0c..cecf1e0fc095 100644 --- a/lldb/bindings/python/CMakeLists.txt +++ b/lldb/bindings/python/CMakeLists.txt @@ -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).