[CMake] discussion about bug 8165

David Cole david.cole at kitware.com
Fri Nov 12 07:40:43 EST 2010


The thread you replied is meant for bug number listing only. I've
started a new thread to continue this discussion. It should really be
recorded in the bug notes since it's specific to that bug...

http://public.kitware.com/Bug/view.php?id=8165

On Fri, Nov 12, 2010 at 3:24 AM, David Hunter <davidhunter22 at gmail.com> wrote:
> I would second this, I have been manually removing the CMAKE_INTDIR by
> hand, I'm not sure why it's even there for C++ compiles. I prefer my
> compile lines as clean and simple as possible and I don't use this
> compile line define anywhere. If I want a compile line define to
> indicate what CMAKE_INT does I can add it myself very easily but I
> don't see any easy way to make it not added of to remove it. Which
> segways me into
>
> 1) Does the patch you mention remove all the C++ defines from the midl
> command line? To my mind the defines you would want for IDL and C++
> are pretty orthoginal so why force one on the other

No, the patch does not remove all C++ defines from the midl command
line. It simply addresses passing the single define in question to
midl in a different way.

The defines for IDL and C++ files in any given project may, but
certainly do not have to, overlap. In a CMake generated project, they
do overlap. As do defines for any added *.rc files. While I agree with
you that they probably should be orthogonally controllable, I don't
think changing CMake's behavior at this point would be beneficial for
the people who have become used to it the way it is... However, I
could be persuaded that we should adopt a new behavior (by CMake's
policy mechanism so that people can still keep the old behavior for a
while as they transition to the new behavior) if there is sufficient
interest.

It's kind of a lot of work for a fairly small feature, though.

People who really want different midl command lines can always use
CMake's add_custom_command to drive midl themselves with the exact
command line of interest. (And then do NOT add the idl file as a
source, but simply make your dll or exe depend on the output of the
custom command...)

This is all very Visual Studio specific, so it's not very high on the
radar compared to CMake features that affect all (multiple-platform,
multiple-compiler) users.


>
> 2) Is there a general standard way to change the default flags you get
> for the compile line. As a for instance on a VS 10 debug build you get
> -RTC1 added which causes, amongst other things run time checking of
> undefined variable. This is toxic at run time for Boost which uses
> undefined variables for their types not their values so you get a
> runtime exception and I'm not man enough to attempt to play in the
> Boost code base. The only way I managed to get this flag changed,
> after various failed attempts at regex replacment of CMAKE variable
> and other Web suggested things, to the less problematic -RTCs was do
> download the source code replace RTC1 wherever I found it and build my
> own patched version. This seems a bit extreme. If someone know
> standard way of changing the default compile line switches for a given
> project, in other words not not by modifying you standard cmake
> install, can it be added to the FAQ/Wiki?
>

The default values in question come from the file
Modules/Platform/Windows-cl.cmake and are defined as:
  SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1")
  SET (CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi  /Ob0 /Od /RTC1")

The way to change the defaults for everybody is to change that file.
(As it appears you've been doing...)

You could change them in your project's CMakeLists.txt file like this:

if(CMAKE_CXX_FLAGS_DEBUG MATCHES "/RTC1")
  string(REPLACE "/RTC1" "xxx"
    CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
  message(STATUS "info: replaced '/RTC1' in CMAKE_CXX_FLAGS_DEBUG with 'xxx'
        Value of CMAKE_CXX_FLAGS_DEBUG seen in cmake-gui is being
overridden with:
        CMAKE_CXX_FLAGS_DEBUG='${CMAKE_CXX_FLAGS_DEBUG}'")
endif()

if(CMAKE_C_FLAGS_DEBUG MATCHES "/RTC1")
  string(REPLACE "/RTC1" "xxx"
    CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
  message(STATUS "info: replaced '/RTC1' in CMAKE_C_FLAGS_DEBUG with 'xxx'
        Value of CMAKE_C_FLAGS_DEBUG seen in cmake-gui is being overridden with:
        CMAKE_C_FLAGS_DEBUG='${CMAKE_C_FLAGS_DEBUG}'")
endif()

Or you can observe what their default values are, and then construct
full replacements for them, and pass them in with -D on the cmake
command line.


Hope this helps,
David


> Thanks
>
>
> On Thu, Nov 11, 2010 at 11:52 PM, Tony Bridges <abridges at rim.com> wrote:
>> Hi David,
>>
>> 0008165 - vs2005 midl chokes on CMAKE_INTDIR  (also 2008)
>>  http://public.kitware.com/Bug/view.php?id=8165
>>
>> I would love to see a fix for 0008165 in the next version.
>>
>> Each new version we pick up, I have to reapply Robert Lenhardt's patch and rebuild.
>>   http://public.kitware.com/Bug/file_download.php?file_id=1887&type=bug
>> The change is simple and isolated, from what I can see.
>>
>> Thanks!
>> /t
>>
>>


More information about the CMake mailing list