From 36d2791972ffd3809f454408dad16532026539d8 Mon Sep 17 00:00:00 2001 From: Qixiang Xu Date: Thu, 21 Feb 2019 14:55:13 +0800 Subject: [PATCH] Fix CMake build error on Cygwin and minGW platforms Signed-off-by: Qixiang Xu --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ade1d4cb..2005abc33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,8 +65,14 @@ set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} # to the corresponding path in the source directory. function(link_to_source base_name) # Get OS dependent path to use in `execute_process` - file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${base_name}" link) - file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${base_name}" target) + if (CMAKE_HOST_WIN32) + #mklink is an internal command of cmd.exe it can only work with \ + string(REPLACE "/" "\\" link "${CMAKE_CURRENT_BINARY_DIR}/${base_name}") + string(REPLACE "/" "\\" target "${CMAKE_CURRENT_SOURCE_DIR}/${base_name}") + else() + set(link "${CMAKE_CURRENT_BINARY_DIR}/${base_name}") + set(target "${CMAKE_CURRENT_SOURCE_DIR}/${base_name}") + endif() if (NOT EXISTS ${link}) if (CMAKE_HOST_UNIX)