From b15a9d675e70204b3df11ba9d017bf909e39b808 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 8 Sep 2015 22:42:05 +0300 Subject: [PATCH] cmake: use copy_if_different --- cmake/OpenCVDetectAndroidSDK.cmake | 4 ++-- cmake/OpenCVPCHSupport.cmake | 2 +- modules/java/CMakeLists.txt | 12 ++++++------ modules/java/android_test/CMakeLists.txt | 6 +++--- modules/java/pure_test/CMakeLists.txt | 6 +++--- modules/videoio/CMakeLists.txt | 8 ++++---- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/cmake/OpenCVDetectAndroidSDK.cmake b/cmake/OpenCVDetectAndroidSDK.cmake index 3bfb10e..bc9dcd0 100644 --- a/cmake/OpenCVDetectAndroidSDK.cmake +++ b/cmake/OpenCVDetectAndroidSDK.cmake @@ -240,7 +240,7 @@ macro(add_android_project target path) foreach(f ${android_proj_files}) add_custom_command( OUTPUT "${android_proj_bin_dir}/${f}" - COMMAND ${CMAKE_COMMAND} -E copy "${path}/${f}" "${android_proj_bin_dir}/${f}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${path}/${f}" "${android_proj_bin_dir}/${f}" MAIN_DEPENDENCY "${path}/${f}" COMMENT "Copying ${f}") list(APPEND android_proj_file_deps "${path}/${f}" "${android_proj_bin_dir}/${f}") @@ -353,7 +353,7 @@ macro(add_android_project target path) set(__android_project_chain ${target} CACHE INTERNAL "auxiliary variable used for Android progects chaining") # put the final .apk to the OpenCV's bin folder - add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${android_proj_bin_dir}/bin/${target}-debug.apk" "${OpenCV_BINARY_DIR}/bin/${target}.apk") + add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${android_proj_bin_dir}/bin/${target}-debug.apk" "${OpenCV_BINARY_DIR}/bin/${target}.apk") if(INSTALL_ANDROID_EXAMPLES AND "${target}" MATCHES "^example-") #apk install(FILES "${OpenCV_BINARY_DIR}/bin/${target}.apk" DESTINATION "samples" COMPONENT samples) diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake index 1c03f36..910235e 100644 --- a/cmake/OpenCVPCHSupport.cmake +++ b/cmake/OpenCVPCHSupport.cmake @@ -277,7 +277,7 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _input) ADD_CUSTOM_COMMAND( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_name}" - COMMAND ${CMAKE_COMMAND} -E copy "${_input}" "${CMAKE_CURRENT_BINARY_DIR}/${_name}" # ensure same directory! Required by gcc + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_input}" "${CMAKE_CURRENT_BINARY_DIR}/${_name}" # ensure same directory! Required by gcc DEPENDS "${_input}" ) diff --git a/modules/java/CMakeLists.txt b/modules/java/CMakeLists.txt index 3a113d5..17d1907 100644 --- a/modules/java/CMakeLists.txt +++ b/modules/java/CMakeLists.txt @@ -81,7 +81,7 @@ macro(copy_common_tests _src_location _dst_location _deps) foreach(f ${_files}) add_custom_command( OUTPUT "${_dst}/${f}" - COMMAND ${CMAKE_COMMAND} -E copy "${_src}/${f}" "${_dst}/${f}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_src}/${f}" "${_dst}/${f}" MAIN_DEPENDENCY "${_src}/${f}" COMMENT "Copying ${f}") list(APPEND ${_deps} "${_src}/${f}" "${_dst}/${f}") @@ -102,7 +102,7 @@ macro(copy_modules_tests _modules _dst_location _deps) foreach (f ${_files}) add_custom_command( OUTPUT "${_dst}/${_tree}/${f}" - COMMAND ${CMAKE_COMMAND} -E copy "${_src}/${f}" "${_dst}/${_tree}/${f}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_src}/${f}" "${_dst}/${_tree}/${f}" MAIN_DEPENDENCY "${_src}/${f}" COMMENT "Copying ${f}") list(APPEND ${_deps} "${_src}/${f}" "${_dst}/${_tree}/${f}") @@ -208,7 +208,7 @@ foreach(java_file ${step3_input_files}) string(REPLACE "+" "/" java_file_name "${java_file_name}") set(output_name "${OpenCV_BINARY_DIR}/src/org/opencv/${java_file_name}") add_custom_command(OUTPUT "${output_name}" - COMMAND ${CMAKE_COMMAND} -E copy "${java_file}" "${output_name}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${java_file}" "${output_name}" MAIN_DEPENDENCY "${java_file}" DEPENDS ${step1_depends} ${generated_java_sources} ${handwritten_java_sources} COMMENT "Generating src/org/opencv/${java_file_name}" @@ -239,7 +239,7 @@ if(ANDROID) foreach(jni_file ${handwritten_cpp_sources} ${handwritten_h_sources} ${generated_cpp_sources}) get_filename_component(jni_file_name "${jni_file}" NAME) add_custom_command(OUTPUT "${OpenCV_BINARY_DIR}/jni/${jni_file_name}" - COMMAND ${CMAKE_COMMAND} -E copy "${jni_file}" "${OpenCV_BINARY_DIR}/jni/${jni_file_name}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${jni_file}" "${OpenCV_BINARY_DIR}/jni/${jni_file_name}" DEPENDS "${jni_file}" ${java_hdr_deps} COMMENT "Generating jni/${jni_file_name}" ) @@ -257,9 +257,9 @@ if(ANDROID AND ANDROID_EXECUTABLE) add_custom_command(OUTPUT ${lib_target_files} "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" COMMAND ${CMAKE_COMMAND} -E remove ${lib_target_files} - COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" COMMAND ${ANDROID_EXECUTABLE} --silent create lib-project --path \"${OpenCV_BINARY_DIR}\" --target \"${lib_target_sdk_target}\" --name OpenCV --package org.opencv 2>\"${CMAKE_CURRENT_BINARY_DIR}/create_lib_project.log\" - COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" MAIN_DEPENDENCY "${CMAKE_CURRENT_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" DEPENDS ${android_step3_input_files} ${android_copied_files} COMMENT "Generating OpenCV Android library project. SDK target: ${lib_target_sdk_target}" diff --git a/modules/java/android_test/CMakeLists.txt b/modules/java/android_test/CMakeLists.txt index e195732..f6261a7 100644 --- a/modules/java/android_test/CMakeLists.txt +++ b/modules/java/android_test/CMakeLists.txt @@ -21,7 +21,7 @@ file(GLOB_RECURSE test_files RELATIVE "${test_dir}" "${test_dir}/res/*" "${test_ foreach(f ${test_files} ${ANDROID_MANIFEST_FILE} ".classpath" ".project") add_custom_command( OUTPUT "${opencv_test_java_bin_dir}/${f}" - COMMAND ${CMAKE_COMMAND} -E copy "${test_dir}/${f}" "${opencv_test_java_bin_dir}/${f}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${test_dir}/${f}" "${opencv_test_java_bin_dir}/${f}" MAIN_DEPENDENCY "${test_dir}/${f}" COMMENT "Copying ${f}") list(APPEND opencv_test_java_file_deps "${test_dir}/${f}" "${opencv_test_java_bin_dir}/${f}") @@ -49,7 +49,7 @@ get_filename_component(java_name "${java_location}" NAME) # build java part add_custom_command( OUTPUT "${opencv_test_java_bin_dir}/bin/OpenCVTest-debug.apk" - COMMAND ${CMAKE_COMMAND} -E copy "${java_location}" "${opencv_test_java_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}/${java_name}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${java_location}" "${opencv_test_java_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}/${java_name}" COMMAND ${ANT_EXECUTABLE} -q -noinput -k debug COMMAND ${CMAKE_COMMAND} -E touch "${opencv_test_java_bin_dir}/bin/OpenCVTest-debug.apk" # needed because ant does not update the timestamp of updated apk WORKING_DIRECTORY "${opencv_test_java_bin_dir}" @@ -62,7 +62,7 @@ add_dependencies(${PROJECT_NAME} opencv_java ${__android_project_chain}) set(__android_project_chain ${PROJECT_NAME} CACHE INTERNAL "auxiliary variable used for Android progects chaining" FORCE) # put the final .apk to the OpenCV's bin folder -add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${opencv_test_java_bin_dir}/bin/OpenCVTest-debug.apk" "${OpenCV_BINARY_DIR}/bin/${PROJECT_NAME}.apk") +add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${opencv_test_java_bin_dir}/bin/OpenCVTest-debug.apk" "${OpenCV_BINARY_DIR}/bin/${PROJECT_NAME}.apk") add_dependencies(opencv_tests ${PROJECT_NAME}) diff --git a/modules/java/pure_test/CMakeLists.txt b/modules/java/pure_test/CMakeLists.txt index 6c9766c..7d78414 100644 --- a/modules/java/pure_test/CMakeLists.txt +++ b/modules/java/pure_test/CMakeLists.txt @@ -24,7 +24,7 @@ file(GLOB_RECURSE test_files RELATIVE "${test_dir}" "${test_dir}/src/*") file(GLOB_RECURSE test_lib_files RELATIVE "${test_dir}" "${test_dir}/lib/*.jar") foreach(f ${test_files} ${test_lib_files}) add_custom_command(OUTPUT "${opencv_test_java_bin_dir}/${f}" - COMMAND ${CMAKE_COMMAND} -E copy "${test_dir}/${f}" "${opencv_test_java_bin_dir}/${f}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${test_dir}/${f}" "${opencv_test_java_bin_dir}/${f}" DEPENDS "${test_dir}/${f}" COMMENT "Copying ${f}" ) @@ -33,13 +33,13 @@ endforeach() # Copy the OpenCV jar after it has been generated. add_custom_command(OUTPUT "${opencv_test_java_bin_dir}/bin/${JAR_NAME}" - COMMAND ${CMAKE_COMMAND} -E copy "${JAR_FILE}" "${opencv_test_java_bin_dir}/bin/${JAR_NAME}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${JAR_FILE}" "${opencv_test_java_bin_dir}/bin/${JAR_NAME}" DEPENDS "${JAR_FILE}" COMMENT "Copying the OpenCV jar" ) add_custom_command(OUTPUT "${opencv_test_java_bin_dir}/build.xml" - COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/build.xml" "${opencv_test_java_bin_dir}/build.xml" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/build.xml" "${opencv_test_java_bin_dir}/build.xml" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/build.xml" COMMENT "Copying build.xml" ) diff --git a/modules/videoio/CMakeLists.txt b/modules/videoio/CMakeLists.txt index 2f5bed9..9e91a8a 100644 --- a/modules/videoio/CMakeLists.txt +++ b/modules/videoio/CMakeLists.txt @@ -249,16 +249,16 @@ if(WIN32 AND WITH_FFMPEG) if(MSVC_IDE) add_custom_command(TARGET ${the_module} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Release/${ffmpeg_bare_name_ver}" - COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Debug/${ffmpeg_bare_name_ver}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Release/${ffmpeg_bare_name_ver}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Debug/${ffmpeg_bare_name_ver}" COMMENT "Copying ${ffmpeg_path} to the output directory") elseif(MSVC AND (CMAKE_GENERATOR MATCHES "Visual")) add_custom_command(TARGET ${the_module} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/${ffmpeg_bare_name_ver}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/${ffmpeg_bare_name_ver}" COMMENT "Copying ${ffmpeg_path} to the output directory") else() add_custom_command(TARGET ${the_module} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${ffmpeg_bare_name_ver}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${ffmpeg_bare_name_ver}" COMMENT "Copying ${ffmpeg_path} to the output directory") endif() -- 2.7.4