Skip to content

Commit 68c609b

Browse files
authored
[libclc] Fix libclc install on Windows when MSVC generator is used (llvm#152703)
Fix a regression of df74736. 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
1 parent acb86fb commit 68c609b

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,33 @@ function(get_libclc_device_info)
199199
endif()
200200
endfunction()
201201

202+
# Install libclc artifacts.
203+
#
204+
# Arguments:
205+
# * FILES <string> ...
206+
# List of libclc artifact files to be installed.
207+
function(libclc_install)
208+
cmake_parse_arguments(ARG "" "" "FILES" ${ARGN})
209+
210+
if( NOT ARG_FILES )
211+
message( FATAL_ERROR "Must provide FILES" )
212+
endif()
213+
214+
if( NOT CMAKE_CFG_INTDIR STREQUAL "." )
215+
# Replace CMAKE_CFG_INTDIR with CMAKE_INSTALL_CONFIG_NAME for multiple-
216+
# configuration generators.
217+
string( REPLACE ${CMAKE_CFG_INTDIR} "\$\{CMAKE_INSTALL_CONFIG_NAME\}"
218+
files ${ARG_FILES} )
219+
else()
220+
set( files ${ARG_FILES} )
221+
endif()
222+
223+
install(
224+
FILES ${files}
225+
DESTINATION "${CMAKE_INSTALL_DATADIR}/clc"
226+
)
227+
endfunction()
228+
202229
# Compiles a list of library source files (provided by LIB_FILES/GEN_FILES) and
203230
# compiles them to LLVM bytecode (or SPIR-V), links them together and optimizes
204231
# them.
@@ -425,10 +452,7 @@ function(add_libclc_builtin_set)
425452
# targets dependent on libclc.
426453
add_dependencies( ${ARG_PARENT_TARGET} prepare-${ARG_TRIPLE} )
427454

428-
install(
429-
FILES ${libclc_builtins_lib}
430-
DESTINATION "${CMAKE_INSTALL_DATADIR}/clc"
431-
)
455+
libclc_install(FILES ${libclc_builtins_lib})
432456

433457
# SPIR-V targets can exit early here
434458
if( ARG_ARCH STREQUAL spirv OR ARG_ARCH STREQUAL spirv64 )
@@ -470,10 +494,7 @@ function(add_libclc_builtin_set)
470494
set_target_properties( alias-${alias_suffix}
471495
PROPERTIES FOLDER "libclc/Device IR/Aliases"
472496
)
473-
install(
474-
FILES ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix}
475-
DESTINATION "${CMAKE_INSTALL_DATADIR}/clc"
476-
)
497+
libclc_install(FILES ${LIBCLC_OUTPUT_LIBRARY_DIR}/${alias_suffix})
477498
endforeach( a )
478499
endfunction(add_libclc_builtin_set)
479500

0 commit comments

Comments
 (0)