[CMake] external link dependency, non-library
Michael Hertling
mhertling at online.de
Tue Sep 7 21:28:05 EDT 2010
On 09/08/2010 12:11 AM, SK wrote:
> Alright, I ended up rototilling and using a dummy file approach, as in:
>
> SET( _relink_dummy "${CMAKE_CURRENT_BINARY_DIR}/relink_dummy.c" )
> ADD_EXECUTABLE( ${_app_name} ${_app_srcs} ${_relink_dummy} )
> SET_SOURCE_FILES_PROPERTIES( ${_relink_dummy} PROPERTIES GENERATED TRUE )
> ADD_CUSTOM_COMMAND( OUTPUT ${_relink_dummy}
> COMMAND echo "/* Autogenerated dummy file to catch link
> dependencies */" > ${_relink_dummy}
> DEPENDS ${_external_objects}
> COMMENT "Generating dummy file to catch link dependencies."
> )
>
> Seems cumbersome to me, particularly since I need to intercept the
> application build at ADD_EXECUTABLE time. I would have been much
> happier to find:
> ADD_LINK_ONLY_DEPENDENCY()
The problem of linkers scripts and a target's dependency on them has
been brought up along with possible solutions in [1] et seq.
> Maybe this is a reasonable feature request?
Yes, IMO, linker scripts are a strong reason for such link dependencies.
For Makefile generators, it's an addition of just one single line to the
concerned target's build.make that would establish the desired dependency.
Regards,
Michael
[1] http://www.mail-archive.com/cmake@cmake.org/msg29123.html
> On Tue, Sep 7, 2010 at 12:04 PM, SK <sk at metrokings.com> wrote:
>> Hello,
>>
>> I have an external build process that produces a linker script that I
>> must use in my CMake project. I must leave the external build as-is.
>> I'm using gcc in Linux.
>>
>> I must relink my application built with CMake if the linker script
>> changes. I'm trying to do this in a simple macro and it's not
>> working. I do not see a first class way to specify arbitrary link
>> dependencies, so I'm setting the dependency indirectly to the
>> application sources.
>>
>> # setup link dependencies for _app_name
>> MACRO( DEPEND_ON_LD _app_name)
>> GET_TARGET_PROPERTY( _srcs ${_app_name} SOURCES )
>> SET_SOURCE_FILES_PROPERTIES( ${_srcs} PROPERTIES OBJECT_DEPENDS
>> /full/path/to/linker_script.ld )
>> ENDMACRO()
>>
>> If I touch the linker script file, my app does not relink.
>>
>> Any help is very much appreciated! Perhaps there is a cleaner way to do this?
>>
>> Thanks,
>> -steve
More information about the CMake
mailing list