[CMake] cmake -E create_symlink for Windows CMake Digest, Vol 68, Issue 51

Samuel E. Henley sehenley at comcast.net
Mon Dec 14 09:38:02 EST 2009


I think there should be a cross platform command for creating symbolic
links, under windows 2000 and above with the ntfs formatted disk. You
can create symbolic links to directories with a program called
“junction” (Vista has a build-in command) - junction has switches that
would simulate the Linux version of ln -s. Of course in Windows it's a
real link to the directory and if you delete/copy the files you get the
results you would expect – files are deleted or copied – not links. You
could get around this by getting a directory listing under windows –
which does show junctions – and use the junction program to make the
copies. Of course all the file commands in windows would have to check
for this property because CMake itself has adopted the Linux version of
a file system for its cross-platform commands.

The objection that CMake would now have to find and run an external
program – doesn't have much weight because cmake does this all the time,
It finds the compiler, linker, resource compiler etc. If that is not an
acceptable method to implement the command – then a built-in version of
junction could be created – In CTest you should take a look at the
platform-dependent code to determine if a windows machine can run
multi-CPU threads. – a built-in version of symbolic links would not
generate any more or obscure platform-dependent code then that test
whose only purpose is to fill a form for CDash. As for the problem at
hand you could create a MACRO that uses cmake -E under Linux and
junction under windows.
   Samuel E. Henley OSRail.net


On Mon, 2009-12-14 at 06:00 -0500, cmake-request at cmake.org wrote:
> Send CMake mailing list submissions to
> 	cmake at cmake.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://www.cmake.org/mailman/listinfo/cmake
> or, via email, send a message with subject or body 'help' to
> 	cmake-request at cmake.org
> 
> You can reach the person managing the list at
> 	cmake-owne

> r at cmake.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of CMake digest..."
> 
> 
> Today's Topics:
> 
>    1. Re: Mac OSX GUI (Bill Hoffman)
>    2. Re: cmake -E create_symlink for Windows (Marcel Loose)
>    3. Re: Mac OSX GUI (Steven Wilson)
>    4. Re: Mac OSX GUI (Mike Jackson)
>    5. Re: cmake -E create_symlink for Windows (Marcel Loose)
>    6. Re: ADD_CUSTOM_COMMAND (Keyan)
>    7. How to generate xcodeproj file correctly for Xcode? (DONG Li)
> 
> 
> Message: 2
> Date: Sun, 13 Dec 2009 23:38:18 +0100
> From: Marcel Loose <loose at astron.nl>
> Subject: Re: [CMake] cmake -E create_symlink for Windows
> To: "Alan W. Irwin" <irwin at beluga.phys.uvic.ca>
> Cc: cmake at cmake.org, Michael Wild <themiwi at gmail.com>,	Bill Hoffman
> 	<bill.hoffman at kitware.com>
> Message-ID: <1260743898.18575.13.camel at galadriel>
> Content-Type: text/plain; charset="UTF-8"
> 
> On Sat, 2009-12-12 at 14:35 -0800, Alan W. Irwin wrote:
> > On 2009-12-12 12:02-0500 Bill Hoffman wrote:
> > 
> > > Some things just can not be done cross platform.   For example reading/ 
> > > writing the windows registry, creating an OSX application bundle, and 
> > > sym-links.  Also, some computers don't even have shared libraries. Should we 
> > > disable those features from CMake?  That said, the symlink command is the 
> > > only -E that does not work cross platform.   The -E create_symlink does 
> > > return failure from main when called on windows. So, if you used it in a 
> > > custom command which is the idea for -E stuff, it would fail in a noticeable 
> > > way (the build would fail).  If you call it from execute_process, you should 
> > > be checking the return value as well.
> > 
> > I guess I am the victim of the assumption that all cmake -E commands are
> > supposed to work cross-platform since all of them do so (which I was glad to
> > hear) other than create_symlink.  Right now, here is what cmake -E help says
> > about that command.
> > 
> >    create_symlink old new    - create a symbolic link new -> old
> > 
> > If you simply added (UNIX ONLY) to that documentation string, then users
> > like me wouldn't make unwarranted assumptions.
> > 
> > Alan
> > __________________________
> > Alan W. Irwin
> > 
> > Astronomical research affiliation with Department of Physics and Astronomy,
> > University of Victoria (astrowww.phys.uvic.ca).
> > 
> > Programming affiliations with the FreeEOS equation-of-state implementation
> > for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
> > package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
> > Linux Links project (loll.sf.net); and the Linux Brochure Project
> > (lbproject.sf.net).
> > __________________________
> > 
> > Linux-powered Science
> > __________________________
> 
> I second that. I was also under the impression that 'cmake -E' provided
> a nice abstraction for a number of commands that could be used
> cross-platform, but with different syntaxes. Seems that create_symlink
> is the odd one out here. Bummer!
> 
> The thing is: it's too late when the build fails (on Windows), because
> long before then, I, as a developer of the build environment, decided to
> use the presumed cross-platform command create_symlink, only to find out
> much later that it doesn't work on Windows.
> 
> Best regards,
> Marcel Loose.
> 
> 
> 
> 




More information about the CMake mailing list