View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006834CMakeCMakepublic2008-04-17 04:282008-04-22 11:11
ReporterGerhard Grimm 
Assigned ToBill Hoffman 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionFixed in Version 
Summary0006834: NMake Makefiles generator passes all compile flags of a target to the resource compiler, causing rc or link errors
DescriptionThe attached example builds a shared and a static library from the same source, using the shared and static versions of the MSVC runtime. To accomplish this, the COMPILE_FLAGS properties of the targets are set to /MDd resp. /MTd.
The shared library includes a version resource, too. Building this example with Visual Studio .NET 2003 using project files (use config_mvs7.bat in the "build" directory) succeeds as expected.
However, when using NMake Makefiles (use config_nmake.bat), a linker error occurs when linking the shared library. The linker chokes on an invalid .RES file created by the resource compiler, because the /MDd option intended for the C compiler was passed to it as well.
Only /I and /D flags should be passed to the resource compiler, just as the Visual Studio generator does it.
Additional InformationSetting the /MDd resp. /MTd flag in the source file's COMPILE_FLAGS property won't help, since it's the same source file for both targets - they would be compiled with the same flag setting, causing one of them to be incorrectly built.
TagsNo tags attached.
Attached Fileszip file icon CMakeBug.zip [^] (3,819 bytes) 2008-04-17 04:28

 Relationships

  Notes
(0011466)
Bill Hoffman (manager)
2008-04-21 18:09

As a work around, can you use set_source_files_properties instead of set_target_properties and not set those flags on the .rc file?
(0011472)
Gerhard Grimm (reporter)
2008-04-22 03:23

Hi Bill, as I outlined in "Additional Information" above, doing so would cause one of the two libraries to be built incorrectly, i.e. with the wrong runtime flag in effect, since they are using the same source file (which has only a single COMPILE_FLAGS property that can't be set to different values per target - the setting defined last "wins" and is used for both targets).
(0011477)
Bill Hoffman (manager)
2008-04-22 11:11

OK, I came up with something that works, and allow for RC to exclude flags it does not want in the makefiles.

$ cvs commit -m "BUG: fix for bug 6834 RC should not get all COMPILE_FLAGS from a target and should work the same way as it does in the vs ide" Modules/CMakeRCInformation.cmake Source/cmMakefileTargetGenerator.cxx
/cvsroot/CMake/CMake/Modules/CMakeRCInformation.cmake,v <-- Modules/CMakeRCInformation.cmake
new revision: 1.6; previous revision: 1.5
/cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.cxx,v <-- Source/cmMakefileTargetGenerator.cxx
new revision: 1.98; previous revision: 1.97
(0011478)
Bill Hoffman (manager)
2008-04-22 11:11

Should be fixed now in CVS.

 Issue History
Date Modified Username Field Change
2008-04-17 04:28 Gerhard Grimm New Issue
2008-04-17 04:28 Gerhard Grimm File Added: CMakeBug.zip
2008-04-21 18:05 Bill Hoffman Status new => assigned
2008-04-21 18:05 Bill Hoffman Assigned To => Bill Hoffman
2008-04-21 18:09 Bill Hoffman Note Added: 0011466
2008-04-22 03:23 Gerhard Grimm Note Added: 0011472
2008-04-22 11:11 Bill Hoffman Note Added: 0011477
2008-04-22 11:11 Bill Hoffman Status assigned => closed
2008-04-22 11:11 Bill Hoffman Note Added: 0011478
2008-04-22 11:11 Bill Hoffman Resolution open => fixed


Copyright © 2000 - 2018 MantisBT Team