[Cmake] CMake variable MINGW

Wheeler, Frederick W (Research) wheeler at crd.ge.com
Fri, 9 Jan 2004 09:35:36 -0500


Bill,

I just tried adding the flags and it works.  You can see the change I made
below.  I added the "${CMAKE_C_FLAGS}".  (I also added some temporary
MESSAGE commands.)  Now, when I use the -mno-cygwin option to gcc, CMake var
MINGW gets set and CMake var CYGWIN is not set, as desired.

Fred Wheeler


# test to see if the c compiler is gnu
EXEC_PROGRAM(${CMAKE_C_COMPILER} ARGS ${CMAKE_C_FLAGS} -E
"\"${CMAKE_ROOT}/Modu\
les/CMakeTestGNU.c\"" OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT RETURN_VALUE
CMAKE_\
COMPILER_RETURN)
MESSAGE(FOO START)
MESSAGE(${CMAKE_COMPILER_OUTPUT})
MESSAGE(FOO END)
IF(NOT CMAKE_COMPILER_RETURN)
  IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" )
    SET(CMAKE_COMPILER_IS_GNUCC 1)
    FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log
      "Determining if the C compiler is GNU succeeded with "
      "the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n")
  ELSE("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" )
    FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log
      "Determining if the C compiler is GNU failed with "
      "the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n")
  ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" )
  IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_MINGW.*" )
    SET(CMAKE_COMPILER_IS_MINGW 1)
    MESSAGE(SETTING CMAKE_COMPILER_IS_MINGW)
  ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_MINGW.*" )
  IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_CYGWIN.*" )
    SET(CMAKE_COMPILER_IS_CYGWIN 1)
  ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_CYGWIN.*" )

ENDIF(NOT CMAKE_COMPILER_RETURN)



> -----Original Message-----
> From: William A. Hoffman [mailto:billlist at nycap.rr.com]
> Sent: Friday, January 09, 2004 7:58 AM
> To: Wheeler, Frederick W (Research); CMake List (E-mail)
> Subject: Re: [Cmake] CMake variable MINGW
> 
> 
> I guess I had not thought of cygwin gcc being used as a MinGW 
> compiler.
> I figured MinGW was MinGW using MSYS and the gcc from there.
> I guess the cxx flags could be added to the EXEC_PROGRAM.  Did you try
> that?  Does it work?
> 
> -Bill
> 
> 
> 
> 
> At 06:05 PM 1/8/2004, Wheeler, Frederick W (Research) wrote:
> >I am trying to get VXL to compile with MinGW, using gcc with 
> the -mno-cygwin
> >option, run from cygwin.  The test for MinGW in
> >CMakeDetermineCCompiler.cmake runs the C compiler without 
> the command line
> >options (I think).  I pasted the relevant section of
> >CMakeDetermineCCompiler.cmake below.  In my situation, the compiler
> >arguments are needed for it to act like a MinGW compiler.
> >
> >Should CMakeDetermineCCompiler.cmake use the given args to 
> the C compiler?
> >
> >Is there some other way I should be doing this with CMake?
> >
> >Is there a shortcut I can take right away?  Notice I tried 
> -DMINGW:BOOL=1
> >below.  That does not seem to alter the setting of the CMake 
> built-in MINGW
> >variable.
> >
> >Thanks,
> >Fred Wheeler
> >
> >
> >mkdir -p $TOP/vxl_bld_min
> >rm -f $TOP/vxl_bld_min/CMakeCache.txt
> >cd $TOP/vxl_bld_min
> ># use the windows version of cmake, but make Unix Makefiles
> >"/cygdrive/c/Program Files/CMake/bin/cmake" \
> >  -G"Unix Makefiles" \
> >  -DCMAKE_INSTALL_PREFIX:PATH="`cygpath -w $TOP/vxl_usr_min`" \
> >  -DCMAKE_C_COMPILER:FILEPATH="`cygpath -w /usr/bin/gcc`" \
> >  -DCMAKE_CXX_COMPILER:FILEPATH="`cygpath -w /usr/bin/g++`" \
> >  -DCMAKE_C_LINK_SHARED:FILEPATH="`cygpath -w /usr/bin/gcc`" \
> >  -DCMAKE_CXX_LINK_SHARED:FILEPATH="`cygpath -w /usr/bin/g++`" \
> >  -DMINGW:BOOL=1 \
> >  -DCMAKE_C_FLAGS:STRING="-Wall -g -O0 -mno-cygwin" \
> >  -DCMAKE_CXX_FLAGS:STRING="-Wall -g -O0 -mno-cygwin" \
> >  -DX11_X11_INCLUDE_PATH:PATH=IGNORE \
> >  -DVXL_FORCE_V3P_ZLIB:BOOL=YES \
> >  -DVXL_FORCE_V3P_PNG:BOOL=YES \
> >  -DVXL_FORCE_V3P_JPEG:BOOL=YES \
> >  -DVXL_FORCE_V3P_MPEG2:BOOL=YES \
> >  -DVXL_FORCE_V3P_TIFF:BOOL=YES \
> >  -DBUILD_VGUI:BOOL=NO \
> >  -DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF \
> >  "`cygpath -w $TOP/vxl_src`"
> >
> >
> >Relevant section of CMakeDetermineCCompiler.cmake
> >
> ># test to see if the c compiler is gnu
> >EXEC_PROGRAM(${CMAKE_C_COMPILER} ARGS -E
> >"\"${CMAKE_ROOT}/Modules/CMakeTestGNU.c\"" OUTPUT_VARIABLE
> >CMAKE_COMPILER_OUTPUT RETURN_VALUE CMAKE_COMPILER_RETURN)
> >IF(NOT CMAKE_COMPILER_RETURN)
> >  IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" )
> >    SET(CMAKE_COMPILER_IS_GNUCC 1)
> >    FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log
> >      "Determining if the C compiler is GNU succeeded with "
> >      "the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n")
> >  ELSE("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" )
> >    FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log
> >      "Determining if the C compiler is GNU failed with "
> >      "the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n")
> >  ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" )
> >  IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_MINGW.*" )
> >    SET(CMAKE_COMPILER_IS_MINGW 1)
> >  ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_MINGW.*" )
> >  IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_CYGWIN.*" )
> >    SET(CMAKE_COMPILER_IS_CYGWIN 1)
> >  ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_CYGWIN.*" )
> >
> >ENDIF(NOT CMAKE_COMPILER_RETURN)
> >_______________________________________________
> >Cmake mailing list
> >Cmake at www.cmake.org
> >http://www.cmake.org/mailman/listinfo/cmake 
>