Author: Wenju He Date: 2025-08-11T18:05:42+08:00 New Revision: 68c609b6c80561488dc7e820e5f826741639e3ca
URL: https://github.com/llvm/llvm-project/commit/68c609b6c80561488dc7e820e5f826741639e3ca DIFF: https://github.com/llvm/llvm-project/commit/68c609b6c80561488dc7e820e5f826741639e3ca.diff LOG: [libclc] Fix libclc install on Windows when MSVC generator is used (#152703) Fix a regression of df7473673214. cmake MSVC generator is multiple configurations. Build type is not known at configure time and CMAKE_CFG_INTDIR is evaluated to $(Configuration) at configure time. libclc install fails since $(Configuration) in bitcode file path is unresolved in libclc/cmake_install.cmake at install time. We need a solution that resolves libclc bitcode file path at install time. This PR fixes the issue using CMAKE_INSTALL_CONFIG_NAME which can be evaluated at install time. This is the same solution as in https://reviews.llvm.org/D76827 Added: Modified: libclc/cmake/modules/AddLibclc.cmake Removed: ################################################################################ diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 91d49610eee01..89d5e1dd6f164 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -199,6 +199,33 @@ function(get_libclc_device_info) endif() endfunction() +# Install libclc artifacts. +# +# Arguments: +# * FILES <string> ... +# List of libclc artifact files to be installed. +function(libclc_install) + cmake_parse_arguments(ARG "" "" "FILES" ${ARGN}) + + if( NOT ARG_FILES ) + message( FATAL_ERROR "Must provide FILES" ) + endif() + + if( NOT CMAKE_CFG_INTDIR STREQUAL "." ) + # Replace CMAKE_CFG_INTDIR with CMAKE_INSTALL_CONFIG_NAME for multiple- + # configuration generators. + string( REPLACE ${CMAKE_CFG_INTDIR} "\$\{CMAKE_INSTALL_CONFIG_NAME\}" + files ${ARG_FILES} ) + else() + set( files ${ARG_FILES} ) + endif() + + install( + FILES ${files} + DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" + ) +endfunction() + # Compiles a list of library source files (provided by LIB_FILES/GEN_FILES) and # compiles them to LLVM bytecode (or SPIR-V), links them together and optimizes # them. @@ -425,10 +452,7 @@ function(add_libclc_builtin_set) # targets dependent on libclc. add_dependencies( ${ARG_PARENT_TARGET} prepare-${ARG_TRIPLE} ) - install( - FILES ${libclc_builtins_lib} - DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" - ) + libclc_install(FILES ${libclc_builtins_lib}) # SPIR-V targets can exit early here if( ARG_ARCH STREQUAL spirv OR ARG_ARCH STREQUAL spirv64 ) @@ -470,10 +494,7 @@ function(add_libclc_builtin_set) set_target_properties( alias-${alias_suffix} PROPERTIES FOLDER "libclc/Device IR/Aliases" ) - install( - FILES ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix} - DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" - ) + libclc_install(FILES ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix}) endforeach( a ) endfunction(add_libclc_builtin_set) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits