MantisBT - CMake
View Issue Details
0013929CMakeCPackpublic2013-02-17 17:252016-06-10 14:31
Nathan Osman 
Kitware Robot 
normalmajoralways
closedmoved 
LinuxUbuntu12.10
CMake 2.8.10 
 
0013929: __cpack_system_name incorrectly set when compiling with Mingw-w64
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.
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
cross compile
Issue History
2013-02-17 17:25Nathan OsmanNew Issue
2013-02-17 17:26Nathan OsmanTag Attached: cross compile
2013-02-17 17:27Nathan OsmanNote Added: 0032320
2016-06-10 14:28Kitware RobotNote Added: 0042226
2016-06-10 14:28Kitware RobotStatusnew => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:28Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0032320)
Nathan Osman   
2013-02-17 17:27   
Oh, I almost forgot - you will also need the NSIS command line compiler installed to perform the steps above to reproduce the problem.
(0042226)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.