[CMake] external link dependency, non-library

SK sk at metrokings.com
Tue Sep 7 18:11:05 EDT 2010


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()

Maybe this is a reasonable feature request?

Cheers,
-steve

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