llvm-capstone/lldb/bindings/CMakeLists.txt
Alex Langford 662548c826 [lldb] Replace SB swig interfaces with API headers
Instead of maintaining separate swig interface files, we can use the API
headers directly. They implement the exact same C++ APIs and we can
conditionally include the python extensions as needed. To remove the
swig extensions from the API headers when building the LLDB
framework, we can use the unifdef tool when it is available. Otherwise
we just copy them as-is.

Differential Revision: https://reviews.llvm.org/D142926
2023-02-16 11:18:04 -08:00

54 lines
1.4 KiB
CMake

file(GLOB SWIG_INTERFACES interface/*.i)
file(GLOB_RECURSE SWIG_SOURCES *.swig)
file(GLOB SWIG_HEADERS
${LLDB_SOURCE_DIR}/include/lldb/API/*.h
${LLDB_SOURCE_DIR}/include/lldb/*.h
)
file(GLOB SWIG_PRIVATE_HEADERS
${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h
)
foreach(private_header ${SWIG_PRIVATE_HEADERS})
list(REMOVE_ITEM SWIG_HEADERS ${private_header})
endforeach()
if(LLDB_BUILD_FRAMEWORK)
set(framework_arg --framework --target-platform Darwin)
endif()
if(APPLE)
set(DARWIN_EXTRAS "-D__APPLE__")
else()
set(DARWIN_EXTRAS "")
endif()
set(SWIG_COMMON_FLAGS
-c++
-w361,362 # Ignore warnings about ignored operator overloads
-features autodoc
-I${LLDB_SOURCE_DIR}/include
-I${CMAKE_CURRENT_SOURCE_DIR}
${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()
if (LLDB_ENABLE_LUA)
add_subdirectory(lua)
endif()