diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake index d952ff316558..823b6dc1b979 100644 --- a/clang/cmake/modules/AddClang.cmake +++ b/clang/cmake/modules/AddClang.cmake @@ -182,7 +182,7 @@ endmacro() macro(add_clang_symlink name dest) get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS) if(LLVM_TOOL_LLVM_DRIVER_BUILD AND ${dest} IN_LIST LLVM_DRIVER_TOOLS) - set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_SYMLINKS ${name}) + set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_ALIASES_${dest} ${name}) else() llvm_add_tool_symlink(CLANG ${name} ${dest} ALWAYS_GENERATE) # Always generate install targets diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 946d66140fa3..67806e16814d 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -916,6 +916,7 @@ macro(generate_llvm_objects name) set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_OBJLIBS "${obj_name}") set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOLS ${name}) + set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_ALIASES_${name} ${name}) target_link_libraries(${obj_name} ${LLVM_PTHREAD_LIB}) llvm_config(${obj_name} ${USE_SHARED} ${LLVM_LINK_COMPONENTS} ) endif() @@ -2032,7 +2033,6 @@ endfunction() function(llvm_install_symlink project name dest) get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS) if(LLVM_TOOL_LLVM_DRIVER_BUILD AND ${dest} IN_LIST LLVM_DRIVER_TOOLS) - set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_SYMLINKS ${name}) return() endif() cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN}) @@ -2079,11 +2079,7 @@ function(llvm_add_tool_symlink project link_name target) get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS) if (${target} IN_LIST LLVM_DRIVER_TOOLS) - string(REPLACE "-" "_" tool_entry ${target}) - string(REPLACE "-" "_" key ${link_name}) - string(REPLACE "llvm-" "" tool_name ${link_name}) - set_property(GLOBAL APPEND_STRING PROPERTY - LLVM_EXTRA_DRIVER_ENTRIES "LLVM_DRIVER_TOOL(\"${tool_name}\", ${tool_entry})\n") + set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_ALIASES_${target} ${link_name}) endif() set(dest_binary "$") diff --git a/llvm/tools/llvm-driver/CMakeLists.txt b/llvm/tools/llvm-driver/CMakeLists.txt index 148e54b33b0e..e709cd7fdb56 100644 --- a/llvm/tools/llvm-driver/CMakeLists.txt +++ b/llvm/tools/llvm-driver/CMakeLists.txt @@ -5,15 +5,17 @@ get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS) foreach(tool ${LLVM_DRIVER_TOOLS}) string(REPLACE "-" "_" tool_entry ${tool}) - string(REPLACE "llvm-" "" tool ${tool}) - set(def_decl "${def_decl}LLVM_DRIVER_TOOL(\"${tool}\", ${tool_entry})\n") + get_property(tool_aliases GLOBAL PROPERTY LLVM_DRIVER_TOOL_ALIASES_${tool}) + foreach(alias ${tool_aliases}) + set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_SYMLINKS ${alias}) + string(REPLACE "llvm-" "" alias ${alias}) + set(def_decl "${def_decl}LLVM_DRIVER_TOOL(\"${alias}\", ${tool_entry})\n") + endforeach() endforeach() -get_property(LLVM_EXTRA_DRIVER_ENTRIES GLOBAL PROPERTY LLVM_EXTRA_DRIVER_ENTRIES) - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/LLVMDriverTools.def" - "${def_decl}${LLVM_EXTRA_DRIVER_ENTRIES}#undef LLVM_DRIVER_TOOL\n") + "${def_decl}#undef LLVM_DRIVER_TOOL\n") target_include_directories(llvm-driver PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_sources(llvm-driver PRIVATE llvm-driver.cpp) @@ -28,9 +30,8 @@ if(APPLE) endif(APPLE) macro(generate_driver_tool_targets) - get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS) get_property(LLVM_DRIVER_TOOL_SYMLINKS GLOBAL PROPERTY LLVM_DRIVER_TOOL_SYMLINKS) - foreach(name IN LISTS LLVM_DRIVER_TOOLS LLVM_DRIVER_TOOL_SYMLINKS) + foreach(name ${LLVM_DRIVER_TOOL_SYMLINKS}) add_llvm_tool_symlink(${name} llvm-driver ALWAYS_GENERATE) # Always generate install targets llvm_install_symlink(LLVM ${name} llvm-driver ALWAYS_GENERATE)