2020-12-02 05:37:26 +08:00
|
|
|
#[===[.md:
|
|
|
|
# vcpkg_copy_tools
|
|
|
|
|
|
|
|
Copy tools and all their DLL dependencies into the `tools` folder.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
```cmake
|
|
|
|
vcpkg_copy_tools(
|
|
|
|
TOOL_NAMES <tool1>...
|
|
|
|
[SEARCH_DIR <${CURRENT_PACKAGES_DIR}/bin>]
|
2021-04-01 03:47:35 +08:00
|
|
|
[DESTINATION <${CURRENT_PACKAGES_DIR}/tools/${PORT}>]
|
2020-12-02 05:37:26 +08:00
|
|
|
[AUTO_CLEAN]
|
|
|
|
)
|
|
|
|
```
|
|
|
|
## Parameters
|
|
|
|
### TOOL_NAMES
|
|
|
|
A list of tool filenames without extension.
|
|
|
|
|
|
|
|
### SEARCH_DIR
|
2021-05-10 01:48:42 +08:00
|
|
|
The path to the directory containing the tools. This will be set to `${CURRENT_PACKAGES_DIR}/bin` if omitted.
|
2020-12-02 05:37:26 +08:00
|
|
|
|
2021-04-01 03:47:35 +08:00
|
|
|
### DESTINATION
|
2021-05-10 01:48:42 +08:00
|
|
|
Destination to copy the tools to. This will be set to `${CURRENT_PACKAGES_DIR}/tools/${PORT}` if omitted.
|
2021-04-01 03:47:35 +08:00
|
|
|
|
2020-12-02 05:37:26 +08:00
|
|
|
### AUTO_CLEAN
|
2021-10-27 14:44:43 +08:00
|
|
|
Auto clean the copied executables from `${CURRENT_PACKAGES_DIR}/bin` and `${CURRENT_PACKAGES_DIR}/debug/bin`.
|
2020-12-02 05:37:26 +08:00
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
* [cpuinfo](https://github.com/microsoft/vcpkg/blob/master/ports/cpuinfo/portfile.cmake)
|
|
|
|
* [nanomsg](https://github.com/microsoft/vcpkg/blob/master/ports/nanomsg/portfile.cmake)
|
|
|
|
* [uriparser](https://github.com/microsoft/vcpkg/blob/master/ports/uriparser/portfile.cmake)
|
|
|
|
#]===]
|
|
|
|
|
2020-05-02 06:28:55 +08:00
|
|
|
function(vcpkg_copy_tools)
|
2021-07-30 00:47:35 +08:00
|
|
|
cmake_parse_arguments(PARSE_ARGV 0 arg "AUTO_CLEAN" "SEARCH_DIR;DESTINATION" "TOOL_NAMES")
|
2020-05-02 06:28:55 +08:00
|
|
|
|
2021-07-30 00:47:35 +08:00
|
|
|
if(DEFINED arg_UNPARSED_ARGUMENTS)
|
|
|
|
message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT DEFINED arg_TOOL_NAMES)
|
2020-05-02 06:28:55 +08:00
|
|
|
message(FATAL_ERROR "TOOL_NAMES must be specified.")
|
|
|
|
endif()
|
|
|
|
|
2021-07-30 00:47:35 +08:00
|
|
|
if(NOT DEFINED arg_DESTINATION)
|
|
|
|
set(arg_DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
|
2021-04-01 03:47:35 +08:00
|
|
|
endif()
|
|
|
|
|
2021-07-30 00:47:35 +08:00
|
|
|
if(NOT DEFINED arg_SEARCH_DIR)
|
|
|
|
set(arg_SEARCH_DIR "${CURRENT_PACKAGES_DIR}/bin")
|
|
|
|
elseif(NOT IS_DIRECTORY "${arg_SEARCH_DIR}")
|
|
|
|
message(FATAL_ERROR "SEARCH_DIR (${arg_SEARCH_DIR}) must be a directory")
|
2020-05-02 06:28:55 +08:00
|
|
|
endif()
|
|
|
|
|
2021-07-30 00:47:35 +08:00
|
|
|
foreach(tool_name IN LISTS arg_TOOL_NAMES)
|
|
|
|
set(tool_path "${arg_SEARCH_DIR}/${tool_name}${VCPKG_TARGET_EXECUTABLE_SUFFIX}")
|
|
|
|
set(tool_pdb "${arg_SEARCH_DIR}/${tool_name}.pdb")
|
2020-11-06 10:16:47 +08:00
|
|
|
if(EXISTS "${tool_path}")
|
2021-07-30 00:47:35 +08:00
|
|
|
file(COPY "${tool_path}" DESTINATION "${arg_DESTINATION}")
|
2021-10-05 03:40:14 +08:00
|
|
|
elseif(NOT "${VCPKG_TARGET_BUNDLE_SUFFIX}" STREQUAL "" AND NOT "${VCPKG_TARGET_BUNDLE_SUFFIX}" STREQUAL "${VCPKG_TARGET_EXECUTABLE_SUFFIX}")
|
|
|
|
set(bundle_path "${arg_SEARCH_DIR}/${tool_name}${VCPKG_TARGET_BUNDLE_SUFFIX}")
|
|
|
|
if(EXISTS "${bundle_path}")
|
|
|
|
file(COPY "${bundle_path}" DESTINATION "${arg_DESTINATION}")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Couldn't find tool \"${tool_name}\":
|
|
|
|
neither \"${tool_path}\" nor \"${bundle_path}\" exists")
|
|
|
|
endif()
|
2020-05-02 06:28:55 +08:00
|
|
|
else()
|
2021-07-30 00:47:35 +08:00
|
|
|
message(FATAL_ERROR "Couldn't find tool \"${tool_name}\":
|
|
|
|
\"${tool_path}\" does not exist")
|
2020-05-02 06:28:55 +08:00
|
|
|
endif()
|
2020-11-06 10:16:47 +08:00
|
|
|
if(EXISTS "${tool_pdb}")
|
2021-07-30 00:47:35 +08:00
|
|
|
file(COPY "${tool_pdb}" DESTINATION "${arg_DESTINATION}")
|
2020-11-06 10:16:47 +08:00
|
|
|
endif()
|
2020-05-02 06:28:55 +08:00
|
|
|
endforeach()
|
|
|
|
|
2021-07-30 00:47:35 +08:00
|
|
|
if(arg_AUTO_CLEAN)
|
|
|
|
vcpkg_clean_executables_in_bin(FILE_NAMES ${arg_TOOL_NAMES})
|
2020-05-02 06:28:55 +08:00
|
|
|
endif()
|
|
|
|
|
2021-07-30 00:47:35 +08:00
|
|
|
vcpkg_copy_tool_dependencies("${arg_DESTINATION}")
|
2020-05-02 06:28:55 +08:00
|
|
|
endfunction()
|