]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/tools/vcpkg/scripts/cmake/vcpkg_clean_executables_in_bin.cmake
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / tools / vcpkg / scripts / cmake / vcpkg_clean_executables_in_bin.cmake
1 #[===[.md:
2 # vcpkg_clean_executables_in_bin
3
4 Remove specified executables found in `${CURRENT_PACKAGES_DIR}/bin` and `${CURRENT_PACKAGES_DIR}/debug/bin`. If, after all specified executables have been removed, and the `bin` and `debug/bin` directories are empty, then also delete `bin` and `debug/bin` directories.
5
6 ## Usage
7 ```cmake
8 vcpkg_clean_executables_in_bin(
9 FILE_NAMES <file1>...
10 )
11 ```
12
13 ## Parameters
14 ### FILE_NAMES
15 A list of executable filenames without extension.
16
17 ## Notes
18 Generally, there is no need to call this function manually. Instead, pass an extra `AUTO_CLEAN` argument when calling `vcpkg_copy_tools`.
19
20 ## Examples
21 * [czmq](https://github.com/microsoft/vcpkg/blob/master/ports/czmq/portfile.cmake)
22 #]===]
23
24 function(vcpkg_clean_executables_in_bin)
25 # parse parameters such that semicolons in options arguments to COMMAND don't get erased
26 cmake_parse_arguments(PARSE_ARGV 0 _vct "" "" "FILE_NAMES")
27
28 if(NOT DEFINED _vct_FILE_NAMES)
29 message(FATAL_ERROR "FILE_NAMES must be specified.")
30 endif()
31
32 foreach(file_name IN LISTS _vct_FILE_NAMES)
33 file(REMOVE
34 "${CURRENT_PACKAGES_DIR}/bin/${file_name}${VCPKG_TARGET_EXECUTABLE_SUFFIX}"
35 "${CURRENT_PACKAGES_DIR}/debug/bin/${file_name}${VCPKG_TARGET_EXECUTABLE_SUFFIX}"
36 "${CURRENT_PACKAGES_DIR}/bin/${file_name}.pdb"
37 "${CURRENT_PACKAGES_DIR}/debug/bin/${file_name}.pdb"
38 )
39 endforeach()
40
41 function(try_remove_empty_directory directory)
42 if(NOT EXISTS "${directory}")
43 return()
44 endif()
45
46 if(NOT IS_DIRECTORY "${directory}")
47 message(FATAL_ERROR "${directory} is supposed to be an existing directory.")
48 endif()
49
50 # TODO:
51 # For an empty directory,
52 # file(GLOB items "${directory}" "${directory}/*")
53 # will return a list with one item.
54 file(GLOB items "${directory}/" "${directory}/*")
55 list(LENGTH items items_count)
56
57 if(${items_count} EQUAL 0)
58 file(REMOVE_RECURSE "${directory}")
59 endif()
60 endfunction()
61
62 try_remove_empty_directory("${CURRENT_PACKAGES_DIR}/bin")
63 try_remove_empty_directory("${CURRENT_PACKAGES_DIR}/debug/bin")
64 endfunction()