[cmake-developers] Custom commands with Ninja on Windows

Martin Ankerl martin.ankerl at gmail.com
Fri May 20 03:56:05 EDT 2016


sorry, that DEP_FILE problem was my fault. It's working correctly.

Martin

On Fri, May 20, 2016 at 9:41 AM Martin Ankerl <martin.ankerl at gmail.com>
wrote:

> From what I have understood it seems more safe to use .bat and not .cmd,
> because the behavior of the errorlevel is different. From
> http://waynes-world-it.blogspot.co.at/2008/08/difference-between-bat-and-cmd.html
> :
>
> > The differences between .CMD and .BAT as far as CMD.EXE is concerned
> are: With extensions enabled, PATH/APPEND/PROMPT/SET/ASSOC in .CMD files
> will set
> ERRORLEVEL regardless of error. .BAT sets ERRORLEVEL only on errors.
>
> I've created a first attempt of this implementation, please see the
> attached patch. It seems to do the trick for my test case, but I couldn't
> test it well because unfortunately I've run into a different unrelated
> problem: the slashes for the DEP_FILE are in the git version / instead of \
> which makes the ninja build fail. This was not the case with version 3.5.2
>
> Martin
>
>
>
> On Thu, May 19, 2016 at 10:46 PM Brad King <brad.king at kitware.com> wrote:
>
>> On 05/19/2016 04:31 PM, Martin Ankerl wrote:
>> > I didn't think about just writing a .cmd (or .bat?) with cmake
>>
>> The ".cmd" extension is a modern version of ".bat".
>>
>> > that sounds like the simplest solution!
>>
>> Yes, assuming we never have a need for ninja placeholder substitution.
>> Why are one-line response files generated by Ninja not a solution?
>> Does cmd support them?
>>
>> > if %errorlevel% neq 0 exit /b %errorlevel%
>>
>> Yes.
>>
>> > I have no experience with cmake implementation though, how would you
>> > find a name for the filename?
>>
>> First, it can be made conditional on when the command line is really long.
>> Second, you could just put it in CMakeFiles/ and name it using a hash
>> of its content (or of the list of outputs).  See Source/cmCryptoHash.h
>> for example.
>>
>> Thanks,
>> -Brad
>>
>> --
> Martin
>
-- 
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160520/770b7f85/attachment.html>


More information about the cmake-developers mailing list