ladybird/Meta/Lagom/ClangPlugins/CMakeLists.txt
Andrew Kaster 12dd5f0804 CMake: Include utils from places that were implicitly dependent on it
These files use functions that are declared in utils.cmake, but were
relying on implicit inclusion from other files.
2025-07-07 09:10:05 +02:00

38 lines
1.8 KiB
CMake

include(clang_development)
include(utils)
function(clang_plugin target_name)
cmake_parse_arguments(CLANG_PLUGIN "" "" "SOURCES" ${ARGN})
add_library(${target_name} ${CLANG_PLUGIN_SOURCES})
target_include_directories(${target_name} SYSTEM PRIVATE ${CLANG_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS})
target_compile_features(${target_name} PRIVATE cxx_std_20)
target_compile_options(${target_name} PRIVATE -Wall -Wextra -Werror -Wno-unused -fno-rtti)
# Building these with fuzzers would require building the compiler with fuzzers, which feels out of scope
target_compile_options(${target_name} PRIVATE -fno-sanitize=all)
target_link_options(${target_name} PRIVATE -fno-sanitize=all)
add_custom_target(${target_name}Target DEPENDS ${target_name})
set_property(GLOBAL APPEND PROPERTY CLANG_PLUGINS_COMPILE_OPTIONS_FOR_TESTS -fplugin=${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/lib${target_name}.so)
add_lagom_library_install_rules(${target_name})
if (NOT WIN32 AND NOT APPLE)
target_link_options(${target_name} PRIVATE LINKER:-z,undefs)
target_link_options(${target_name} PRIVATE LINKER:--allow-shlib-undefined)
endif()
endfunction()
function(depend_on_clang_plugin target_name plugin_name)
if (TARGET ${plugin_name}Target)
add_dependencies(${target_name} ${plugin_name}Target)
endif()
target_compile_options(${target_name} INTERFACE -fplugin=$<TARGET_FILE:Lagom::${plugin_name}>)
if (${ENABLE_CLANG_PLUGINS_INVALID_FUNCTION_MEMBERS})
target_compile_options(${target_name} INTERFACE -fplugin-arg-libjs_gc_scanner-detect-invalid-function-members)
endif()
endfunction()
clang_plugin(LambdaCaptureClangPlugin SOURCES LambdaCapturePluginAction.cpp)
clang_plugin(LibJSGCClangPlugin SOURCES LibJSGCPluginAction.cpp)