Merge pull request #15433 from huihut:master
authorhuihut <huihut@outlook.com>
Wed, 4 Sep 2019 15:36:56 +0000 (23:36 +0800)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Wed, 4 Sep 2019 15:36:56 +0000 (18:36 +0300)
* fix 'chmod' is not recognized as an internal or external command in Windows

https://github.com/opencv/opencv/issues/14939

* cmake: update PCH command handling

cmake/OpenCVPCHSupport.cmake

index b36fa78..a796ae9 100644 (file)
@@ -305,10 +305,13 @@ fi
 ${_command} '-D$<JOIN:$<TARGET_PROPERTY:${_targetName},COMPILE_DEFINITIONS>,' '-D>'
 ")
     GET_FILENAME_COMPONENT(_outdir ${_output} PATH)
+    if(NOT CMAKE_HOST_WIN32)  # chmod may be not available on Win32/MinGW (and it is not required)
+      set(_pch_prepare_command COMMAND chmod +x "${_pch_generate_file_cmd}")
+    endif()
     ADD_CUSTOM_COMMAND(
       OUTPUT "${_output}"
       COMMAND ${CMAKE_COMMAND} -E make_directory "${_outdir}"
-      COMMAND chmod +x "${_pch_generate_file_cmd}"
+      ${_pch_prepare_command}
       COMMAND "${_pch_generate_file_cmd}"
       DEPENDS "${_input}" "${_pch_generate_file_cmd}"
       DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_name}"