[CMake] Creating symbolic links

Tyler Roscoe tyler at cryptio.net
Thu Feb 5 11:19:31 EST 2009


On Thu, Feb 05, 2009 at 09:11:10AM -0500, Schrader, Glenn wrote:
> I'm having some trouble with one of my CMakeLists.txt files. What I want to do is to create a symbolic link to a file in another directory if it doesn't already exist. The commands that looked to my like they should work are:
> 
> ADD_CUSTOM_TARGET(run echo "run a test")
> ADD_CUSTOM_COMMAND(OUTPUT myLink COMMAND ln;-s;${OTHERDIR}/myLink;myLink)
> ADD_DEPENDENCIES(run myLink)
> 
> Not only does 'make run' not create a symbolic link, the ln command doesn't show up anywhere in the generated makefiles.

I'm surprised this works at all, since myLink is not a target and
therefore you shouldn't be able to add a dependency on it.

Look in the faq to see the pattern for how to use add_custom_command and
add_custom_target. I think your example above should work if your
add_custom_target looks like:

> ADD_CUSTOM_TARGET(run echo "run a test" DEPENDS myLink)

tyler


More information about the CMake mailing list