From 3f359430b3823a5c8cf8912bd356c9e7e8f5a829 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 8 Oct 2013 15:07:00 +0000 Subject: [PATCH] Only modify lto.exports.def when contents have changed. Patch by Greg Bedwell. llvm-svn: 192182 --- llvm/tools/lto/CMakeLists.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/llvm/tools/lto/CMakeLists.txt b/llvm/tools/lto/CMakeLists.txt index 89160ee02397..957a9f0036c3 100644 --- a/llvm/tools/lto/CMakeLists.txt +++ b/llvm/tools/lto/CMakeLists.txt @@ -15,10 +15,16 @@ if( NOT CYGWIN AND LLVM_ENABLE_PIC ) # 'EXPORTS'. The file "lto.exports" already contains the list, so we # massage it into the correct format here to create "lto.exports.def". set(LTO_EXPORTS_DEF ${CMAKE_CURRENT_BINARY_DIR}/lto.exports.def) + set(LTO_EXPORTS_DEF_TEMP ${LTO_EXPORTS_DEF}.txt) file(READ "lto.exports" exports_list) - file(WRITE ${LTO_EXPORTS_DEF} "LIBRARY LTO\n") - file(APPEND ${LTO_EXPORTS_DEF} "EXPORTS\n") - file(APPEND ${LTO_EXPORTS_DEF} ${exports_list}) + file(WRITE ${LTO_EXPORTS_DEF_TEMP} "LIBRARY LTO\n") + file(APPEND ${LTO_EXPORTS_DEF_TEMP} "EXPORTS\n") + file(APPEND ${LTO_EXPORTS_DEF_TEMP} ${exports_list}) + + # Copy the file only if it has changed. + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${LTO_EXPORTS_DEF_TEMP} ${LTO_EXPORTS_DEF}) + set(SHARED_LIB_SOURCES ${SOURCES} ${LTO_EXPORTS_DEF}) else() set(SHARED_LIB_SOURCES ${SOURCES})