Skip to content

Commit 9ccd37f

Browse files
committed
feat: automatically install runtimes for vcpkg
1 parent 6b6dee4 commit 9ccd37f

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

cspell.config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ words:
7777
- libc
7878
- libcuda
7979
- libg
80+
- libm
8081
- libstdc
8182
- LPSTR
8283
- LPWSTR

src/PackageProject.cmake

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ function(package_project)
134134
set(_PackageProject_NAMESPACE "${_PackageProject_NAME}::")
135135
set(_PackageProject_VARS_PREFIX ${_PackageProject_NAME})
136136
set(_PackageProject_EXPORT ${_PackageProject_NAME})
137+
set(_PackageProject_SET "${_PackageProject}_deps_set")
137138

138139
# default version to the project version
139140
if("${_PackageProject_VERSION}" STREQUAL "")
@@ -249,12 +250,35 @@ function(package_project)
249250
install(
250251
TARGETS ${_targets_list}
251252
EXPORT ${_PackageProject_EXPORT}
253+
RUNTIME_DEPENDENCY_SET ${_PackageProject_SET}
252254
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
253255
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
254256
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
255257
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_PackageProject_NAME}" COMPONENT dev
256258
${FILE_SET_ARGS}
257259
)
260+
set(runtime_dirs)
261+
if(VCPKG_INSTALLED_DIR)
262+
list(APPEND runtime_dirs
263+
"${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin"
264+
"${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/lib"
265+
)
266+
endif()
267+
if(runtime_dirs)
268+
install(RUNTIME_DEPENDENCY_SET ${_PackageProject_SET}
269+
PRE_EXCLUDE_REGEXES
270+
[[api-ms-win-.*]]
271+
[[ext-ms-.*]]
272+
[[kernel32\.dll]]
273+
[[(libc|libgcc_s|libgcc_s_seh|libm|libstdc\+\+|libc\+\+|libunwind)(-[0-9.]+)?\..*]]
274+
POST_EXCLUDE_REGEXES
275+
[[.*/system32/.*\.dll]]
276+
[[^/lib.*]]
277+
[[^/usr/lib.*]]
278+
DIRECTORIES
279+
${runtime_dirs}
280+
)
281+
endif()
258282

259283
# download ForwardArguments
260284
FetchContent_Declare(

0 commit comments

Comments
 (0)