MantisBT - CMake
View Issue Details
0013001CMakeCMakepublic2012-02-28 02:052012-09-03 16:00
renes 
Brad King 
normalfeaturealways
closedfixed 
64-bitWindows7
CMake 2.8.7 
CMake 2.8.8CMake 2.8.8 
0013001: Compiling CMake with gcc under MinGW-64/MSYS on 64-bit Windows
Changes (see attached patch):

(1) Added code to read HOME environment variable (to get MSYS root) and read /etc/fstab (to get MinGw-64 path and other fstab entries) to map MSYS paths to Windows paths.

(2) Added calls to "ConvertToOutputPath" where Windows API file system calls are made.

(3) Minor changes to handle MinGw-64 C library differences from MinGw.

(4) There are still a few test failures. Some of the MSYS tools do not handle the Windows paths with forward slashes generated by CMake. For paths used as arguments to MSYS programs, there needs to be a way in CMake files to request returning an MSYS path (e.g. /C/foo) instead of a Windows path with forward slashes (e.g. C:/foo).

Example:

Fails:

cd /C/work/sources/cmake-2.8.7/Tests/ExternalProject/CMakeExternals/Source && /C/msys/bin/cvs.exe -d C:/work/sources/cmake-2.8.7/Tests/ExternalProject/LocalRepositories/CVS -q co "-D2009-06-26 16:50:00 UTC" -d TutorialStep1-CVS-20090626 TutorialStep1

Works:

cd /C/work/sources/cmake-2.8.7/Tests/ExternalProject/CMakeExternals/Source && /C/msys/bin/cvs.exe -d /C/work/sources/cmake-2.8.7/Tests/ExternalProject/LocalRepositories/CVS -q co "-D2009-06-26 16:50:00 UTC" -d TutorialStep1-CVS-20090626 TutorialStep1


The following tests FAILED:
         25 - FindPackageTest (Failed)
         99 - ExternalProject (Failed)
        132 - CTest.UpdateSVN (Failed)
        133 - CTest.UpdateCVS (Failed)
        134 - CTest.UpdateHG (Failed)

(5) Since MinGW-64 can be used on Linux to cross-compile for Windows, these changes need to be tested there as well.
No tags attached.
patch cmake-2.8.7-mingw.patch (46,089) 2012-02-28 02:05
https://public.kitware.com/Bug/file/4235/cmake-2.8.7-mingw.patch
patch cmake-2.8.7-mingw-w64.patch (13,015) 2012-02-29 01:59
https://public.kitware.com/Bug/file/4236/cmake-2.8.7-mingw-w64.patch
log CMakeError.log (466,732) 2012-02-29 17:20
https://public.kitware.com/Bug/file/4240/CMakeError.log
patch cmake-2.8.7-mingw-w64-updated.patch (11,364) 2012-02-29 17:21
https://public.kitware.com/Bug/file/4241/cmake-2.8.7-mingw-w64-updated.patch
log CMakeError-with-patches.log (550,619) 2012-03-01 18:51
https://public.kitware.com/Bug/file/4243/CMakeError-with-patches.log
patch cmake-2.8.7-mingw-w64-update2.patch (2,623) 2012-03-02 07:37
https://public.kitware.com/Bug/file/4245/cmake-2.8.7-mingw-w64-update2.patch
txt FindPackageTestFiles.txt (11,378) 2012-03-02 16:34
https://public.kitware.com/Bug/file/4247/FindPackageTestFiles.txt
Issue History
2012-02-28 02:05renesNew Issue
2012-02-28 02:05renesFile Added: cmake-2.8.7-mingw.patch
2012-02-28 13:08Brad KingNote Added: 0028730
2012-02-28 13:39renesNote Added: 0028731
2012-02-28 13:53Brad KingNote Added: 0028732
2012-02-28 13:59renesNote Added: 0028733
2012-02-28 14:12Brad KingNote Added: 0028735
2012-02-28 14:25renesNote Added: 0028736
2012-02-28 14:42Brad KingNote Added: 0028737
2012-02-28 15:18renesNote Added: 0028739
2012-02-28 15:25Brad KingNote Added: 0028740
2012-02-28 16:04renesNote Added: 0028742
2012-02-28 17:00Brad KingNote Added: 0028743
2012-02-29 01:59renesFile Added: cmake-2.8.7-mingw-w64.patch
2012-02-29 02:11renesNote Added: 0028748
2012-02-29 14:39Brad KingNote Added: 0028759
2012-02-29 14:41Brad KingNote Added: 0028760
2012-02-29 14:46Brad KingNote Added: 0028761
2012-02-29 17:20renesFile Added: CMakeError.log
2012-02-29 17:21renesFile Added: cmake-2.8.7-mingw-w64-updated.patch
2012-02-29 17:25renesNote Added: 0028764
2012-03-01 10:47Brad KingNote Added: 0028772
2012-03-01 11:00Brad KingNote Added: 0028773
2012-03-01 11:25Brad KingNote Added: 0028774
2012-03-01 18:51renesFile Added: CMakeError-with-patches.log
2012-03-01 18:57renesNote Added: 0028777
2012-03-01 20:03renesNote Added: 0028779
2012-03-02 07:37renesFile Added: cmake-2.8.7-mingw-w64-update2.patch
2012-03-02 07:38renesNote Added: 0028783
2012-03-02 08:14Brad KingNote Added: 0028784
2012-03-02 08:24Brad KingNote Added: 0028785
2012-03-02 08:28Brad KingNote Added: 0028786
2012-03-02 08:39renesNote Added: 0028787
2012-03-02 08:45Brad KingNote Added: 0028788
2012-03-02 10:05renesNote Added: 0028790
2012-03-02 13:12Brad KingNote Added: 0028796
2012-03-02 15:35Brad KingNote Added: 0028797
2012-03-02 15:36Brad KingAssigned To => Brad King
2012-03-02 15:36Brad KingStatusnew => assigned
2012-03-02 15:36Brad KingTarget Version => CMake 2.8.8
2012-03-02 16:34renesFile Added: FindPackageTestFiles.txt
2012-03-02 16:48renesNote Added: 0028799
2012-03-02 17:06Brad KingNote Added: 0028800
2012-03-02 23:48renesNote Added: 0028801
2012-03-05 09:44Brad KingNote Added: 0028808
2012-03-06 05:48renesNote Added: 0028810
2012-03-06 08:23Brad KingNote Added: 0028811
2012-03-06 09:41renesNote Added: 0028841
2012-03-06 10:51Brad KingNote Added: 0028843
2012-03-06 10:51Brad KingStatusassigned => resolved
2012-03-06 10:51Brad KingFixed in Version => CMake 2.8.8
2012-03-06 10:51Brad KingResolutionopen => fixed
2012-09-03 16:00David ColeNote Added: 0030828
2012-09-03 16:00David ColeStatusresolved => closed

