Merge pull request #435 from ongjunjie/master

minimize file copying on incremental builds
This commit is contained in:
Lee Thomason 2016-05-14 10:46:04 -07:00
commit 31d6c877bd
1 changed files with 14 additions and 13 deletions

View File

@ -30,19 +30,20 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/.")
# Add custom target to copy all data # Add custom target to copy all data
set(TARGET_DATA_COPY DATA_COPY) set(TARGET_DATA_COPY DATA_COPY)
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) set(DATA_COPY_FILES)
add_custom_target( if(NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
${TARGET_DATA_COPY} foreach(data dream.xml empty.xml utf8test.xml utf8testverify.xml)
COMMAND ${CMAKE_COMMAND} -E echo "In source build") set(DATA_COPY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources/${data})
else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) set(DATA_COPY_DEST ${CMAKE_CURRENT_BINARY_DIR}/resources/${data})
make_directory(${CMAKE_CURRENT_BINARY_DIR}/resources/) add_custom_command(
add_custom_target( OUTPUT ${DATA_COPY_DEST}
${TARGET_DATA_COPY} COMMAND ${CMAKE_COMMAND}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/dream.xml ${CMAKE_CURRENT_BINARY_DIR}/resources/ ARGS -E copy ${DATA_COPY_SRC} ${DATA_COPY_DEST}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/empty.xml ${CMAKE_CURRENT_BINARY_DIR}/resources/ DEPENDS ${DATA_COPY_SRC})
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/utf8test.xml ${CMAKE_CURRENT_BINARY_DIR}/resources/ list(APPEND DATA_COPY_FILES ${DATA_COPY_DEST})
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/utf8testverify.xml ${CMAKE_CURRENT_BINARY_DIR}/resources/) endforeach(data)
endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) endif(NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
add_custom_target(${TARGET_DATA_COPY} DEPENDS ${DATA_COPY_FILES})
################################ ################################
# Add definitions # Add definitions