|
| 1 | +#=========================== begin_copyright_notice ============================ |
| 2 | +# |
| 3 | +# Copyright (c) 2021 Intel Corporation |
| 4 | +# |
| 5 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | +# of this software and associated documentation files (the "Software"), |
| 7 | +# to deal in the Software without restriction, including without limitation |
| 8 | +# the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | +# and/or sell copies of the Software, and to permit persons to whom |
| 10 | +# the Software is furnished to do so, subject to the following conditions: |
| 11 | +# |
| 12 | +# The above copyright notice and this permission notice shall be included |
| 13 | +# in all copies or substantial portions of the Software. |
| 14 | +# |
| 15 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 21 | +# IN THE SOFTWARE. |
| 22 | +# |
| 23 | +#============================ end_copyright_notice ============================= |
| 24 | + |
| 25 | +set(BACKEND_PLUGIN_SOURCES |
| 26 | + BackendPlugin.cpp |
| 27 | + ) |
| 28 | + |
| 29 | +add_library(VCBackendPlugin |
| 30 | + MODULE |
| 31 | + ${BACKEND_PLUGIN_SOURCES} |
| 32 | + ) |
| 33 | + |
| 34 | +# Hack to avoid transitive LLVM dependencies that will break |
| 35 | +# plugin because of duplicate global variables. |
| 36 | +# 'CODEGEN_LIBS' will consist of 'VCCodeGen' and all its direct dependencies. |
| 37 | +# This should be enough for now. In case of indirect dependencies on VectorCompiler |
| 38 | +# libraries, searching algorithm needs to be improved. |
| 39 | +# 'CODEGEN_LIBS_FILES' will be expanded to plain library names so cmake |
| 40 | +# will not add any transitive dependencies when target is linked against them. |
| 41 | +get_target_property(CODEGEN_LIBS VCCodeGen LINK_LIBRARIES) |
| 42 | +set(CODEGEN_LIBS VCCodeGen ${CODEGEN_LIBS}) |
| 43 | +foreach(target ${CODEGEN_LIBS}) |
| 44 | + # Filter out interface libraries -- these will not produce any files. |
| 45 | + set(tgt_type "$<TARGET_PROPERTY:${target},TYPE>") |
| 46 | + set(is_iface "$<STREQUAL:${tgt_type},INTERFACE_LIBRARY>") |
| 47 | + set(not_iface "$<NOT:${is_iface}>") |
| 48 | + |
| 49 | + set(tgt_file "$<TARGET_FILE:${target}>") |
| 50 | + set(whole_gen "$<${not_iface}:${tgt_file}>") |
| 51 | + list(APPEND CODEGEN_LIBS_FILES ${whole_gen}) |
| 52 | +endforeach() |
| 53 | + |
| 54 | +# Cmake also does not add any dependencies for libraries |
| 55 | +# that are linked this way. |
| 56 | +add_dependencies(VCBackendPlugin |
| 57 | + ${CODEGEN_LIBS} |
| 58 | + ) |
| 59 | + |
| 60 | +target_link_libraries(VCBackendPlugin |
| 61 | + PRIVATE |
| 62 | + VCHeaders |
| 63 | + ${CODEGEN_LIBS_FILES} |
| 64 | + # GenX_IR actually should be linked to LLVMGenXCodeGen. |
| 65 | + GenX_IR |
| 66 | + ) |
0 commit comments