Notes
(0028730)
Brad King   
2012-02-28 13:08   
Thanks for working on this, but I wish you'd come to the mailing list first for help before starting all this effort.

CMake already works on 64-bit MinGW at an MSYS prompt. Just like every other Makefile generator one is required to launch CMake from a command prompt with the proper environment already configured.

There is no need to ConvertToOutputPath before passing paths to system file handling APIs. They all understand forward slashes as required by POSIX. ConvertToOutputPath is meant for use by generators writing paths into shell command lines.
(0028731)
renes   
2012-02-28 13:39   
It doesn't work running 64-bit MinGW on Windows.

On Windows, compiling and running CMake under MSYS and 64-bit MinGW, files are being installed under C:\C without the changes.

It is the same reason there is code in CMake for Cygwin to do the same translation of paths.

/cygdrive/c -> c:\

/c/ -> c:\
(0028732)
Brad King   
2012-02-28 13:53   
I've built and run CMake with 64-bit MinGW tools using both the "MSYS Makefiles" generator and the "MinGW Makefiles" generator.

Please provide a more detailed explanation of your environment.

At what path is CMake installed?

At what prompt are you launching CMake? With what arguments? What is in the PATH at that prompt?
(0028733)
renes   
2012-02-28 13:59   
I am running Windows 7 (64-bit) with the following mingw-w64 build and MSYS:

http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/4.7.0-1/ [^]

http://sourceforge.net/projects/mingw-w64/files/Toolchain%20sources/Personal%20Builds/rubenvb/ [^]


Compiling CMake using the following running the bash shell from MSYS:

./configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=$(cd ../install && pwd)

make

make test

make install
(0028735)
Brad King   
2012-02-28 14:12   
The "configure" script is really just an alias for the "bootstrap" script. Bootstrap is known to work under at least 32-bit MSYS prompts, and the case is covered by our nightly testing.

What is the output of "uname" at the prompt?

If you install CMake using our prebuilt windows installer from the download page, does it not work to generate projects? I can build CMake that way as described in 0013001:0028732.
(0028736)
renes   
2012-02-28 14:25   
The output from uname:

$ uname
MINGW32_NT-6.1


The bash shell from MSYS takes MSYS paths in a command line (e.g. /c/sources/cmake-2.8.7) and passes Windows paths to the program being run (e.g. C:\sources\cmake-2.8.7).

MSYS does not handle the translation of MSYS paths inside CMake files. There is code in CMake to handle this for Cygwin (see call to cygwin_conv_to_win32_path in Source\kwsys\SystemTools.cxx) but not for mingw-w64/MSYS.

If you run mingw-w64 on Linux and cross-compile for Windows, you wouldn't run into this problem.
(0028737)
Brad King   
2012-02-28 14:42   
The /c/ style paths and the MSYS fstab are meaningful only to MSYS and have nothing to do with MinGW. MinGW is a Windows platform that only uses Windows paths. CMake is not part of MSYS so there is no need to support MSYS paths written inside CMakeLists.txt files or passed to it on the command line.

The Cygwin handling code you see is an optimization to avoid the (slow) Cygwin magic filesystem tricks for paths that map to normal Windows files:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9b6c3d07 [^]

It is used only when building CMake under Cygwin, and Cygwin is NOT a Windows platform. It is a POSIX platform that runs on Windows.

MinGW IS a Windows platform and should be supported by the normal Windows CMake built with any tool (such as MSVC). No special behavior should be enabled by __MINGW32__ or similar tests.
(0028739)
renes   
2012-02-28 15:18   
I am building CMake using mingw-w64's GCC.

I am not using MSVC.

CMake doesn't compile with mingw-w64's GCC without some minor changes (see ftruncate).
(0028740)
Brad King   
2012-02-28 15:25   
Whether CMake is built with a MinGW gcc or MSVC the resulting behavior should be the same. There should be no special path conversions or other behavioral differences based on the compiler used so long as the target platform is Windows (and MinGW tools target Windows).

