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

Brad King brad.king at kitware.com
Tue Nov 22 11:49:46 EST 2005


Brandon J. Van Every wrote:
> 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".

CMake 2.0 used to use /usr/local as the default prefix even on Windows. 
  This was fixed for CMake 2.2 to be a more windows-like path.  We 
should improve the fix to work with MSys, though.  Please submit a bug 
report here:

http://www.cmake.org/Bug

> Does a similar issue pertain to Cygwin?  Maybe not, as the archives 
> seemed to indicate that it may use /usr/local by default.

No, because CMake builds natively under cygwin as a cygwin program. 
Separate CMake builds must be used for Windows and Cygwin, but the same 
CMake build can be used for Windows and MinGW/MSYS.

> 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)

That looks fine to me.  Please include it in the bug report.  It doesn't 
matter if OSTYPE is set on other platforms or not.  As long as it is set 
for msys then it can be used to detect msys.

-Brad


More information about the CMake mailing list