Created
August 29, 2023 19:15
-
-
Save scivision/4c4047122ef657e970c0e1aed93b139e to your computer and use it in GitHub Desktop.
CMake extract file to UNC path example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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