]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
1 | #[===[.md:\r |
2 | # vcpkg_copy_tools\r | |
3 | \r | |
4 | Copy tools and all their DLL dependencies into the `tools` folder.\r | |
5 | \r | |
6 | ## Usage\r | |
7 | ```cmake\r | |
8 | vcpkg_copy_tools(\r | |
9 | TOOL_NAMES <tool1>...\r | |
10 | [SEARCH_DIR <${CURRENT_PACKAGES_DIR}/bin>]\r | |
11 | [DESTINATION <${CURRENT_PACKAGES_DIR}/tools/${PORT}>]\r | |
12 | [AUTO_CLEAN]\r | |
13 | )\r | |
14 | ```\r | |
15 | ## Parameters\r | |
16 | ### TOOL_NAMES\r | |
17 | A list of tool filenames without extension.\r | |
18 | \r | |
19 | ### SEARCH_DIR\r | |
20 | The path to the directory containing the tools. This will be set to `${CURRENT_PACKAGES_DIR}/bin` if omitted.\r | |
21 | \r | |
22 | ### DESTINATION\r | |
23 | Destination to copy the tools to. This will be set to `${CURRENT_PACKAGES_DIR}/tools/${PORT}` if omitted.\r | |
24 | \r | |
25 | ### AUTO_CLEAN\r | |
26 | Auto clean executables in `${CURRENT_PACKAGES_DIR}/bin` and `${CURRENT_PACKAGES_DIR}/debug/bin`.\r | |
27 | \r | |
28 | ## Examples\r | |
29 | \r | |
30 | * [cpuinfo](https://github.com/microsoft/vcpkg/blob/master/ports/cpuinfo/portfile.cmake)\r | |
31 | * [nanomsg](https://github.com/microsoft/vcpkg/blob/master/ports/nanomsg/portfile.cmake)\r | |
32 | * [uriparser](https://github.com/microsoft/vcpkg/blob/master/ports/uriparser/portfile.cmake)\r | |
33 | #]===]\r | |
34 | \r | |
35 | function(vcpkg_copy_tools)\r | |
36 | # parse parameters such that semicolons in options arguments to COMMAND don't get erased\r | |
37 | cmake_parse_arguments(PARSE_ARGV 0 _vct "AUTO_CLEAN" "SEARCH_DIR;DESTINATION" "TOOL_NAMES")\r | |
38 | \r | |
39 | if(NOT DEFINED _vct_TOOL_NAMES)\r | |
40 | message(FATAL_ERROR "TOOL_NAMES must be specified.")\r | |
41 | endif()\r | |
42 | \r | |
43 | if(NOT DEFINED _vct_DESTINATION)\r | |
44 | set(_vct_DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}")\r | |
45 | endif()\r | |
46 | \r | |
47 | if(NOT DEFINED _vct_SEARCH_DIR)\r | |
48 | set(_vct_SEARCH_DIR "${CURRENT_PACKAGES_DIR}/bin")\r | |
49 | elseif(NOT IS_DIRECTORY ${_vct_SEARCH_DIR})\r | |
50 | message(FATAL_ERROR "SEARCH_DIR ${_vct_SEARCH_DIR} is supposed to be a directory.")\r | |
51 | endif()\r | |
52 | \r | |
53 | foreach(tool_name IN LISTS _vct_TOOL_NAMES)\r | |
54 | set(tool_path "${_vct_SEARCH_DIR}/${tool_name}${VCPKG_TARGET_EXECUTABLE_SUFFIX}")\r | |
55 | set(tool_pdb "${_vct_SEARCH_DIR}/${tool_name}.pdb")\r | |
56 | if(EXISTS "${tool_path}")\r | |
57 | file(COPY "${tool_path}" DESTINATION "${_vct_DESTINATION}")\r | |
58 | else()\r | |
59 | message(FATAL_ERROR "Couldn't find this tool: ${tool_path}.")\r | |
60 | endif()\r | |
61 | if(EXISTS "${tool_pdb}")\r | |
62 | file(COPY "${tool_pdb}" DESTINATION "${_vct_DESTINATION}")\r | |
63 | endif()\r | |
64 | endforeach()\r | |
65 | \r | |
66 | if(_vct_AUTO_CLEAN)\r | |
67 | vcpkg_clean_executables_in_bin(FILE_NAMES ${_vct_TOOL_NAMES})\r | |
68 | endif()\r | |
69 | \r | |
70 | vcpkg_copy_tool_dependencies("${_vct_DESTINATION}")\r | |
71 | endfunction()\r |