[CMake] Supplying different debug flags during compile and link stages for libraries and executables

Brett Delle Grazie brett.dellegrazie at gmail.com
Thu Jun 28 12:07:28 EDT 2012


Hi Petr, et. al.

It looks like I spoke too soon.
I cannot see any way to separate the debug compile flag (-g) so that
it does not appear on the linker lines for static and shared
libraries.

The creation rules for static / shared libraries all include
"<LANGUAGE_COMPILE_FLAGS>" which inevitably includes the debug flags.

On AIX, the '-g' debug flag should only be supplied to executable
targets otherwise duplicate symbol errors result.

I'll take a look at the sources and see if anything can be done there
otherwise I might have to raise a defect.

If anyone has any alternative suggestions please let me know.

Kind regards,

Brett

On 28 June 2012 14:31, Brett Delle Grazie <brett.dellegrazie at gmail.com> wrote:
> Hi Petr,
>
> Thanks very much ... I saw something extremely similar in the VS
> /STACK:1000 and managed to work it out from there.
> I've been playing around with it today and have managed to get somewhere.
>
> Thanks again,
>
> Brett
>
> On 28 June 2012 08:06, Petr Kmoch <petr.kmoch at gmail.com> wrote:
>> Hi Brett,
>>
>> as far as I know, compilation flags come from
>> CMAKE_<lang>_FLAGS_<config>, while linker flags come from
>> CMAKE_{SHARED|EXE}_LINKER_FLAGS[_<config>]. So you should be able to
>> override CMAKE_SHARED_LINKER_FLAGS_Debug (not sure with correct case
>> for configuration name) and remove -g from there.
>>
>> Petr
>>
>> On Wed, Jun 27, 2012 at 10:36 PM, Brett Delle Grazie
>> <brett.dellegrazie at gmail.com> wrote:
>>> Hi,
>>>
>>> On AIX using the XLC compiler I've determined the debug flag (-g)
>>> should be used for all compile stages but should only be supplied to
>>> the final
>>> link stage of an executable (not a library target), otherwise
>>> duplicate symbol errors result.
>>> For reference see:
>>> http://www.ibm.com/developerworks/forums/thread.jspa?threadID=438591&tstart=0
>>>
>>> Is there an easy way of supplying a different set of debug flags for
>>> the compile stage as opposed to the link stage?
>>>
>>> I could potentially override:
>>> CMAKE_C_FLAGS_DEBUG_INIT
>>> CMAKE_CXX_FLAGS_DEBUG_INIT
>>>
>>> but I can't really see where these are combined into the compile / link rules.
>>>
>>> Does anyone have any suggestions? Any guidance / help is appreciated.
>>>
>>> Thanks,
>>>
>>> --
>>> Best Regards,
>>>
>>> Brett Delle Grazie
>>> --
>>>
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>
>
>
> --
> Best Regards,
>
> Brett Delle Grazie



-- 
Best Regards,

Brett Delle Grazie


More information about the CMake mailing list