[CMake] Changing the default compiler of VC++

Hendrik Sattler post at hendrik-sattler.de
Mon May 4 14:21:06 EDT 2009


Am Montag 04 Mai 2009 16:24:29 schrieb Andreas Pakulat:
> On 04.05.09 16:10:21, Hendrik Sattler wrote:
> > Zitat von Andreas Pakulat <apaku at gmx.de>:
> >> On 04.05.09 17:56:14, ankit jain wrote:
> >>> Thanks Andreas for your reply. I already build the code using mks. now
> >>> i want to build the code using cl/VC++. since it gives lots of errors
> >>> of not founding fiels like strings.h unistd.h
> >>
> >> Then you need to fix those errors, either your environment is
> >> incorrectly setup (make sure to use the Visual studio command prompt
> >> link to get a properly setup command prompt from where you can run
> >> cmake) or the compiler lacks some of these headers. In the latter case
> >> you'll have to adjust your code and use whatever facilities cl provides.
> >> However strings.h and unistd.h are both part of VC++ so I guess its the
> >> broken environment.
> >
> > unistd.h and strings.h are _not_ part of MSVC. They both come with
> > mingw32 and other gcc compile environments for windows but not MSVC.
> > You have to add your own replacement header files for that case or only
> > use them conditionally.
>
> Heh, misread strings.h as string.h and I wasn't aware unistd.h is not part
> of VC as its standard POSIX (and MSVC does have most posix stuff).

Instead of using unistd.h conditionally, you can use the approach I took for 
OpenObex: adding a private include dir that contains the missing file with 
proper defines, see
http://git.kernel.org/?p=bluetooth/openobex.git;a=tree;f=include/msvc

and its usage like:
if (MSVC)
  include_directories (AFTER SYSTEM
    "${CMAKE_CURRENT_SOURCE_DIR}/include/msvc"
  )
endif (MSVC)

Same goes for stdint.h/inttypes.h that are missing with MSVC. You can find good 
ones at googlecode.

HS



More information about the CMake mailing list