[Cmake] CMake variable MINGW

Wheeler, Frederick W (Research) wheeler at crd.ge.com
Thu, 8 Jan 2004 18:05:54 -0500


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)