[CMake] MSVC variable doesn't work without project() call first

Robert Dailey rcdailey at gmail.com
Tue Nov 1 12:18:44 EDT 2011


On Tue, Nov 1, 2011 at 10:43 AM, David Cole <david.cole at kitware.com> wrote:

> On Tue, Nov 1, 2011 at 11:22 AM, Alexander Neundorf
> <a.neundorf-work at gmx.net> wrote:
> > On Tuesday 01 November 2011, Robert Dailey wrote:
> >> For some reason the built in variable like MSVC_VERSION and MSVC do not
> >> have any value unless the project() command is called first. Can someone
> >> explain why?
> >
> > Without checking...
> > IIRC, the project() call enables by default the C and the CXX languages
> (if
> > that hasn't been done before explicitely).
> > During enabling the languages the compilers are detected, and with them
> those
> > variables are set.
> > So, before that no languages are known to cmake, so these variables are
> not
> > set.
> >
> > Alex
> > --
> >
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.cmake.org/mailman/listinfo/cmake
> >
>
> Alex is right.
>
> If you need the value of MSVC *before* calling the project command for
> some reason, then you can call enable_language(C) (or CXX) instead...


I don't need MSVC checking before project() in my case, they just seemed
unrelated so I wanted to check for educational purposes :)

Thanks guys.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111101/53b0d2d5/attachment.htm>


More information about the CMake mailing list