Tests based on __MINGW32__ and __MINGW64__ to address compilation issues are another story because they do not affect the resulting interface. Please factor out a patch containing these changes exclusively.

FYI, it does build for me with MinGW-w64's gcc:

$ gcc -v 2>&1 |egrep '(Target|version)'
Target: x86_64-w64-mingw32
gcc version 4.6.2 20110802 (prerelease) (GCC)
(0028742)
renes   
2012-02-28 16:04   
I am using:

$ gcc -v 2>&1 |egrep '(Target|version)'
Target: x86_64-w64-mingw32
gcc version 4.7.0 20120113 (experimental) (GCC)


I'll work on a separate patch for compilation/linking problems.


I'm seeing MSYS paths written to CMake files and MSYS paths being passed to CMake by MSYS make files generated by CMake on Windows; not Windows paths.

(1) Makefile

# CMAKE generated file: DO NOT EDIT!
# Generated by "MSYS Makefiles" Generator, CMake Version 2.8


# The main all target
all: cmake_check_build_system
    $(CMAKE_COMMAND) -E cmake_progress_start /C/work/sources/cmake-2.8.7/CMakeFiles /C/work/sources/cmake-2.8.7/CMakeFiles/progress.marks
    $(MAKE) -f CMakeFiles/Makefile2 all
    $(CMAKE_COMMAND) -E cmake_progress_start /C/work/sources/cmake-2.8.7/CMakeFiles 0
.PHONY : all

(2) cmake_install.cmake

# Install script for directory: C:/work/sources/cmake-2.8.7

# Set the install prefix
IF(NOT DEFINED CMAKE_INSTALL_PREFIX)
  SET(CMAKE_INSTALL_PREFIX "/C/work/sources/install")
(0028743)
Brad King   
2012-02-28 17:00   
Re 0013001:0028742: The paths you see in the Makefile all lie in commands passed to the MSYS shell and will be properly evaluated there. The case is explicitly handled here:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmLocalGenerator.cxx;hb=v2.8.7#l2221 [^]

There should be no MSYS paths in CMake language files or in the CMakeCache.txt file. The path in cmake_install.cmake is due to a bug in the bootstrap script in that it does not properly convert it to a Windows path before passing it to CMake. Try this patch:

diff --git a/bootstrap b/bootstrap
index f5eacbd..c67c28e 100755
--- a/bootstrap
+++ b/bootstrap
@@ -127,10 +127,20 @@ fi
 cmake_bootstrap_dir="${cmake_binary_dir}/Bootstrap${_cmk}"
 
 # Helper function to fix windows paths.
-cmake_fix_slashes ()
-{
-  echo "$1" | sed 's/\\/\//g'
-}
+case "${cmake_system}" in
+*MINGW*)
+  cmake_fix_slashes()
+  {
+    cmd //c echo "$(echo "$1" | sed 's/\\/\//g')" | sed 's/^"//;s/"$//'

+  }
+  ;;
+*)
+  cmake_fix_slashes()
+  {
+    echo "$1" | sed 's/\\/\//g'
+  }
+  ;;
+esac
 
 # Choose the default install prefix.
 if ${cmake_system_mingw}; then
(0028748)
renes   
2012-02-29 02:11   
I attached cmake-2.8.7-mingw-w64.patch with the patch to handle the compilation issues.

The patch to bootstrap fixed the install problem.


The tests using CVS (ExternalProject, CTest.UpdateCVS) failing are explained by the MSYS version of cvs.exe being called in my environment.

The HG test is failing on a "file://" [^] URL. I'm using Mercurial 2.1.

Not sure what is causing FindPackageTest to fail.

CMake Error at CMakeLists.txt:211 (MESSAGE):
  Package EnvB should have been [EnvB_DIR-NOTFOUND] but was
  [C:/work/sources/cmake-2.8.7/Tests/FindPackageTest/lib/zot-3.1]


