[CMake] Detecting MinGW MSYS or Cygwin unix style file system

Brandon J. Van Every bvanevery at gmail.com
Tue Nov 22 09:35:19 EST 2005


Hi, I'm going up the CMake Windows learning curve on behalf of Chicken 
Scheme.
http://www.call-with-current-continuation.org/index.html
I have read the archives quite a bit and I think it's time to ask the 
question.

I notice that on Windows the default CMAKE_INSTALL_PREFIX is "C:/Program 
Files".  However, this doesn't actually make sense to a MinGW user 
employing MSYS.  MSYS implements a unix-style file system, so a proper 
prefix would more likely be "/usr/local".  However, the wrinkle is it's 
also perfectly legitimate to use MinGW sans MSYS, and install things to 
"C:/Program Files" in the normal Windows way.  It's really MSYS that's 
the dependency here, not MinGW.  And so, I would like to detect MSYS and 
"do the right thing" for people who are using Windows as a Unix-alike.  
Not because I love Unix, but because I want to keep my MSYS and "normal 
Windows" environments completely separate from each other.  When people 
try out Chicken, I want to be able to ask "are you using the MinGW, the 
Cygwin, or the VC++ build?" and not have there be any confusion about 
what got installed where.

Does a similar issue pertain to Cygwin?  Maybe not, as the archives 
seemed to indicate that it may use /usr/local by default.  I am not 
wishing to try this out if I can avoid it.  :-)  Aside from being highly 
biased towards MinGW support issues, it happens that Eclipse gets messed 
up if both are on one's system.

Gleaning knowledge from the archives, I have created a PreLoad.cmake 
which successfully detects MSYS.  My understanding is that this command 
must be in PreLoad.cmake, that it cannot just be in CMakeLists.txt, as 
it must be set before anything else happens.  Correct?

IF(WIN32)
  IF("$ENV{OSTYPE}" STREQUAL "msys")
     SET(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH
         "MSYS default install path")
  ENDIF("$ENV{OSTYPE}" STREQUAL "msys")
ENDIF(WIN32)

I am wondering if CMake has its own, native, more reliable way of doing 
this.  If it doesn't, I'm thinking it should, because MinGW and MSYS are 
like bread and butter, even if bread can be eaten without butter.  :-)  
I am also wondering if anyone knows if OSTYPE is a reliable indicator.  
I just looked at what was in the environment and figured, heh, this 
looks like it'll work.


Cheers,
Brandon Van Every
"The pioneer is the one with the arrows in his back."
                          - anonymous entrepreneur


More information about the CMake mailing list