[CMake] Unix make files and CMAKE_EXE_LINKER_FLAGS_RELEASE

Philip Lowman philip at yhbt.com
Tue Feb 24 20:13:55 EST 2009


The implementation is the same for the Makefile generator (at least on the
version of CMake I'm using, 2.6.3)
CMAKE_EXE_LINKER_FLAGS is used on all build configurations
CMAKE_EXE_LINKER_FLAGS_DEBUG is added to the link line after
CMAKE_EXE_LINKER_FLAGS when CMAKE_BUILD_TYPE = Debug.

The documentation on this isn't exactly clear.  I believe all of the
*_<CONFIG> variables behave in this way, however.
http://www.cmake.org/cmake/help/cmake2.6docs.html#variable:CMAKE_EXE_LINKER_FLAGS

On Tue, Feb 24, 2009 at 7:07 PM, Neal Meyer <nmeyer at dottedzebra.com> wrote:

> That seems to be different from the Visual Studio Generator's
> implementation.  I've got the following in my CMake for Windows builds.
> (using VS 2005)
>
> set( CMAKE_EXE_LINKER_FLAGS "/MANIFEST /DEBUG /MACHINE:X86" CACHE STRING "Flags
> used by the linker" FORCE )
>
> set( CMAKE_EXE_LINKER_FLAGS_DEBUG "/INCREMENTAL:NO" CACHE STRING "Flags
> used by the linker" FORCE )
>
> set( CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO /OPT:REF /LTCG" CACHE
> STRING "Flags used by the linker" FORCE )
>
>
> For the release builds the linker flags are CMAKE_EXE_LINKER_FLAGS +
> CMAKE_EXE_LINKER_FLAGS_RELEASE.  Similar for the Debug builds.  This seems
> much simpler, because it allows for the combination of the Linker Flags
> which is nice for avoiding repetition in the flags.
>
>
> -Neal
>
> On Tue, Feb 24, 2009 at 3:54 PM, Philip Lowman <philip at yhbt.com> wrote:
>
>> On Tue, Feb 24, 2009 at 6:45 PM, Neal Meyer <nmeyer at dottedzebra.com>wrote:
>>
>>> Philip,
>>> Ok... so it works with the Build_Type thing set, but now with out it.  I
>>> also I'm using XCode sometimes and it doesn't use the linker flags at all.
>>>
>>
>> set(CMAKE_EXE_LINKER_FLAGS "-L/no/build/type")  ?
>>
>> Don't know much about xcode, unfortunately.  Post a clear example of what
>> you're trying to do and what Xcode isn't doing for you and hopefully someone
>> else can help with that.
>>
>>
>>  -Neal
>>>
>>>
>>>
>>>> It could be something simple like
>>>> 1. The CMAKE_EXE_LINKER_FLAGS_<config> variable is somehow not in scope
>>>> when you're calling add_executable()
>>>> 2. Setting CMAKE_EXE_LINKER_FLAGS_MinSizeRel (uppercase config names
>>>> seems to be the only thing that works for me).
>>>> 3. You forgot to set CMAKE_BUILD_TYPE at configure time
>>>>
>>>> Could you try the following small CMakeLists.txt on your system and see
>>>> if it works OK?
>>>>
>>>> ====
>>>> project(Foo)
>>>> cmake_minimum_required(VERSION 2.6)
>>>>
>>>> set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-L/FOO_DEBUG_OK")
>>>> set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-L/FOO_RELEASE_OK")
>>>> set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "-L/FOO_MINSIZEREL_OK")
>>>> set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "-L/FOO_RELWITHDEBINFO_OK")
>>>>
>>>> add_executable(foo foo.cc)
>>>> ====
>>>> cmake -DCMAKE_BUILD_TYPE=Debug
>>>>
>>>>
>>>>
>>>> --
>>>> Philip Lowman
>>>>
>>>
>>>
>>
>>
>> --
>> Philip Lowman
>>
>
>


-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090224/27d61951/attachment-0001.htm>


More information about the CMake mailing list