aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/scripts/cmake/vcpkg_clean_executables_in_bin.cmake
diff options
context:
space:
mode:
authorEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
committerEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
commit54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch)
treed915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/scripts/cmake/vcpkg_clean_executables_in_bin.cmake
move to own git serverHEADmaster
Diffstat (limited to 'vcpkg/scripts/cmake/vcpkg_clean_executables_in_bin.cmake')
-rw-r--r--vcpkg/scripts/cmake/vcpkg_clean_executables_in_bin.cmake46
1 files changed, 46 insertions, 0 deletions
diff --git a/vcpkg/scripts/cmake/vcpkg_clean_executables_in_bin.cmake b/vcpkg/scripts/cmake/vcpkg_clean_executables_in_bin.cmake
new file mode 100644
index 0000000..f3c7a75
--- /dev/null
+++ b/vcpkg/scripts/cmake/vcpkg_clean_executables_in_bin.cmake
@@ -0,0 +1,46 @@
+function(z_vcpkg_clean_executables_in_bin_remove_directory_if_empty directory)
+ if(NOT EXISTS "${directory}")
+ return()
+ endif()
+
+ if(NOT IS_DIRECTORY "${directory}")
+ message(FATAL_ERROR "${directory} must be a directory")
+ endif()
+
+ file(GLOB items "${directory}/*")
+ if("${items}" STREQUAL "")
+ file(REMOVE_RECURSE "${directory}")
+ endif()
+endfunction()
+
+
+function(vcpkg_clean_executables_in_bin)
+ cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "FILE_NAMES")
+
+ if(NOT DEFINED arg_FILE_NAMES)
+ message(FATAL_ERROR "FILE_NAMES must be specified.")
+ endif()
+
+ if(DEFINED arg_UNPARSED_ARGUMENTS)
+ message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
+ endif()
+
+
+ foreach(file_name IN LISTS arg_FILE_NAMES)
+ file(REMOVE
+ "${CURRENT_PACKAGES_DIR}/bin/${file_name}${VCPKG_TARGET_EXECUTABLE_SUFFIX}"
+ "${CURRENT_PACKAGES_DIR}/debug/bin/${file_name}${VCPKG_TARGET_EXECUTABLE_SUFFIX}"
+ "${CURRENT_PACKAGES_DIR}/bin/${file_name}.pdb"
+ "${CURRENT_PACKAGES_DIR}/debug/bin/${file_name}.pdb"
+ )
+ if(NOT VCPKG_TARGET_BUNDLE_SUFFIX STREQUAL "")
+ file(REMOVE_RECURSE
+ "${CURRENT_PACKAGES_DIR}/bin/${file_name}${VCPKG_TARGET_BUNDLE_SUFFIX}"
+ "${CURRENT_PACKAGES_DIR}/debug/bin/${file_name}${VCPKG_TARGET_BUNDLE_SUFFIX}"
+ )
+ endif()
+ endforeach()
+
+ z_vcpkg_clean_executables_in_bin_remove_directory_if_empty("${CURRENT_PACKAGES_DIR}/bin")
+ z_vcpkg_clean_executables_in_bin_remove_directory_if_empty("${CURRENT_PACKAGES_DIR}/debug/bin")
+endfunction()