[Cmake] compiling and testing CMake with gcc -mno-cygwin
for MinGW
William A. Hoffman
billlist at nycap.rr.com
Wed, 21 Jan 2004 10:48:27 -0500
Try adding this:
export LDFLAGS="-mno-cygwin"
-Bill
At 02:08 PM 1/20/2004, Wheeler, Frederick W (Research) wrote:
>CMake List:
>
>I've been trying to get CMake to build and pass it's tests in Cygwin
>using gcc with the -mno-cygwin option to use the MinGW libraries
>instead of Cygwin. The build works fine now (thanks to recent
>CMakeDetermineCCompiler.cmake change), but some of the tests fail.
>Part of the problem (perhaps all of the problem?) is that the
>-mno-cygwin option is not used everywhere it needs to be during the
>CMake tests.
>
>Here is how I configure and build CMake. Works fine.
>
># use precompiled installed CMake to configure cmake
># configure cannot be used for a MinGW build, only Unix
>"/cygdrive/c/Program Files/CMake/bin/cmake" \
> -G"Unix Makefiles" \
> -DCMAKE_INSTALL_PREFIX:PATH="`cygpath -m $TOP/cmake_usr_min`" \
> -DCMAKE_C_COMPILER:FILEPATH="`cygpath -m /usr/bin/gcc`" \
> -DCMAKE_CXX_COMPILER:FILEPATH="`cygpath -m /usr/bin/g++`" \
> -DCMAKE_C_FLAGS:STRING="-mno-cygwin -Wall -O2 -g" \
> -DCMAKE_CXX_FLAGS:STRING="-mno-cygwin -Wall -O2 -g" \
> "`cygpath -m $TOP/cmake_src`"
>make
>
>If I just do "make test" next I get a lot of console windows
>explaining some illegal instruction error. (Details available.) This
>problem is mostly fixed by these environment settings.
>
>export CC="`cygpath -m /usr/bin/gcc`"
>export CXX="`cygpath -m /usr/bin/g++`"
>export CFLAGS="-mno-cygwin"
>export CXXFLAGS="-mno-cygwin"
>
>With these settings, the tests are using the -mno-cygwin option enough
>to at least avoid the illegal instruction errors. All tests except
>these pass:
>
>The following tests FAILED:
> LoadedCommand
> LoadedCommandOneConfig
> complex
> complexOneConfig
> kwsys
>
>What do these tests have in common?
>
>I dug down into the LoadedCommand test a bit. This snippet should
>show how there is an attempt to link a shared lib without the
>-mno-cygwin option. Note how the lib builds when I manually add the
>-mno-cygwin option.
>
>0% pwd
>/home/200006507/dev/cmake_bld_min/Tests/LoadCommand/CMakeCommands
>0% make
>Building shared module cmCMAKE_TEST_COMMAND.dll...
>cmTestCommand.o(.text+0xb16):cmTestCommand.c: undefined reference to
>`__imp___iob'
>collect2: ld returned 1 exit status
>make[1]: *** [cmCMAKE_TEST_COMMAND.dll] Error 1
>make: *** [default_target] Error 2
>2% make -n cmCMAKE_TEST_COMMAND.dll
>echo "Building shared module cmCMAKE_TEST_COMMAND.dll..."
>C:/cygwin/home/200006507/dev/cmake_bld_min/bin/cmake.exe -E remove -f
>"`pwd`"/cmCMAKE_TEST_COMMAND.dll
>C:/cygwin/bin/gcc.exe -shared -o "`pwd`"/cmCMAKE_TEST_COMMAND.dll
>cmTestCommand.o
>0% C:/cygwin/bin/gcc.exe -mno-cygwin -shared -o
>"`pwd`"/cmCMAKE_TEST_COMMAND.dll cmTestCommand.o
>0% ls cmCMAKE_TEST_COMMAND.dll
>cmCMAKE_TEST_COMMAND.dll
>0%
>
>I don't yet know how to fix this and I don't know whether it is worth
>fixing. If anyone has any suggestions I will try them. I want to at
>least post what I have found.
>
>It seems to me that the basic problem is that -mno-cygwin is a special
>kind of critical option that essentially specifies which compiler you
>are using. I need a way to tell the tests that they must always use
>this option in addition to whatever other options they ordinarily wish
>to use for gcc. Besides the environment variables CC, CXX, CFLAGS and
>CXXFLAGS I do not see any other way to pass compiler arguments down to
>the CMake tests. CMAKE_C_COMPILER and CMAKE_CXX_COMPILER cannot have
>this option tacked on. (I forget exactly what happens, but recall
>this not working.) The CMAKE_*_FLAGS options used for building CMake
>are not necessarily used by the tests, for good reason - so that is
>not an avenue.
>
>Comments or suggestions welcome.
>
>Fred Wheeler
>_______________________________________________
>Cmake mailing list
>Cmake at www.cmake.org
>http://www.cmake.org/mailman/listinfo/cmake