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>]
|
|
|
|
[AUTO_CLEAN]
|
|
|
|
)
|
|
|
|
```
|
|
|
|
## Parameters
|
|
|
|
### TOOL_NAMES
|
|
|
|
A list of tool filenames without extension.
|
|
|
|
|
|
|
|
### SEARCH_DIR
|
|
|
|
The path to the directory containing the tools. This will be set to `${CURRENT_PACKAGES_DIR}/bin` if ommited.
|
|
|
|
|
|
|
|
### AUTO_CLEAN
|
|
|
|
Auto clean executables in `${CURRENT_PACKAGES_DIR}/bin` and `${CURRENT_PACKAGES_DIR}/debug/bin`.
|
|
|
|
|
|
|
|
## 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)
|
2020-10-27 10:30:27 +08:00
|
|
|
# parse parameters such that semicolons in options arguments to COMMAND don't get erased
|
|
|
|
cmake_parse_arguments(PARSE_ARGV 0 _vct "AUTO_CLEAN" "SEARCH_DIR" "TOOL_NAMES")
|
2020-05-02 06:28:55 +08:00
|
|
|
|
|
|
|
if(NOT DEFINED _vct_TOOL_NAMES)
|
|
|
|
message(FATAL_ERROR "TOOL_NAMES must be specified.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT DEFINED _vct_SEARCH_DIR)
|
2020-11-06 10:16:47 +08:00
|
|
|
set(_vct_SEARCH_DIR "${CURRENT_PACKAGES_DIR}/bin")
|
2020-05-02 06:28:55 +08:00
|
|
|
elseif(NOT IS_DIRECTORY ${_vct_SEARCH_DIR})
|
|
|
|
message(FATAL_ERROR "SEARCH_DIR ${_vct_SEARCH_DIR} is supposed to be a directory.")
|
|
|
|
endif()
|
|
|
|
|
2020-11-06 10:16:47 +08:00
|
|
|
foreach(tool_name IN LISTS _vct_TOOL_NAMES)
|
2020-05-02 06:28:55 +08:00
|
|
|
set(tool_path "${_vct_SEARCH_DIR}/${tool_name}${VCPKG_TARGET_EXECUTABLE_SUFFIX}")
|
2020-11-06 10:16:47 +08:00
|
|
|
set(tool_pdb "${_vct_SEARCH_DIR}/${tool_name}.pdb")
|
|
|
|
if(EXISTS "${tool_path}")
|
|
|
|
file(COPY "${tool_path}" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
|
2020-05-02 06:28:55 +08:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Couldn't find this tool: ${tool_path}.")
|
|
|
|
endif()
|
2020-11-06 10:16:47 +08:00
|
|
|
if(EXISTS "${tool_pdb}")
|
|
|
|
file(COPY "${tool_pdb}" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
|
|
|
|
endif()
|
2020-05-02 06:28:55 +08:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if(_vct_AUTO_CLEAN)
|
|
|
|
vcpkg_clean_executables_in_bin(FILE_NAMES ${_vct_TOOL_NAMES})
|
|
|
|
endif()
|
|
|
|
|
2020-11-06 10:16:47 +08:00
|
|
|
vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/${PORT}")
|
2020-05-02 06:28:55 +08:00
|
|
|
endfunction()
|