[CMake] CMake needs tmp directory manually created for GCC to work

michael kapelko kornerr at gmail.com
Tue Apr 5 01:30:48 EDT 2011


Hello.
I'm using Cygwin as a shell, and MinGW as a compiler. I'm experiencing a 
weird build problem with CMake.

Steps to reproduce the problem.
1. Install Cygwin with standard packages.
2. Download and unpack the following MinGW archives into C:/MinGW:
- [binutils-2.21-2-mingw32-bin.tar.lzma 
http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GNU-Binutils/binutils-2.21/binutils-2.21-2-mingw32-bin.tar.lzma/download]
- [gcc-c++-4.5.2-1-mingw32-bin.tar.lzma 
http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GCC/Version4/gcc-4.5.2-1/gcc-c%2B%2B-4.5.2-1-mingw32-bin.tar.lzma/download]
- [gcc-core-4.5.2-1-mingw32-bin.tar.lzma 
http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GCC/Version4/gcc-4.5.2-1/gcc-core-4.5.2-1-mingw32-bin.tar.lzma/download]
- [libexpat-2.0.1-1-mingw32-dll-1.tar.gz 
http://sourceforge.net/projects/mingw/files/MinGW/expat/expat-2.0.1-1/libexpat-2.0.1-1-mingw32-dll-1.tar.gz/download]
- [libgcc-4.5.2-1-mingw32-dll-1.tar.lzma 
http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GCC/Version4/gcc-4.5.2-1/libgcc-4.5.2-1-mingw32-dll-1.tar.lzma/download]
- [libgmp-5.0.1-1-mingw32-dll-10.tar.lzma 
http://sourceforge.net/projects/mingw/files/MinGW/gmp/gmp-5.0.1-1/libgmp-5.0.1-1-mingw32-dll-10.tar.lzma/download]
- [libiconv-1.13.1-1-mingw32-dll-2.tar.lzma 
http://sourceforge.net/projects/mingw/files/MinGW/libiconv/libiconv-1.13.1-1/libiconv-1.13.1-1-mingw32-dll-2.tar.lzma/download]
- [libintl-0.17-1-mingw32-dll-8.tar.lzma 
http://sourceforge.net/projects/mingw/files/MinGW/gettext/gettext-0.17-1/libintl-0.17-1-mingw32-dll-8.tar.lzma/download]
- [libmpc-0.8.1-1-mingw32-dll-2.tar.lzma 
http://sourceforge.net/projects/mingw/files/MinGW/mpc/mpc-0.8.1-1/libmpc-0.8.1-1-mingw32-dll-2.tar.lzma/download]
- [libmpfr-2.4.1-1-mingw32-dll-1.tar.lzma 
http://sourceforge.net/projects/mingw/files/MinGW/mpfr/mpfr-2.4.1-1/libmpfr-2.4.1-1-mingw32-dll-1.tar.lzma/download]
- [libpthread-2.8.0-3-mingw32-dll-2.tar.lzma 
http://sourceforge.net/projects/mingw/files/MinGW/pthreads-w32/pthreads-w32-2.8.0-3/libpthread-2.8.0-3-mingw32-dll-2.tar.lzma/download]
- [libstdc++-4.5.2-1-mingw32-dll-6.tar.lzma 
http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GCC/Version4/gcc-4.5.2-1/libstdc%2B%2B-4.5.2-1-mingw32-dll-6.tar.lzma/download]
- [make-3.82-5-mingw32-bin.tar.lzma 
http://sourceforge.net/projects/mingw/files/MinGW/make/make-3.82-mingw32/make-3.82-5-mingw32-bin.tar.lzma/download]
- [mingwrt-3.18-mingw32-dev.tar.gz 
http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/RuntimeLibrary/MinGW-RT/mingwrt-3.18/mingwrt-3.18-mingw32-dev.tar.gz/download]
- [mingwrt-3.18-mingw32-dll.tar.gz 
http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/RuntimeLibrary/MinGW-RT/mingwrt-3.18/mingwrt-3.18-mingw32-dll.tar.gz/download]
- [w32api-3.15-1-mingw32-dev.tar.lzma 
http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/RuntimeLibrary/Win32-API/w32api-3.15/w32api-3.15-1-mingw32-dev.tar.lzma/download]
e.g. with this script:

#!/bin/sh
# MinGW setup script
SRCNAM=mingw
MINGW=C:/MinGW
mkdir -p $MINGW
for file in $(ls $SRCNAM/*tar*); do
     echo "Extracting $file to $MINGW";
     tar -xf $file -C $MINGW
done;
cp $MINGW/bin/mingw32-make.exe $MINGW/bin/make.exe

3. Restart Cygwin shell.
4. Download 
http://sourceforge.net/projects/pcre/files/pcre/8.12/pcre-8.12.tar.bz2/download 
into a directory, and put the following script into the same directory:

#!/bin/sh
# MinGW build script for PCRE
SRCNAM=pcre
VERSION=8.12
MINGW=C:/MinGW
TMP=tmp
rm -rf $TMP
mkdir -p $TMP/{src,build}
tar -xf $SRCNAM-$VERSION.tar.bz2 -C $TMP/src
cd $TMP/build
# Exclude sh.exe from PATH so that CMake doesn't complain.
OLD_PATH="$PATH"
export PATH=$(echo $PATH | sed -e "s/:\/bin:/:/g" | sed -e 
"s/:\/usr\/bin:/:/g")
cmake -G "MinGW Makefiles" ../src/$SRCNAM-$VERSION
# Return previous PATH value back.
export PATH="$OLD_PATH"

Run it from Cygwin shell, and see:



Administrator at root-9aad2f026d /cygdrive/c/build/PCRE
$ ./pcre.MinGWBuild
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files/CMake 
2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
   The C compiler "C:/MinGW/bin/gcc.exe" is not able to compile a simple 
test  program.

   It fails with the following output:

    Change Dir: C:/build/PCRE/tmp/build/CMakeFiles/CMakeTmp

   Run Build Command:C:/MinGW/bin/mingw32-make.exe "cmTryCompileExec/fast"

   C:/MinGW/bin/mingw32-make.exe -f 
CMakeFiles\cmTryCompileExec.dir\build.make
   CMakeFiles/cmTryCompileExec.dir/build

   mingw32-make.exe[1]: Entering directory
   `C:/build/PCRE/tmp/build/CMakeFiles/CMakeTmp'

   "C:\Program Files\CMake 2.8\bin\cmake.exe" -E cmake_progress_report
   C:\build\PCRE\tmp\build\CMakeFiles\CMakeTmp\CMakeFiles 1

   Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj

   C:\MinGW\bin\gcc.exe -o 
CMakeFiles\cmTryCompileExec.dir\testCCompiler.c.obj
   -c C:\build\PCRE\tmp\build\CMakeFiles\CMakeTmp\testCCompiler.c

   This application has requested the Runtime to terminate it in an unusual
   way.

   Please contact the application's support team for more information.

   mingw32-make.exe[1]: ***
   [CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj] Error 3

   mingw32-make.exe[1]: Leaving directory
   `C:/build/PCRE/tmp/build/CMakeFiles/CMakeTmp'

   mingw32-make.exe: *** [cmTryCompileExec/fast] Error 2

   CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
   CMakeLists.txt:41 (PROJECT)

-- Configuring incomplete, errors occurred!







However, if the line in the script is changed from
   mkdir -p $TMP/{src,build}
to
   mkdir -p $TMP/{src,build/tmp}
i.e. tmp directory is created in the directory cmake.exe is issued, we 
get correct behaviour:

Administrator at root-9aad2f026d /cygdrive/c/build/PCRE
$ ./pcre.MinGWBuild
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Could NOT find BZip2 (missing:  BZIP2_LIBRARIES BZIP2_INCLUDE_DIR)
-- Could NOT find ZLIB (missing:  ZLIB_INCLUDE_DIR ZLIB_LIBRARY)
-- Could not find OPTIONAL package Readline
-- Looking for dirent.h
-- Looking for dirent.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for windows.h
-- Looking for windows.h - found
-- Looking for C++ include type_traits.h
-- Looking for C++ include type_traits.h - not found
-- Looking for C++ include bits/type_traits.h
-- Looking for C++ include bits/type_traits.h - not found
-- Looking for bcopy
-- Looking for bcopy - not found
-- Looking for memmove
-- Looking for memmove - found
-- Looking for strerror
-- Looking for strerror - found
-- Looking for strtoll
-- Looking for strtoll - found
-- Looking for strtoq
-- Looking for strtoq - not found
-- Looking for _strtoi64
-- Looking for _strtoi64 - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of long long
-- Check size of long long - done
-- Check size of unsigned long long
-- Check size of unsigned long long - done
--
--
-- PCRE configuration summary:
--
--   Install prefix .................. : C:/Program Files/PCRE
--   C compiler ...................... : C:/MinGW/bin/gcc.exe
--   C++ compiler .................... : C:/MinGW/bin/g++.exe
--   C compiler flags ................ :
--   C++ compiler flags .............. :
--
--   Build C++ library ............... : ON
$
--   Unicode properties .............. : OFF
--   Newline char/sequence ........... : LF
--   \R matches only ANYCRLF ......... : OFF
--   EBCDIC coding ................... : OFF
--   Rebuild char tables ............. : OFF
--   No stack recursion .............. : OFF
--   POSIX mem threshold ............. : 10
--   Internal link size .............. : 2
--   Match limit ..................... : 10000000
--   Match limit recursion ........... : MATCH_LIMIT
--   Build shared libs ............... : OFF
--   Build static libs ............... : ON
--   Build pcregrep .................. : ON
--   Build tests (implies pcretest) .. : ON
--   Link pcregrep with libz ......... : None
--   Link pcregrep with libbz2 ....... : None
--   Link pcretest with libreadline .. : None
--
-- Configuring done
-- Generating done
-- Build files have been written to: C:/build/PCRE/tmp/build


I can see cmake creates some auxiliary bat files during its run. But why 
do I need to create tmp directory manually? Is this OK?
Thanks.


More information about the CMake mailing list