[cmake-developers] [CMake 0013929]: __cpack_system_name incorrectly set when compiling with Mingw-w64

Mantis Bug Tracker mantis at public.kitware.com
Sun Feb 17 17:25:20 EST 2013


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=13929 
====================================================================== 
Reported By:                Nathan Osman
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   13929
Category:                   CPack
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2013-02-17 17:25 EST
Last Modified:              2013-02-17 17:25 EST
====================================================================== 
Summary:                    __cpack_system_name incorrectly set when compiling
with Mingw-w64
Description: 
I have a CMake/CPack project that I am cross-compiling for 32 and 64-bit
Windows. CPack generates an NSIS installer for both architectures but
incorrectly detects a 32-bit compiler in both cases.

After looking through the source code for Modules/CPack.cmake, I came across the
following:

if(${__cpack_system_name} MATCHES Windows)
  if(CMAKE_CL_64)
    set(__cpack_system_name win64)
...

It appears that CPack is only checking for the 64-bit compiler that ships with
MSVC++ and not for Mingw-w64.

Steps to Reproduce: 
Assuming you have the Mingw-w64 compiler installed, the following steps will
reproduce the problem:

1. Create a very simple project that consists of the following files:

   test.cpp:

       #include <iostream>
       
       int main(int argc, char ** argv)
       {
           std::cout << "Hello world!" << std::endl;
           return 0;
       }

   CMakeLists.txt:

       cmake_minimum_required(VERSION 2.8)
       
       project(test)
       add_executable(test test.cpp)
       install(TARGETS test RUNTIME DESTINATION bin)
       
       include(CPack)

2. Create a CMake toolchain file like so (toolchain.cmake in the same
directory):

       set(CMAKE_SYSTEM_NAME Windows)
       
       set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
       set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
       set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
       
       set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
       
       set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
       set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
       set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

   (You may need to adjust the value of "CMAKE_FIND_ROOT_PATH".)

3. Build the package:

       mkdir build ; cd build
       cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake ..
       make package

4. You should end up with an incorrectly named installer titled:

       test-0.1.1-win32.exe
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-02-17 17:25 Nathan Osman   New Issue                                    
======================================================================




More information about the cmake-developers mailing list