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
set(TARGET_DATA_COPY DATA_COPY)
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
add_custom_target(
${TARGET_DATA_COPY}
COMMAND ${CMAKE_COMMAND} -E echo "In source build")
else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
make_directory(${CMAKE_CURRENT_BINARY_DIR}/resources/)
add_custom_target(
${TARGET_DATA_COPY}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/dream.xml ${CMAKE_CURRENT_BINARY_DIR}/resources/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/empty.xml ${CMAKE_CURRENT_BINARY_DIR}/resources/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/utf8test.xml ${CMAKE_CURRENT_BINARY_DIR}/resources/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/utf8testverify.xml ${CMAKE_CURRENT_BINARY_DIR}/resources/)
endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
set(DATA_COPY_FILES)
if(NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
foreach(data dream.xml empty.xml utf8test.xml utf8testverify.xml)
set(DATA_COPY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources/${data})
set(DATA_COPY_DEST ${CMAKE_CURRENT_BINARY_DIR}/resources/${data})
add_custom_command(
OUTPUT ${DATA_COPY_DEST}
COMMAND ${CMAKE_COMMAND}
ARGS -E copy ${DATA_COPY_SRC} ${DATA_COPY_DEST}
DEPENDS ${DATA_COPY_SRC})
list(APPEND DATA_COPY_FILES ${DATA_COPY_DEST})
endforeach(data)
endif(NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
add_custom_target(${TARGET_DATA_COPY} DEPENDS ${DATA_COPY_FILES})
################################
# Add definitions