Skip to content

Instantly share code, notes, and snippets.

@scivision
Created August 29, 2023 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scivision/4c4047122ef657e970c0e1aed93b139e to your computer and use it in GitHub Desktop.
Save scivision/4c4047122ef657e970c0e1aed93b139e to your computer and use it in GitHub Desktop.
CMake extract file to UNC path example
# extract file to UNC path example
cmake_minimum_required(VERSION 3.20)
# using WSL as example UNC network path
set(bin "\\\\wsl$\\Ubuntu\\home\\username")
if(NOT IS_DIRECTORY ${bin})
message(FATAL_ERROR "${bin} is not a directory")
endif()
# for simple demo, put own file in .zst archive
set(archive ${CMAKE_CURRENT_BINARY_DIR}/test.zst)
file(ARCHIVE_CREATE OUTPUT ${archive} PATHS ${CMAKE_CURRENT_LIST_FILE})
cmake_path(GET CMAKE_CURRENT_LIST_FILE FILENAME name)
message(STATUS "Extracting ${archive} to ${bin}/${name}")
file(ARCHIVE_EXTRACT INPUT "${archive}" DESTINATION "${bin}" VERBOSE)
if(NOT EXISTS ${bin}/${name})
message(FATAL_ERROR "Failed to extract ${bin}/${name}")
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment