Hi everyone,

I've been trying to build something for Windows on Fedora with MinGW
and I'm hitting a road block.

First, the problem: CMake fails trying to test the C++ compiler with
the following error message:

  Linking CXX executable cmTC_f5bba

  /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f5bba.dir/link.txt
  --verbose=1

  /usr/bin/i686-w64-mingw32-g++ -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
  -fexceptions --param=ssp-buffer-size=4
  CMakeFiles/cmTC_f5bba.dir/testCXXCompiler.cxx.o -o cmTC_f5bba -rdynamic

  i686-w64-mingw32-g++: error: unrecognized command line option '-rdynamic'

The -rdynamic flag is indeed not supported with MinGW, so CMake
shouldn't pass it.

I'm using Fedora's mingw32-cmake command which passes this toolchain
file to CMake:

http://pkgs.fedoraproject.org/cgit/mingw-filesystem.git/tree/toolchain-
mingw32.cmake?h=f22

As you can see, it sets CMAKE_SYSTEM_NAME to Windows.

After a few hours of trying to figuring this out, and adding
MESSAGE(...) lines everywhere in the /usr/share/cmake files involved in
building the project, I added the following line to the top of the
/usr/share/cmake/Modules/CMakeCXXInformation.cmake file:

  MESSAGE("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")

I'm attaching the full output of the build to this email. In it, you
will see that for most of the build, the CMAKE_SYSTEM_NAME variable is
correctly set to "Windows", until a point where it is set to "Linux".

As a result, the /usr/share/cmake/Modules/Platform/Linux-GNU.cmake file
gets loaded, which contains this line:

  set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic")

And this is exactly what causes my build to fail.

So I guess something is wrong here. I don't know much CMake, but I find
it surprising that the CMAKE_SYSTEM_NAME variable would change like
this in the middle of the build process.

What am I doing wrong? :)

Thanks,


-- 
Mathieu
-- The CXX compiler identification is GNU 5.1.0
CMAKE_SYSTEM_NAME: Windows
-- Check for working CXX compiler: /usr/bin/i686-w64-mingw32-g++
CMAKE_SYSTEM_NAME: Windows
-- Check for working CXX compiler: /usr/bin/i686-w64-mingw32-g++ -- works
-- Detecting CXX compiler ABI info
CMAKE_SYSTEM_NAME: Windows
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
CMAKE_SYSTEM_NAME: Windows
CMAKE_SYSTEM_NAME: Windows
CMAKE_SYSTEM_NAME: Windows
-- Detecting CXX compile features - done
CMake Warning (dev) at CMakeLists.txt:76 (add_custom_target):
  Policy CMP0037 is not set: Target names should not be reserved and should
  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  The target name "package" is reserved or not valid for certain CMake
  features, such as generator expressions, and may result in undefined
  behavior.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Performing Test static_link
CMAKE_SYSTEM_NAME: Windows
-- Performing Test static_link - Failed
-- The CXX compiler identification is GNU 5.1.0
CMAKE_SYSTEM_NAME: Linux
-- Check for working CXX compiler: /usr/bin/i686-w64-mingw32-g++
CMAKE_SYSTEM_NAME: Linux
-- Check for working CXX compiler: /usr/bin/i686-w64-mingw32-g++ -- broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCXXCompiler.cmake:54 (message):
  The C++ compiler "/usr/bin/i686-w64-mingw32-g++" is not able to compile a
  simple test program.

  It fails with the following output:

   Change Dir: /home/bochecha/Workspace/eduanatomist/development/brainvisa-cmake/tags/1.2.1/tmp/CMakeFiles/CMakeTmp

  

  Run Build Command:"/usr/bin/gmake" "cmTC_93224/fast"

  /usr/bin/gmake -f CMakeFiles/cmTC_93224.dir/build.make
  CMakeFiles/cmTC_93224.dir/build

  gmake[1]: Entering directory
  '/home/bochecha/Workspace/eduanatomist/development/brainvisa-cmake/tags/1.2.1/tmp/CMakeFiles/CMakeTmp'


  Building CXX object CMakeFiles/cmTC_93224.dir/testCXXCompiler.cxx.o

  /usr/bin/i686-w64-mingw32-g++ -o
  CMakeFiles/cmTC_93224.dir/testCXXCompiler.cxx.o -c
  /home/bochecha/Workspace/eduanatomist/development/brainvisa-cmake/tags/1.2.1/tmp/CMakeFiles/CMakeTmp/testCXXCompiler.cxx


  Linking CXX executable cmTC_93224

  /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_93224.dir/link.txt
  --verbose=1

  /usr/bin/i686-w64-mingw32-g++
  CMakeFiles/cmTC_93224.dir/testCXXCompiler.cxx.o -o cmTC_93224 -rdynamic

  i686-w64-mingw32-g++: error: unrecognized command line option '-rdynamic'

  CMakeFiles/cmTC_93224.dir/build.make:97: recipe for target 'cmTC_93224'
  failed

  gmake[1]: *** [cmTC_93224] Error 1

  gmake[1]: Leaving directory
  '/home/bochecha/Workspace/eduanatomist/development/brainvisa-cmake/tags/1.2.1/tmp/CMakeFiles/CMakeTmp'


  Makefile:126: recipe for target 'cmTC_93224/fast' failed

  gmake: *** [cmTC_93224/fast] Error 2

  

  

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


-- Configuring incomplete, errors occurred!
See also "/home/bochecha/Workspace/eduanatomist/development/brainvisa-cmake/tags/1.2.1/tmp/CMakeFiles/CMakeOutput.log".
See also "/home/bochecha/Workspace/eduanatomist/development/brainvisa-cmake/tags/1.2.1/tmp/CMakeFiles/CMakeError.log".
gmake: Nothing to be done for 'install'.
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    BUILD_SHARED_LIBS
    CMAKE_INSTALL_LIBDIR
    INCLUDE_INSTALL_DIR
    SHARE_INSTALL_PREFIX
    SYSCONF_INSTALL_DIR


-- Build files have been written to: /home/bochecha/Workspace/eduanatomist/development/brainvisa-cmake/tags/1.2.1
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to