diff options
author | Evgeny Grin <k2k@narod.ru> | 2021-02-02 20:39:10 +0300 |
---|---|---|
committer | Evgeny Grin <k2k@narod.ru> | 2021-02-02 20:39:10 +0300 |
commit | f0fead24fbfd68c1364948714dde18f01715f97d (patch) | |
tree | 4d79420861e224145102e31b5094cb7a700b9860 /cmake | |
parent | 0d82d29f59dd7844f25c74fed9dd2eaf0012b947 (diff) |
[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.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/scripts/common/Macros.cmake | 16 |
1 files changed, 12 insertions, 4 deletions
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) |