From f0fead24fbfd68c1364948714dde18f01715f97d Mon Sep 17 00:00:00 2001 From: Evgeny Grin Date: Tue, 2 Feb 2021 20:39:10 +0300 Subject: [win32] Fixed CMake out-of-source build on Windows CMake is smart enough to detect symlink on Windows, but at the same time is not smart enough to copy symlink itself or linked content on Windows. Currently it fails to copy 'freebsd.xml' which is symlink to 'linux.xml'. Suggested workaround uses CMake internal command and avoids copy of unchanged file. --- cmake/scripts/common/Macros.cmake | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'cmake') diff --git a/cmake/scripts/common/Macros.cmake b/cmake/scripts/common/Macros.cmake index d896651ffd..757d3eebbb 100644 --- a/cmake/scripts/common/Macros.cmake +++ b/cmake/scripts/common/Macros.cmake @@ -221,11 +221,19 @@ function(copy_file_to_buildtree file) endif() if(NOT file STREQUAL ${CMAKE_BINARY_DIR}/${outfile}) - if(VERBOSE) - message(STATUS "copy_file_to_buildtree - copying file: ${file} -> ${CMAKE_BINARY_DIR}/${outfile}") + if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows" OR NOT IS_SYMLINK "${file}") + if(VERBOSE) + message(STATUS "copy_file_to_buildtree - copying file: ${file} -> ${CMAKE_BINARY_DIR}/${outfile}") + endif() + file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake + "file(COPY \"${file}\" DESTINATION \"${CMAKE_BINARY_DIR}/${outdir}\")\n" ) + else() + if(VERBOSE) + message(STATUS "copy_file_to_buildtree - copying symlinked file: ${file} -> ${CMAKE_BINARY_DIR}/${outfile}") + endif() + file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake + "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy_if_different \"${file}\" \"${CMAKE_BINARY_DIR}/${outfile}\")\n") endif() - file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake - "file(COPY \"${file}\" DESTINATION \"${CMAKE_BINARY_DIR}/${outdir}\")\n") endif() if(NOT arg_NO_INSTALL) -- cgit v1.2.3