I would like to create a custom target to run UnitTest++ based unit tests that
has builtin default parameters.
For example:
make unit_test verbose=1 xml-output=1 run=test_name suite=suite_name
The actual parameters passed to the unit_test are:
unit_test --verbose --xml-output --run=test_name --suite=suite_name
I would prefer NOT to call a shell script but rather have the intelligence in
the COMMAND itself.
Here’s what I’ve done:
add_custom_target(${PROJECT_NAME}_run
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${target} "$(if $(verbose),
--verbose)" "$(if $(run), --run=$(run))" "$(if $(suite), --suite=$(suite))"
"$(if $(xml-output), --xml-output)" \${PARAMS}
DEPENDS ${target}
)
What ends up in build.make is this:
…/unit_test $(if\ $(verbose),\ --verbose) $(if\ $(xml-output),\
--xml-output) $(if\ $(run),\ --run=$(run)) $(if\ $(suite),\ --suite=$(suite))
This would work great if CMake didn’t put ‘\’ characters in build.cmake. I can
only assume it’s escaping the spaces within the quotes.
If I don’t use quotes in the COMMAND value I get this:
$ ( if $(verbose), --verbose )
Is there a way to format the COMMAND value so CMake doesn’t escape the spaces?
I’m using CMake version 3.7.2
—Dave--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake