diff options
author | Christian Fetzer <fetzer.ch@gmail.com> | 2016-04-05 19:43:24 +0200 |
---|---|---|
committer | Christian Fetzer <fetzer.ch@gmail.com> | 2016-04-06 08:16:14 +0200 |
commit | cc735b78888d58cf8bf8608905ae315782e21ed0 (patch) | |
tree | 8d34ffb24b9792fe4dd1d2f832bb3ecaba6405d7 /project | |
parent | ce28cb617a6de9ba304469f85c1e63f446bbf0fc (diff) |
[cmake] Speed up export-files target
The export-files target mirrors files from the source tree to the build
tree (such as system/ userdata/ addons/) by doing a byte wise diff
which is slow. Instead generate a CMake script that uses file(COPY)
which only copies if the source is newer.
Measurements on Linux machine (real time, cmake + make export-files):
- first run (with cleaned page caches): 19+27s vs. 19+6s
- consecutive run (with cleaned page caches): 12+35s vs. 12+3s
- consecutive run: 6+18s vs. 6+0.3s
Measurements on Windows machine (real time, cmake + make export-files):
- first run: 43+65s vs. 52+8s
- consecutive run: 19+62s vs. 29+1.5s
Diffstat (limited to 'project')
-rw-r--r-- | project/cmake/scripts/common/macros.cmake | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/project/cmake/scripts/common/macros.cmake b/project/cmake/scripts/common/macros.cmake index 5566f76189..e878033f7c 100644 --- a/project/cmake/scripts/common/macros.cmake +++ b/project/cmake/scripts/common/macros.cmake @@ -62,20 +62,20 @@ endfunction() # (if NO_INSTALL is not given). function(copy_file_to_buildtree file relative) cmake_parse_arguments(arg "NO_INSTALL" "" "" ${ARGN}) - if(NOT WIN32) - string(REPLACE "\(" "\\(" file ${file}) - string(REPLACE "\)" "\\)" file ${file}) - endif() string(REPLACE "${relative}/" "" outfile ${file}) + get_filename_component(outdir ${outfile} DIRECTORY) if(NOT TARGET export-files) - add_custom_target(export-files ALL COMMENT "Copying files into build tree") + file(REMOVE ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake) + add_custom_target(export-files ALL COMMENT "Copying files into build tree" + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake) endif() if(NOT ${CORE_SOURCE_DIR} MATCHES ${CMAKE_BINARY_DIR}) if(VERBOSE) - message(STATUS "copy_file_to_buildtree - copying file: ${file} -> ${CMAKE_CURRENT_BINARY_DIR}/${outfile}") + message(STATUS "copy_file_to_buildtree - copying file: ${file} -> ${CMAKE_BINARY_DIR}/${outfile}") endif() - add_custom_command(TARGET export-files COMMAND ${CMAKE_COMMAND} -E copy_if_different "${file}" "${CMAKE_CURRENT_BINARY_DIR}/${outfile}") + file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake + "file(COPY \"${file}\" DESTINATION \"${CMAKE_BINARY_DIR}/${outdir}\")\n") endif() if(NOT arg_NO_INSTALL) list(APPEND install_data ${outfile}) |