| View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | ||||
| 0013579 | CMake | Modules | public | 2012-10-09 11:16 | 2013-03-04 08:38 | ||||
| Reporter | Jordan Lefebvre | ||||||||
| Assigned To | Brad King | ||||||||
| Priority | high | Severity | major | Reproducibility | always | ||||
| Status | closed | Resolution | fixed | ||||||
| Platform | Windows | OS | 7 64bit | OS Version | |||||
| Product Version | CMake 2.8.9 | ||||||||
| Target Version | CMake 2.8.10 | Fixed in Version | CMake 2.8.10 | ||||||
| Summary | 0013579: FortranCInterface.cmake does not pass CMAKE_BUILD_TYPE flags | ||||||||
| Description | In attempting to compile a mixed language static Windows executable, FortranCInterface.cmake breaks the cmake configuration. Windows MSVC and Intel compilers toggle between static and dynamic system/compiler libraries using /MT and /MD compiler flags respectively. /libs:static /threads and /libs:dll /threads are equivalent to /MT and /MD respectively. The issues stems from a difference in initialization across C/CXX flags and Fortran flags. The static/dynamic flags are initialized in the base CMAKE_Fortran_FLAGS while they are initialized in the CMAKE_[C|CXX}_FLAGS_<CMAKE_BUILD_TYPE> flags. FortranCInterface.cmake does not pass the BUILD_TYPE flags through to the subproject. This results in mixed dynamic and static libraries and multiply defined symbols at linking. | ||||||||
| Steps To Reproduce | 1) Create cmake configuration which utilizes FortranCInterface. 2) Use Intel compilers on Windows 3) Add these additional configuration options to a configuration script.bat: cmake ^ -D CMAKE_C_FLAGS:STRING="/DWIN32 /D_WINDOWS /W3 /Zm1000" ^ -D CMAKE_CXX_FLAGS:STRING="/DWIN32 /D_WINDOWS /W3 /Zm1000 /EHsc /GR" ^ -D CMAKE_Fortran_FLAGS:STRING="/W1 /nologo /fpp" ^ -D CMAKE_C_FLAGS_RELEASE:STRING="/D_NDEBUG /O2 /MT" ^ -D CMAKE_CXX_FLAGS_RELEASE:STRING="/DNDEBUG /O2 /MT" ^ -D CMAKE_Fortran_FLAGS_RELEASE:STRING="/D_NDEBUG /O2 /MT" ^ -D CMAKE_Fortran_COMPILER:STRING=ifort ^ -D CMAKE_CXX_COMPILER:STRING=icl ^ -D CMAKE_C_COMPILER:STRING=icl ^ -G "NMake Makefiles" ^ %* 4) initialize Intel development environment 5) run script.bat path/to/src | ||||||||
| Additional Information | This could be fixed by standardizing the initialization of compiler flags across all languages or passing all compiler flags through to the FortranCInterface subproject. This prevents a static Windows build for executable deployment. It would be convenient to have this fixed as soon as possible. | ||||||||
| Tags | No tags attached. | ||||||||
| Attached Files | |||||||||
| Relationships | |
| Relationships |
| Notes | |
|
(0031196) Brad King (manager) 2012-10-09 13:08 |
Please attach a complete example in a tarball. |
|
(0031197) Bill Hoffman (manager) 2012-10-09 13:11 |
When do you get an error? Does the try-compile fail and you don't get the .h files? |
|
(0031201) Jordan Lefebvre (reporter) 2012-10-10 07:46 |
Yes. The try compile fails so the configuration halts. I will try to create a small example tarball. |
|
(0031205) Bill Hoffman (manager) 2012-10-10 14:31 |
I was able to reproduce using the test case. To reproduce you start a Intel command line prompt. Then run cmake -D CMAKE_C_FLAGS:STRING="/DWIN32 /D_WINDOWS /W3 /Zm1000" -D CMAKE_CXX_FLAGS:STRING="/DWIN32 /D_WINDOWS /W3 /Zm1000 /EHsc /GR" -D CMAKE_Fortran_FLAGS:STRING="/W1 /nologo /fpp" -D CMAKE_C_FLAGS_RELEASE:STRING="/D_NDEBUG /O2 /MT" -D CMAKE_CXX_FLAGS_RELEASE:STRING="/DNDEBUG /O2 /MT" -D CMAKE_Fortran_FLAGS_RELEASE:STRING="/D_NDEBUG /O2 /MT" -D CMAKE_Fortran_COMPILER:STRING=ifort -D CMAKE_CXX_COMPILER:STRING=icl -D CMAKE_C_COMPILER:STRING=icl -G "NMake Makefiles" Which gives errors like this: /MANIFESTFILE:VerifyFortranC.exe.intermediate.manifest VerifyFortranC.exe.embed.manifest.res CMakeFiles/VerifyFortranC.dir/main.c.obj CMakeFiles/VerifyFortranC.dir/VerifyC.c.obj LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in M SVCRT.lib(MSVCR90.dll) LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVC RT.lib(MSVCR90.dll) LIBCMT.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSV CRT.lib(MSVCR90.dll) LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRT.lib (MSVCR90.dll) |
|
(0031207) Brad King (manager) 2012-10-10 15:27 edited on: 2012-10-10 15:28 |
Minimum test case: >type ..\CMakeLists.txt cmake_minimum_required(VERSION 2.8.9) project(Issue13579 C Fortran) string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") string(REPLACE "/libs:dll /threads" "" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") include(FortranCInterface) FortranCInterface_VERIFY() >cmake .. -G"NMake Makefiles" -DCMAKE_C_COMPILER:STRING=icl -DCMAKE_Fortran_COMPILER:STRING=ifort LIBCMT.lib(crt0dat.obj) : error LNK2005: _amsg_exit already defined in MSVCRT.lib(MSVCR90.dll) ... |
|
(0031210) Brad King (manager) 2012-10-10 16:05 |
As a work around, simply comment out the FortranCInterface_VERIFY() calls in your project for your deployment build. You know that the compilers are compatible. |
|
(0031211) Brad King (manager) 2012-10-10 16:05 |
This should fix it: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=71491bbe [^] |
|
(0032475) Robert Maynard (manager) 2013-03-04 08:38 |
Closing resolved issues that have not been updated in more than 4 months. |
| Notes |
| Issue History | |||
| Date Modified | Username | Field | Change |
| 2012-10-09 11:16 | Jordan Lefebvre | New Issue | |
| 2012-10-09 13:08 | Brad King | Note Added: 0031196 | |
| 2012-10-09 13:11 | Bill Hoffman | Note Added: 0031197 | |
| 2012-10-10 07:46 | Jordan Lefebvre | Note Added: 0031201 | |
| 2012-10-10 14:31 | Bill Hoffman | Note Added: 0031205 | |
| 2012-10-10 15:27 | Brad King | Note Added: 0031207 | |
| 2012-10-10 15:28 | Brad King | Note Edited: 0031207 | |
| 2012-10-10 15:38 | Brad King | Assigned To | => Brad King |
| 2012-10-10 15:38 | Brad King | Status | new => assigned |
| 2012-10-10 16:05 | Brad King | Note Added: 0031210 | |
| 2012-10-10 16:05 | Brad King | Note Added: 0031211 | |
| 2012-10-11 10:43 | Brad King | Status | assigned => resolved |
| 2012-10-11 10:43 | Brad King | Resolution | open => fixed |
| 2012-10-11 10:43 | Brad King | Target Version | => CMake 2.8.11 |
| 2012-10-17 17:00 | David Cole | Fixed in Version | => CMake 2.8.10 |
| 2012-10-17 17:00 | David Cole | Target Version | CMake 2.8.11 => CMake 2.8.10 |
| 2013-03-04 08:38 | Robert Maynard | Note Added: 0032475 | |
| 2013-03-04 08:38 | Robert Maynard | Status | resolved => closed |
| Issue History |
| Copyright © 2000 - 2018 MantisBT Team |