Workaround CMake being unable to override symlink on Windows

The documentation says "If <linkname> already exists, it will
be overwritten.". This seems to be the case on GNU/Linux but
on Windows with CMake 3.24.2 (as provided by the official Qt
installer) I've nevertheless got an error.
This commit is contained in:
Martchus 2023-03-23 21:10:05 +01:00
parent e3d82ad643
commit fd14d3c502
1 changed files with 4 additions and 0 deletions

View File

@ -52,6 +52,10 @@ set(META_CUSTOM_CONFIG
set(RES_FILE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${META_PROJECT_NAME}_font.qrc")
set(RES_FILE_DATA "<RCC><qresource prefix=\"/\"><file>${META_FONT_FILE_NAME}</file></qresource></RCC>")
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.14")
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" AND EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${META_FONT_FILE_NAME}")
# avoid running into error when symlink already exists (should not be necassary according to docs)
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/${META_FONT_FILE_NAME}")
endif ()
file(CREATE_LINK "${FORK_AWESOME_FONT_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/${META_FONT_FILE_NAME}" SYMBOLIC)
else ()
file(COPY "${FORK_AWESOME_FONT_FILE}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")