Skip to content

Commit

Permalink
Improve build parallelism by compiling mrregister and mrtransform first
Browse files Browse the repository at this point in the history
mrregister and mrtransform can take a long time to build. If their compilation starts towards the end of the build, Ninja may be compiling a single source file for quite sometime. This may result in suboptimal compilation times.
This hack tries to avoid this by starting their compilation as soon as possible (atm there's no alternative nice way of doing this in Ninja or CMake).

See ninja-build/ninja#232
  • Loading branch information
daljit46 committed Apr 13, 2024
1 parent b7883d3 commit 09fd824
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/CMakeLists.txt
Expand Up @@ -26,8 +26,14 @@ foreach(CMD ${HEADLESS_CMD_SRCS})
add_cmd(${CMD} FALSE)
endforeach(CMD)

# mrregister and mrtransform are the commands that take the longest to compile
# so we try to start their compilation as soon as possible by adding them as dependencies
# of the first command in alphabetical order. This is hacky, but it provides a significant
# speedup in the compilation time when using Ninja.
add_dependencies(5tt2gmwmi mrregister mrtransform)

if(MRTRIX_BUILD_GUI)
foreach(CMD ${GUI_CMD_SRCS})
add_cmd(${CMD} TRUE)
endforeach(CMD)
endif()
endif()

0 comments on commit 09fd824

Please sign in to comment.