$ hg --version
Mercurial Distributed SCM (version 2.1)
(see http://mercurial.selenic.com [^] for more information)

Using HG tools:
 hg = c:/Program Files/Mercurial/hg.exe
Creating test directory...
Creating repository...
Importing content...
CMake Error at CTestUpdateCommon.cmake:13 (message):
  Child failed (255), output is

    abort: file:// URLs can only refer to localhost

25:FindPackageTest
99:ExternalProject
133:CTest.UpdateCVS
134:CTest.UpdateHG
(0028759)
Brad King   
2012-02-29 14:39   
I applied the bootstrap patch:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7f7679e6 [^]
(0028760)
Brad King   
2012-02-29 14:41   
For the tests using CVS, is it failing because the tool treats "c:/..." as a request to access machine "c" by ssh protocol and ask it for "/..."?

For the tests using Mercurial, what is the actual file:// URL that hg doesn't like?
(0028761)
Brad King   
2012-02-29 14:46   
The changes in your patch to libarchive need to be something acceptable in their upstream:

  https://github.com/libarchive/libarchive [^]
  http://libarchive.github.com/ [^]

The archive_platform.h must always be the first header included.

What is wrong with sys/stat.h?

Please attach your CMakeFiles/CMakeError.log file. It should contain information about why ftruncate was not detected.
(0028764)
renes   
2012-02-29 17:25   
I attached a smaller patch (cmake-2.8.7-mingw-w64-updated.patch) that doesn't move sys/stat.h and attached CMakeFiles/CMakeError.log.


The file:// URL in the failing CTest.UpdateHG test is:

    file://C:/work/sources/cmake-2.8.7/Tests/CTest [^] UpdateHG/repo.hg


I tried it from the command line:

$ hg --version
Mercurial Distributed SCM (version 2.1)
(see http://mercurial.selenic.com [^] for more information)

Copyright (C) 2005-2012 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ hg push file://C:/work/sources/cmake-2.8.7/Tests/CTest\ [^] UpdateHG/repo.hg
abort: file:// URLs can only refer to localhost


$ hg push file:///C/work/sources/cmake-2.8.7/Tests/CTest\ [^] UpdateHG/repo.hg
pushing to file:///C/work/sources/cmake-2.8.7/Tests/CTest%20UpdateHG/repo.hg [^]
abort: repository /C/work/sources/cmake-2.8.7/Tests/CTest UpdateHG/repo.hg not found!


134/201 Testing: CTest.UpdateHG
134/201 Test: CTest.UpdateHG
Command: "C:/work/sources/cmake-2.8.7/bin/cmake.exe" "-P" "C:/work/sources/cmake-2.8.7/Tests/CTestUpdateHG.cmake"
Directory: C:/work/sources/cmake-2.8.7/Tests
"CTest.UpdateHG" start time: Feb 29 13:57 Pacific Standard Time
Output:
----------------------------------------------------------
Using HG tools:
 hg = c:/Program Files/Mercurial/hg.exe
Creating test directory...
Creating repository...
 REPO = file://C:/work/sources/cmake-2.8.7/Tests/CTest [^] UpdateHG/repo.hg
Importing content...
CMake Error at CTestUpdateCommon.cmake:13 (message):
  Child failed (255), output is

    abort: file:// URLs can only refer to localhost

  Command = [WORKING_DIRECTORY;C:/work/sources/cmake-2.8.7/Tests/CTest
  UpdateHG/import;COMMAND;c:/Program
  Files/Mercurial/hg.exe;push;file://C:/work/sources/cmake-2.8.7/Tests/CTest [^]
  UpdateHG/repo.hg]

Call Stack (most recent call first):
  CTestUpdateHG.cmake:50 (run_child)


<end of output>
Test time = 0.94 sec
----------------------------------------------------------
Test Failed.
"CTest.UpdateHG" end time: Feb 29 13:57 Pacific Standard Time
"CTest.UpdateHG" time elapsed: 00:00:00
----------------------------------------------------------
(0028772)
Brad King   
2012-03-01 10:47   
Our nightly testing revealed a problem with the bootstrap change. I merged a slightly tweaked version of the fix:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5cd879c4 [^]
(0028773)
Brad King   
2012-03-01 11:00   
Does this patch fix the HG test?
diff --git a/Tests/CTestUpdateHG.cmake.in b/Tests/CTestUpdateHG.cmake.in
index 543ddd9..5a9daae 100644
--- a/Tests/CTestUpdateHG.cmake.in
+++ b/Tests/CTestUpdateHG.cmake.in
@@ -28,7 +28,7 @@ run_child(
   WORKING_DIRECTORY ${TOP}/repo.hg
   COMMAND ${HG} init
   )
-set(REPO file://${TOP}/repo.hg [^])
+set(REPO file:///${TOP}/repo.hg [^])

 #-----------------------------------------------------------------------------
 # Import initial content into the repository.
(0028774)
Brad King   
2012-03-01 11:25   
The ftruncate patch hunks should not be necessary. cmcurl and cmlibarchive test for existence of everything with try_compile. However, cmcurl contains an optimization to avoid many tests on Windows. Those hard-coded results should not be used for MinGW because they are for MS tools. They also interfere with cmlibarchive's tests. Try this patch without yours and with a fresh build tree:

diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt
index 29ce25d6..caa44f1 100644
--- a/Utilities/cmcurl/CMakeLists.txt
+++ b/Utilities/cmcurl/CMakeLists.txt
@@ -126,9 +126,9 @@ IF(CURL_MALLOC_DEBUG)
 ENDIF(CURL_MALLOC_DEBUG)

 # On windows preload settings
-IF(WIN32)
+IF(WIN32 AND NOT MINGW)
   INCLUDE(${LIBCURL_SOURCE_DIR}/Platforms/WindowsCache.cmake)
-ENDIF(WIN32)
+ENDIF()

 # This macro checks if the symbol exists in the library and if it
 # does, it appends library to the list.
(0028777)
renes   
2012-03-01 18:57   
I uploaded another CMakeError.log with the name CMakeError-with-patches.log.

I tried your patches (without mine) on a clean build tree. I am still seeing the same build errors.

cd /C/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive && /c/mingw64/bin/gcc.exe -DCURL_STATICLIB -DLIBARCHIVE_STATIC -DHAVE_CONFIG_H @CMakeFiles/cmlibarchive.dir/includes_C.rsp -o CMakeFiles/cmlibarchive.dir/archive_check_magic.c.obj -c /C/work/sources/cmake-2.8.7/Utilities/cmlibarch
ive/libarchive/archive_check_magic.c
In file included from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_platform.h:68:0,
                 from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_check_magic.c:26:
c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_windows.h:106:0: warning: "fstat" redefined [enabled by default]
In file included from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_windows.h:59:0,
                 from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_platform.h:68,
                 from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_check_magic.c:26:
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/include/sys/stat.h
:259:0: note: this is the location of the previous definition
In file included from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_platform.h:68:0,
                 from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_check_magic.c:26:
c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_windows.h:111:0: warning: "lseek" redefined [enabled by default]
In file included from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_windows.h:55:0,
                 from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_platform.h:68,
                 from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_check_magic.c:26:
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/include/io.h:336:0: note: this is the location of the previous definition
In file included from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_platform.h:68:0,
                 from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_check_magic.c:26:
c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_windows.h:119:0: warning: "stat" redefined [enabled by default]
In file included from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_windows.h:59:0,
                 from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_platform.h:68,
                 from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_check_magic.c:26:
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/include/sys/stat.h
:258:0: note: this is the location of the previous definition
In file included from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_check_magic.c:41:0:
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/include/unistd.h:43:5: error: conflicting types for '__la_ftruncate'
In file included from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_platform.h:68:0,
                 from c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_check_magic.c:26:
c:/work/sources/cmake-2.8.7/Utilities/cmlibarchive/libarchive/archive_windows.h:360:14: note: previous declaration of '__la_ftruncate' was here
make[2]: *** [Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/archive_check_magic.c.obj] Error 1
make[2]: Leaving directory `/c/work/sources/cmake-2.8.7'
make[1]: *** [Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/all] Error 2
make[1]: Leaving directory `/c/work/sources/cmake-2.8.7'
make: *** [all] Error 2
(0028779)
renes   
2012-03-01 20:03   
I tested the CTestUpdateHG.cmake.in patch with the bootstrap patch and my patch on a clean tree.

The patch fixes the HG test.

(ExternalProject and CTest.UpdateCVS failing because MSYS CVS doesn't use Windows paths)

The following tests FAILED:
         25 - FindPackageTest (Failed)
         99 - ExternalProject (Failed)
        133 - CTest.UpdateCVS (Failed)
Errors while running CTest
make: *** [test] Error 8
(0028783)
renes   
2012-03-02 07:38   
On mingw-w64, ftruncate is in libmingwex.a and declared in unistd.h. Mingw uses Microsoft's C library.

CMake (cmlibarchive) is checking in glibc only?

cmlibarchive\CMakeLists.txt:CHECK_FUNCTION_EXISTS_GLIBC(ftruncate HAVE_FTRUNCATE)
cmlibarchive\configure.ac:AC_CHECK_FUNCS([fstat ftruncate futimes geteuid getpid])

C:\mingw64\x86_64-w64-mingw32\lib>findstr /m ftruncate *
libmingwex.a

C:\mingw64\x86_64-w64-mingw32\include>findstr /m ftruncate *
unistd.h


I attached a smaller patch in cmake-2.8.7-mingw-w64-update2.patch.
(0028784)
Brad King   
2012-03-02 08:14   
Re 0013001:0028779: Thanks for testing the HG patch. Applied upstream:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0916cc88 [^]
(0028785)
Brad King   
2012-03-02 08:24   
Re 0013001:0028777, 0013001:0028783: According to CMakeError-with-patches.log there was no trouble locating ftruncate. Is HAVE_FTRUNCATE set to 1 in CMakeCache.txt?

The "CHECK_FUNCTION_EXISTS_GLIBC" tests come from libarchive upstream. It wraps around CMake's check_function_exists test to first check for a glibc stub and then fall back to the normal test.

BTW, I'm not opposed to taking your patches but I want to understand why the normal platform checks are not working as expected for this platform because it may affect other platforms. Thanks for your patience.
(0028786)
Brad King   
2012-03-02 08:28   
This commit from libarchive upstream seems related:

  https://github.com/libarchive/libarchive/commit/05e3b825 [^]

CMake's imported snapshot of libarchive already includes that change though.
(0028787)
renes   
2012-03-02 08:39   
I don't see that change in cmake-2.8.7 though (The version I've been building).

It looks like it fixes the same problem.

The other changes I made are to get rid of warnings about redefining #define's.

Example:

+#ifdef stat
+#undef stat
+#endif
 #define stat(file,st) _stati64(file,st)
(0028788)
Brad King   
2012-03-02 08:45   
Re 0013001:0028787: Oops. I've been building CMake from git master. That's probably why I haven't been able to reproduce your problems. Please follow instructions from here:

 http://www.cmake.org/Wiki/CMake/Git [^]

to clone upstream CMake and try that version.

Also, FYI an extraneous "#undef" doesn't hurt so you do not actually need to condition it with "#ifdef".
(0028790)
renes   
2012-03-02 10:05   
The version of CMake in Git builds.

CMakeOnly.AllFindModules fails because a long list of executables and libraries are not found. I don't have them installed or don't have expected environment variables set.

CMake.CheckSourceTree fails because the Git executables are not found. Git for Windows (http://code.google.com/p/msysgit/ [^]) installs its own copy of MSYS and bash and puts the the Git executables in the same directory as its MSYS executables (which is why I don't have it on the path).


The other failures are for the same reasons as before.


The following tests FAILED:
         25 - FindPackageTest (Failed)
         98 - ExternalProject (Failed)
        132 - CTest.UpdateCVS (Failed)
        133 - CTest.UpdateHG (Failed)
        183 - CMakeOnly.AllFindModules (Failed)
        209 - CMake.CheckSourceTree (Failed)
Errors while running CTest


The bootstrap/configure script now says --host, --build and --target options are unknown.

$ ./configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=$(cd ../install && pwd)
Unknown option: --host=x86_64-w64-mingw32

At the following link, there are some cross-compiling scripts showing how those options are used to build 32-bit and 64-bit executables for Windows on Linux and Mac OS:

http://sourceforge.net/projects/mingw-w64/files/Toolchain%20sources/Personal%20Builds/rubenvb/ [^]
(0028796)
Brad King   
2012-03-02 13:12   
Re 0013001:0028790: Thanks for testing it. I'm glad it builds.

Even though it was not necessary to build I think the patch from 0013001:0028774 is still worthwhile:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2d59c9ab [^]

The AllFindModules test intentionally tries finding everything CMake can find. Although the output complains about lots of stuff not being there that should not be causing the failure. There must be an actual "CMake Error" line somewhere in there. The test is new and still under development though.

CMake's FindGit module can find msysGit in its default location but we are not currently using that for the build of CMake itself for historical reasons. That can be corrected but either way the CheckSource tree test should not be running if Git is not found. This should fix that (not yet in master):

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9012be20 [^]

The bootstrap script never supported --host, --build, or --target but previously failed to diagnose unused options. It is not an autotools-style script. It is for bootstrapping CMake so it can build in places that do not already have CMake. Cross compiling is not a goal for bootstrap, but it can be achieved by building CMake with an existing CMake built for the host environment.
(0028797)
Brad King   
2012-03-02 15:35   
Here is a fix for the tests using MSYS cvs (ExternalProject and CTest.UpdateCVS):

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e3336025 [^]

Earlier fixes posted here cover CTest.UpdateHG and CMake.CheckSourceTree. AllFindModules is a work in progress by its contributor and problems may not be specific to MinGW or MSYS.

That leaves FindPackageTest which I cannot reproduce. Is the failure the same as in 0013001:0028748?
(0028799)
renes   
2012-03-02 16:48   
The FindPackageTest failure is the same one as in http://public.kitware.com/Bug/view.php?id=13001#c28748 [^]

Testing/Temporary/LastTest.log just has the following:

CMake Error at CMakeLists.txt:211 (MESSAGE):
  Package EnvB should have been [EnvB_DIR-NOTFOUND] but was
  [C:/work/sources/cmake-2.8.7/Tests/FindPackageTest/lib/zot-3.1]

I tried adding "--debug --extra-verbose" to the ctest call and setting VERBOSE=1 but there isn't more than the above on this error.

I attached FindPackageTestFiles.txt with a list of files in that test directory.
(0028800)
Brad King   
2012-03-02 17:06   
Please add this to FindPackageTest temporarily to get more output:
diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt
index 9a4bdfe..0157b19 100644
--- a/Tests/FindPackageTest/CMakeLists.txt
+++ b/Tests/FindPackageTest/CMakeLists.txt
@@ -158,7 +158,9 @@ UNSET(CMAKE_LIBRARY_ARCHITECTURE)
 SET(CMAKE_PREFIX_PATH)
 SET(ENV{EnvA_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/lib/zot-3.1")
 FIND_PACKAGE(EnvA 3.1 EXACT QUIET NAMES zot) # Should Work
+SET(CMAKE_FIND_DEBUG_MODE 1)
 FIND_PACKAGE(EnvB 3.1 EXACT QUIET NAMES zot) # Should Fail
+SET(CMAKE_FIND_DEBUG_MODE 0)

 # Test system package registry if available.
 IF(CMakeTestSystemPackage)
(0028801)
renes   
2012-03-02 23:48   
A few of the directories being checked are not on the path.

Written to Testing/Temporary/LastTest.log:

25/209 Testing: FindPackageTest
25/209 Test: FindPackageTest
Command: "C:/work/sources/cmake/bin/ctest.exe" "--build-and-test" "C:/work/sources/cmake/Tests/FindPackageTest" "C:/work/sources/cmake/Tests/FindPackageTest" "--build-two-config" "--build-generator" "MSYS Makefiles" "--build-makeprogram" "C:/msys/bin/make.exe" "--build-project" "FindPackageTest" "--test-command" "FindPackageTest"
Directory: C:/work/sources/cmake/Tests
"FindPackageTest" start time: Mar 02 16:08 Pacific Standard Time
Output:
----------------------------------------------------------
Internal cmake changing into directory: C:/work/sources/cmake/Tests/FindPackageTest
Error: cmake execution failed
Re-run cmake no build system arguments
HKLM is writable: enabling CMakeTestSystemPackage
CMake Error at CMakeLists.txt:213 (MESSAGE):
  Package EnvB should have been [EnvB_DIR-NOTFOUND] but was
  [C:/work/sources/cmake/Tests/FindPackageTest/lib/zot-3.1]


Preparing export(PACKAGE) test project
Searching for export(PACKAGE) test project
Configuring
Configuring incomplete, errors occurred!

Checking bundle prefix [C:/msys/home/user1/]
Checking bundle prefix [C:/work/sources/cmake/Tests/FindPackageTest/]
Checking bundle prefix [C:/msys/local/]
Checking bundle prefix [c:/mingw64/]
Checking bundle prefix [C:/msys/]
Checking bundle prefix [c:/Program Files (x86)/NVIDIA Corporation/PhysX/Common/]
Checking bundle prefix [c:/Program Files (x86)/Haskell Platform/2011.4.0.0/lib/extralibs/]
Checking bundle prefix [c:/Program Files (x86)/Haskell Platform/2011.4.0.0/]
Checking bundle prefix [c:/Windows/System32/]
Checking bundle prefix [c:/Program Files (x86)/SMLNJ/]
Checking bundle prefix [c:/Program Files (x86)/QuickTime/QTSystem/]
Checking bundle prefix [c:/Program Files/SlikSvn/]
Checking bundle prefix [c:/Program Files/Microsoft Windows Performance Toolkit/]
Checking bundle prefix [c:/Ruby193/]
Checking bundle prefix [c:/Python27/]
Checking bundle prefix [c:/Users/user1/AppData/Roaming/cabal/]
Checking bundle prefix [c:/Program Files (x86)/Gambit-C/v4.6.2/]
Checking bundle prefix [c:/Program Files (x86)/CVS Suite/CVSNT Tools/]
Checking bundle prefix [c:/Program Files (x86)/Darcs/]
Checking bundle prefix [c:/Program Files (x86)/Potrace/]
Checking bundle prefix [c:/]
Checking bundle prefix [c:/Program Files/Java/jdk1.6.0_30/]
Checking bundle prefix [c:/Program Files/Perforce/Server/]
Checking bundle prefix [c:/bin/depot_tools/]
Checking bundle prefix [C:/work/sources/cmake/Tests/FindPackageTest/%SCALA_HOME%/]
Checking bundle prefix [c:/Program Files/eclipse/plugins/org.eclipse.m2e.maven.runtime_1.0.0.20110607-2117/]
Checking bundle prefix [c:/Program Files/eclipse/plugins/org.apache.ant_1.8.2.v20110505-1300/]
Checking bundle prefix [c:/Program Files/Mercurial/]
Checking bundle prefix [c:/flexdll/]
Checking bundle prefix [c:/mingw64/opt/ocaml/]
Checking bundle prefix [C:/work/projects/io/build/]
Checking bundle prefix [C:/work/projects/chicken-4.5.0/build/]
Checking bundle prefix [C:/work/projects/chicken-4.5.0/]
Checking bundle prefix [C:/work/sources/cmake/Tests/FindPackageTest/A/]
Checking bundle prefix [C:/Program Files/]
Checking bundle prefix [C:/work/]
Checking bundle prefix [C:/Program Files (x86)/FindPackageTest/]
Checking bundle prefix [/]
Checking prefix [C:/msys/home/user1/]
Checking file [C:/msys/home/user1/zotConfig.cmake]
Checking file [C:/msys/home/user1/zot-config.cmake]
Checking prefix [C:/work/sources/cmake/Tests/FindPackageTest/]
Checking file [C:/work/sources/cmake/Tests/FindPackageTest/zotConfig.cmake]
Checking file [C:/work/sources/cmake/Tests/FindPackageTest/zot-config.cmake]
Checking file [C:/work/sources/cmake/Tests/FindPackageTest/lib/cmake/zot-4.0/zotConfig.cmake]
Checking file [C:/work/sources/cmake/Tests/FindPackageTest/lib/cmake/zot-4.0/zot-config.cmake]
Checking file [C:/work/sources/cmake/Tests/FindPackageTest/lib/zot/zotConfig.cmake]
Checking file [C:/work/sources/cmake/Tests/FindPackageTest/lib/zot/zot-config.cmake]
Checking file [C:/work/sources/cmake/Tests/FindPackageTest/lib/zot-1.0/zotConfig.cmake]
Checking file [C:/work/sources/cmake/Tests/FindPackageTest/lib/zot-1.0/zot-config.cmake]
Checking file [C:/work/sources/cmake/Tests/FindPackageTest/lib/zot-2.0/zotConfig.cmake]
Checking file [C:/work/sources/cmake/Tests/FindPackageTest/lib/zot-2.0/zot-config.cmake]
Checking file [C:/work/sources/cmake/Tests/FindPackageTest/lib/zot-3.0/zotConfig.cmake]
Checking file [C:/work/sources/cmake/Tests/FindPackageTest/lib/zot-3.0/zot-config.cmake]
Checking file [C:/work/sources/cmake/Tests/FindPackageTest/lib/zot-3.1/zotConfig.cmake]
Checking file [C:/work/sources/cmake/Tests/FindPackageTest/lib/zot-3.1/zot-config.cmake]
<end of output>
Test time = 2.88 sec
----------------------------------------------------------
Test Failed.
"FindPackageTest" end time: Mar 02 16:08 Pacific Standard Time
"FindPackageTest" time elapsed: 00:00:02
----------------------------------------------------------


Written to the console:

c:/work/sources/cmake/Source/CTest/cmCTestRunTest.cxx:405 Start 25: FindPackageTest

c:/work/sources/cmake/Source/CTest/cmCTestRunTest.cxx:541
25: Test command: C:\work\sources\cmake\bin\ctest.exe "--build-and-test" "C:/work/sources/cmake/Tests/FindPackageTest" "C:/work/sources/cmake/Tests/FindPackageTest" "--build-two-config" "--build-generator" "MSYS Makefiles" "--build-makeprogram" "C:/msys/bin/make.exe" "--build-project" "FindPackageTest" "--test-command" "FindPackageTest"

c:/work/sources/cmake/Source/cmCTest.cxx:158 Current_Time: Mar 02 16:08 Pacific Standard Time

c:/work/sources/cmake/Source/CTest/cmCTestRunTest.cxx:664 25: Test timeout computed to be: 1500

c:/work/sources/cmake/Source/CTest/cmCTestRunTest.cxx:62 25: Internal cmake changing into directory: C:/work/sources/cmake/Tests/FindPackageTest

c:/work/sources/cmake/Source/CTest/cmCTestRunTest.cxx:62 25: Error: cmake execution failed

c:/work/sources/cmake/Source/CTest/cmCTestRunTest.cxx:62 25: Re-run cmake no build system arguments

c:/work/sources/cmake/Source/CTest/cmCTestRunTest.cxx:62 25: HKLM is writable: enabling CMakeTestSystemPackage

c:/work/sources/cmake/Source/CTest/cmCTestRunTest.cxx:62 25: CMake Error at CMakeLists.txt:213 (MESSAGE):

c:/work/sources/cmake/Source/CTest/cmCTestRunTest.cxx:62 25: Package EnvB should have been [EnvB_DIR-NOTFOUND] but was

c:/work/sources/cmake/Source/CTest/cmCTestRunTest.cxx:62 25: [C:/work/sources/cmake/Tests/FindPackageTest/lib/zot-3.1]

c:/work/sources/cmake/Source/CTest/cmCTestRunTest.cxx:62 25:

c:/work/sources/cmake/Source/CTest/cmCTestRunTest.cxx:62 25:


These directories are not on the path:

Checking bundle prefix [C:/work/projects/io/build/]
Checking bundle prefix [C:/work/projects/chicken-4.5.0/build/]
Checking bundle prefix [C:/work/projects/chicken-4.5.0/]


PATH environment variable:

PATH='/home/user1/bin:.:/usr/local/bin:/mingw/bin:/bin:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c/PROGRA~2/HASKEL~1/2011.4.0.0/lib/extralibs/bin:/c/PROGRA~2/HASKEL~1/2011.4.0.0/bin:/c/PROGRA~2/NVIDIA~1/PhysX/Common:/c/Windows/system32:/c/PROGRA~2/SMLNJ/bin/:/c/PROGRA~2/QuickTime/QTSystem/:/c/PROGRA~1/SlikSvn/bin:/c/PROGRA~1/MICROS~4/:/c/Ruby193/bin:/c/Python27:/c/Users/user1/AppData/Roaming/cabal/bin:/c/PROGRA~2/Gambit-C/v4.6.2/bin:/c/PROGRA~2/CVSSUI~1/CVSNTT~1/:/c/PROGRA~2/Darcs/
:/c/PROGRA~2/Potrace/:/c/bin/:/c/progra~1/Java/jdk1.6.0_30/bin:/c/PROGRA~1/Perforce/Server:/c/bin/depot_tools:%SCALA_HOME%/bin:/c/PROGRA~1/eclipse/plugins/org.eclipse.m2e.maven.runtime_1.0.0.20110607-
2117/bin:/c/PROGRA~1/eclipse/plugins/org.apache.ant_1.8.2.v20110505-1300/bin:/c/PROGRA~1/Mercurial:/
c/flexdll:/c/mingw64/opt/ocaml/bin'
(0028808)
Brad King   
2012-03-05 09:44   
Re 0013001:0028801: Thanks for running the test.

The PATH is not the only place find_package searches. See documentation for 9 steps it follows only one of which is the PATH:

  http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:find_package [^]

The "/build" paths you quote are probably coming from step 5:

 "5. Search project build trees recently configured in a CMake GUI."

The code in question does:

 SET(CMAKE_PREFIX_PATH)
 ...
 FIND_PACKAGE(EnvB 3.1 EXACT QUIET NAMES zot) # Should Fail

which should remove the test source tree from the search locations. I cannot explain from this output why it decides to do

  Checking prefix [C:/work/sources/cmake/Tests/FindPackageTest/]

or all the files inside that. Did you manually configure the test in the GUI while debugging MSYS builds? What happens if you use a totally fresh source and build tree location?
(0028810)
renes   
2012-03-06 05:48   
The "Checking bundle prefix" directories were left over from a previous install of an older version of CMake. I ran the CMake uninstall program but the Windows registry entries for CMake were not deleted.


I deleted the Windows registry entries and ran the tests again with the same results.


This file has the value it seems to be picking up:

Tests/FindPackageTest/CMakeCache.txt

//The directory containing a CMake configuration file for EnvA.
EnvA_DIR:PATH=C:/work/sources/cmake/Tests/FindPackageTest/lib/zot-3.1

//The directory containing a CMake configuration file for EnvB.
EnvB_DIR:PATH=C:/work/sources/cmake/Tests/FindPackageTest/lib/zot-3.1
(0028811)
Brad King   
2012-03-06 08:23   
Re 0013001:0028810: The CMakeCache.txt is where the value is stored *after* detecting it.

The test passes on all our nightly testing machines, including those for MSYS and MinGW. I can't reproduce the FindPackageTest failure and without access to a machine where it happens cannot investigate it further myself. I'm not sure it has anything to do specifically with MSYS or MinGW (and therefore with this bug report). Therefore I'd like to ignore it until someone comes forward with an answer.

I think that covers everything raised in this issue.
(0028841)
renes   
2012-03-06 09:41   
You've fixed what I need to move forward.

Building software for Windows 64-bit sometimes exposes issues not seen on Windows 32-bit (e.g. pointer sizes). Building for Linux 64-bit might be one way to cover some cases.
(0028843)
Brad King   
2012-03-06 10:51   
Re 0013001:0028841: Great, thanks for the confirmation.
(0030828)
David Cole   
2012-09-03 16:00   
Closing resolved issues that have not been updated in more than 4 months.