Question

In CMake I have a function:

function(add_mpi_test name no_mpi_proc)
  include_directories(...)
  add_executable(...)
  add_dependencies(...)
  target_link_libraries(...)
  # The important lines:
  set(test_parameters " -np ${no_mpi_proc} ./${name}")
  add_test(NAME ${name} COMMAND "mpirun" ${test_parameters})
endfunction(add_mpi_test)

that I use to create tests like this:

add_mpi_test(mpi 4)

But when I run CTest I get the following error:

2: Test command: /usr/local/bin/mpirun " -np 4 ./mpi "
2: Test timeout computed to be: 9.99988e+06
2: [proxy:0:0@localhost] HYDU_create_process (./utils/launch/launch.c:75): execvp error on file  -np 4 ./mpi  (No such file or directory)

However if I run in the directory

/usr/local/bin/mpirun  -np 4 ./mpi

without the quotes everything works, and if I run it with the quotes

/usr/local/bin/mpirun " -np 4 ./mpi "

I get exactly the same error.

  • Is there a way to remove these quotes?

  • What do I have to change in the line

    add_test(NAME ${name} COMMAND "mpirun" ${test_parameters})

to get:

2: Test command: /usr/local/bin/mpirun -np 4 ./mpi

without quotes?

I've tried

add_test(NAME ${name} COMMAND "mpirun ${test_parameters}")

but then it says in can't find my executable.

Était-ce utile?

La solution

Try:

set (test_parameters -np ${no_mpi_proc} "./${name}")
add_test(NAME ${name} COMMAND "mpirun" ${test_parameters})
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top