[CMake] listing of object file targets in an archive.

Tim St. Clair timothysc at gmail.com
Thu Sep 9 15:06:45 EDT 2010


nevermind I've figured out a generic way to do what I need, build once and
link in multiple locations.

MACRO ( SRC_TARGET_REF _TARGET _REFS_EXPR _SRCREFS )

# 1st obtain the srcs
 get_target_property ( _LSRCS ${_TARGET} SOURCES )

#loop through srouces and check matches
 foreach ( _TARGET_SRC_FILE ${_LSRCS} )

#for each src file check all refs.
 foreach ( _REF ${_REFS_EXPR} )

# if matches
if(${_TARGET_SRC_FILE} MATCHES ${_REF})

if(${_SRCREFS})
set (${_SRCREFS} "${${_SRCREFS}};${_TARGET_SRC_FILE}")
 else(${_SRCREFS})
set (${_SRCREFS} ${_TARGET_SRC_FILE})
endif(${_SRCREFS})

endif()

endforeach( _REF )
endforeach( _TARGET_SRC_FILE )

ENDMACRO ( SRC_TARGET_REF )

############################################
## begin excerpt

src_target_ref( small_lib "^.*$" SMALL_LIB_REFS)
add_library( big_mundge_redistro_lib STATIC blah_blah.cpp;${SMALL_LIB_REFS}
)
add_dependencies (big_mundge_redistro_lib small_lib)

On Thu, Sep 9, 2010 at 11:19 AM, Tim St. Clair <timothysc at gmail.com> wrote:

> From within cmake I see a generation of the .o targets in my makefile, is
> there any way to get a listing without shelling out to ar?
>
> --
> Cheers,
> Timothy St. Clair
>
>


-- 
Cheers,
Timothy St. Clair
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100909/96714df8/attachment.htm>


More information about the CMake mailing list