Reputation: 581
Using cmake 2.8.12.1, I have the following lines:
set(LCOV ~/tools/com.cloudbees.jenkins.plugins.customtools.CustomTool/check/root/usr/local/bin/lcov)
separate_arguments(LCOV_PARAMS UNIX_COMMAND "--capture --directory ./CMakeFiles/mylib.dir --output-file coverage.info")
add_custom_command(
OUTPUT coverage.info
COMMAND ${LCOV} ${LCOV_PARAMS}
DEPENDS tests)
When I run make with VERBOSE=1, I can see that the command is getting wrapped with double quotes, and of course the shell says "No such file or directory":
[100%] Generating coverage.info
"~/tools/com.cloudbees.jenkins.plugins.customtools.CustomTool/check/root/usr/local/bin/lcov" --capture --directory ./CMakeFiles/mylib.dir --output-file coverage.info
/bin/sh: ~/tools/com.cloudbees.jenkins.plugins.customtools.CustomTool/check/root/usr/local/bin/lcov: No such file or directory
When I remove only the tilde from the command, cmake decides that it doesn't need to double quote it anymore. The new lines in CMakeLists.txt:
#set(LCOV ${JENKINS_TOOL_DIR}/check/root/usr/local/bin/lcov)
set(LCOV /tools/com.cloudbees.jenkins.plugins.customtools.CustomTool/check/root/usr/local/bin/lcov)
separate_arguments(LCOV_PARAMS UNIX_COMMAND "--capture --directory ./CMakeFiles/mylib.dir --output-file coverage.info")
add_custom_command(
OUTPUT coverage.info
COMMAND ${LCOV} ${LCOV_PARAMS}
DEPENDS tests)
And the resulting run with VERBOSE=1:
[100%] Generating coverage.info
/tools/com.cloudbees.jenkins.plugins.customtools.CustomTool/check/root/usr/local/bin/lcov --capture --directory ./CMakeFiles/mylib.dir --output-file coverage.info
make[3]: /tools/com.cloudbees.jenkins.plugins.customtools.CustomTool/check/root/usr/local/bin/lcov: Command not found
I can't figure out why cmake is deciding to add quotes for me. I've tried VERBOSE. I've tried putting the command string into add_custom_command (avoiding the set() call). As long as the tilde is there, cmake is smarter, and surrounds my entire command with unwanted double quotes.
How can I execute my command including the tilde without having the string quoted?
Upvotes: 0
Views: 1163
Reputation: 581
Now that I've posted the question I found a solution.
The tilde can be replaced with $ENV{HOME}
.
So my command becomes:
set(LCOV $ENV{HOME}/tools/com.cloudbees.jenkins.plugins.customtools.CustomTool/check/root/usr/local/bin/lcov)
This solved the problem for me.
Upvotes: 2