diff options
Diffstat (limited to 'llvm/cmake/modules/AddLLVM.cmake')
-rw-r--r-- | llvm/cmake/modules/AddLLVM.cmake | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 75e0f10d68a..fce36ba2125 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -847,32 +847,40 @@ macro(add_llvm_executable name) llvm_codesign(${name} ENTITLEMENTS ${ARG_ENTITLEMENTS} BUNDLE_PATH ${ARG_BUNDLE_PATH}) endmacro(add_llvm_executable name) -# add_llvm_pass_plugin(name) +# add_llvm_pass_plugin(name [NO_MODULE] ...) # Add ${name} as an llvm plugin. # If option LLVM_${name_upper}_LINK_INTO_TOOLS is set to ON, the plugin is registered statically. # Otherwise a pluggable shared library is registered. +# +# If NO_MODULE is specified, when option LLVM_${name_upper}_LINK_INTO_TOOLS is set to OFF, +# only an object library is built, and no module is built. This is specific to the Polly use case. function(add_llvm_pass_plugin name) + cmake_parse_arguments(ARG + "NO_MODULE" "" "" + ${ARGN}) string(TOUPPER ${name} name_upper) option(LLVM_${name_upper}_LINK_INTO_TOOLS "Statically link ${name} into tools (if available)" OFF) - # process_llvm_pass_plugins takes care of the actual linking, just create an - # object library as of now - add_llvm_library(${name} OBJECT ${ARGN}) - - if(LLVM_${name_upper}_LINK_INTO_TOOLS) - target_compile_definitions(${name} PRIVATE LLVM_${name_upper}_LINK_INTO_TOOLS) - set_property(TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS LLVM_LINK_INTO_TOOLS) - if (TARGET intrinsics_gen) - add_dependencies(obj.${name} intrinsics_gen) - endif() - endif() - - message(STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper}_LINK_INTO_TOOLS})") if(LLVM_${name_upper}_LINK_INTO_TOOLS) + list(REMOVE_ITEM ARG_UNPARSED_ARGUMENTS BUILDTREE_ONLY) + # process_llvm_pass_plugins takes care of the actual linking, just create an + # object library as of now + add_llvm_library(${name} OBJECT ${ARG_UNPARSED_ARGUMENTS}) + target_compile_definitions(${name} PRIVATE LLVM_${name_upper}_LINK_INTO_TOOLS) + set_property(TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS LLVM_LINK_INTO_TOOLS) + if (TARGET intrinsics_gen) + add_dependencies(obj.${name} intrinsics_gen) + endif() + message(STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper}_LINK_INTO_TOOLS})") set_property(GLOBAL APPEND PROPERTY LLVM_COMPILE_EXTENSIONS ${name}) + elseif(NOT ARG_NO_MODULE) + add_llvm_library(${name} MODULE ${ARG_UNPARSED_ARGUMENTS}) + else() + add_llvm_library(${name} OBJECT ${ARG_UNPARSED_ARGUMENTS}) endif() + endfunction(add_llvm_pass_plugin) # Generate X Macro file for extension handling. It provides a |