[cmake-developers] Any plans to remove the limitation in command line length for the cmake -E remove command?

Ben Boeckel ben.boeckel at kitware.com
Thu May 15 21:51:46 EDT 2014


On Thu, May 15, 2014 at 13:23:10 -0700, Alan W. Irwin wrote:
> I have recently been reminded that the "cmake -E remove" command has a
> limitation due to the length of command line that is acceptable to
> whatever shell is being used.  Is there any willingness to remove that
> limitation (in which case it would be worthwhile for me to make a
> formal bug report) or is this limitation something that should just be
> accepted indefinitely?

This isn't limited to "cmake -E remove". The problem is that the line is
too long to even call "cmake -E remove", so no amount of code on CMake's
side will help here. Well, /technically/ it could, but then you need
some way of doing:

    add_custom_command(
        TARGET       clean-testfiles
        BASE_COMMAND cmake -E remove
        ARGUMENTS    ${test_output_files_LIST})

and then have CMake implement something like xargs to chunk the
available arguments out. I don't think the extra complexity is worth it,
IMO. Possible solutions I can think of follow.

> The reason I ask is the PLplot test suite has a combinatorial issue
> with the number of different tests that are possible.  As currently
> implemented we are careful not to explore all combinations of the
> possibilities in our testing.  Nevertheless, the typical result of
> ctest is ~5000 files which consume ~3GB of disk space.  Therefore, I
> have implemented a convenience custom target to remove all those files
> as follows:

Would it make more sense to have tests delete their outputs unless they
fail or KEEP_TEST_FILES environment variable is set (which would then be
run on a subset of tests ideally)? This is what VTK does.

> add_custom_target(clean_ctest_plot_files
>    COMMAND ${CMAKE_COMMAND} -E remove ${test_output_files_LIST}
>    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
>    )

Alternatively (with caveats in Ninja; see below):

    add_custom_target(clean_ctest_plot_files)
    foreach (test_file IN LISTS test_output_files_LIST)
        add_custom_command(
            TARGET  clean_ctest_plot_files
            COMMAND cmake -E remove "${test_file}")
    endforeach ()

This is probably fine in makefiles (which I believe is one line per
command on a target), but will fail with ninja though (since it joins
all commands with " && " and runs in one shell). I don't know about the
IDE generators.

Ninja would be fine with your add_custom_target if you set
CMAKE_NINJA_FORCE_RESPONSE_FILE to TRUE though.

--Ben



More information about the cmake-developers mailing list