[CMake] Fwd: Adding custom directories to PATH enviroment

Gabriele Greco gabriele.greco at darts.it
Thu Apr 14 03:31:21 EDT 2011


>
>
> You're right about the explicit listing, but you should do the copying
> using configure_file(... COPYONLY). And don't even think about using
> file(GLOB) and friends, that's usually the wrong approach.
>
>
The problem is that those files can be modified by the user and in that case
obviously the sources should be recompiled, so I ended with an approach
similar to the one for the .idl interfaces, the only thing I don't like is
that those small targets are listed as % points of the progress of the
build, anyway it's really impressive the flexibility of cmake!


MACRO (MACRO_ADD_CUSTOMIZED)
 FOREACH(_in_FILE ${ARGN})

   GET_FILENAME_COMPONENT(_out_DIR ${_in_FILE} PATH)
   GET_FILENAME_COMPONENT(_out_FILE ${_in_FILE} NAME_WE)

   ADD_CUSTOM_COMMAND(
     OUTPUT ${PROJECT_BINARY_DIR}/inc/intf/${_out_DIR}/${_out_FILE}.h
     DEPENDS ${PROJECT_SOURCE_DIR}/inc/intf/${_in_FILE}
     COMMAND mkdir -p "${PROJECT_BINARY_DIR}/inc/intf/${_out_DIR}"
     COMMAND cp "${PROJECT_SOURCE_DIR}/inc/intf/${_in_FILE}"
"${PROJECT_BINARY_DIR}/inc/intf/${_out_DIR}"
   )

   SET_SOURCE_FILES_PROPERTIES(
     ${PROJECT_BINARY_DIR}/inc/intf/${_out_DIR}/${_out_FILE}.h
     PROPERTIES
     GENERATED TRUE
   )

   ADD_CUSTOM_TARGET(${_out_FILE} DEPENDS
${PROJECT_BINARY_DIR}/inc/intf/${_out_DIR}/${_out_FILE}.h)

   add_dependencies(idl ${_out_FILE} )
 ENDFOREACH(_in_FILE ${ARGN})


MACRO_ADD_CUSTOMIZED(AckNak/AckNakImpl.h
 GlacToGcrf/GlacToGcrfImpl.h        SfdToVld/SfdToVldImpl.h
        AckNak/AckNakIntf.h          GlacToGcrf/GlacToGcrfIntf.h
 SfdToVld/SfdToVldIntf.h
        FromASII/FromASIIImpl.h      GlacToGtr/GlacToGtrImpl.h
 SubToMaster/SubToMasterImpl.h
        FromASII/FromASIIIntf.h      GlacToGtr/GlacToGtrIntf.h
 SubToMaster/SubToMasterIntf.h
        FromGRL/FromGRLImpl.h        GrfToGcrf/GrfToGcrfImpl.h
 SupvToMonitor/SupvToMonitorImpl.h
        FromGRL/FromGRLIntf.h        GrfToGcrf/GrfToGcrfIntf.h
 SupvToMonitor/SupvToMonitorIntf.h
        FromTLP/FromTLPImpl.h        GtlrToGtr/GtlrToGtrImpl.h
 TechInterface/TechInterfaceImpl.h
        FromTLP/FromTLPIntf.h        GtlrToGtr/GtlrToGtrIntf.h
 TechInterface/TechInterfaceIntf.h
        FromTTL/FromTTLImpl.h        GtrToGcfg/GtrToGcfgImpl.h
 ToASII/ToASIIImpl.h
        FromTTL/FromTTLIntf.h        GtrToGcfg/GtrToGcfgIntf.h
 ToASII/ToASIIIntf.h
        GcfgToGfg/GcfgToGfgImpl.h    GtrToGcrf/GtrToGcrfImpl.h
 ToCLK/ToCLKImpl.h
        GcfgToGfg/GcfgToGfgIntf.h    GtrToGcrf/GtrToGcrfIntf.h
 ToCLK/ToCLKIntf.h
        GcfgToGtr/GcfgToGtrImpl.h    GtrToGcrl/GtrToGcrlImpl.h
 ToGprotoIdle/ToGprotoIdleImpl.h
        GcfgToGtr/GcfgToGtrIntf.h    GtrToGcrl/GtrToGcrlIntf.h
 ToGprotoIdle/ToGprotoIdleIntf.h
        GcrfToGlac/GcrfToGlacImpl.h  GtrToGlac/GtrToGlacImpl.h
 ToGprotoNull/ToGprotoNullImpl.h
        GcrfToGlac/GcrfToGlacIntf.h  GtrToGlac/GtrToGlacIntf.h
 ToGprotoNull/ToGprotoNullIntf.h
        GcrfToGrf/GcrfToGrfImpl.h    GtrToGmsg/GtrToGmsgImpl.h
 ToGprotoReady/ToGprotoReadyImpl.h
        GcrfToGrf/GcrfToGrfIntf.h    GtrToGmsg/GtrToGmsgIntf.h
 ToGprotoReady/ToGprotoReadyIntf.h
        GcrfToGtr/GcrfToGtrImpl.h    GtrToGtlr/GtrToGtlrImpl.h
 ToTLP/ToTLPImpl.h
        GcrfToGtr/GcrfToGtrIntf.h    GtrToGtlr/GtrToGtlrIntf.h
 ToTLP/ToTLPIntf.h
        GcrlToGrl/GcrlToGrlImpl.h    MasterToSub/MasterToSubImpl.h
 ToTTL/ToTTLImpl.h
        GcrlToGrl/GcrlToGrlIntf.h    MasterToSub/MasterToSubIntf.h
 ToTTL/ToTTLIntf.h
        GcrlToGtr/GcrlToGtrImpl.h    MonitorToSupv/MonitorToSupvImpl.h
 VldToProc/VldToProcImpl.h
        GcrlToGtr/GcrlToGtrIntf.h    MonitorToSupv/MonitorToSupvIntf.h
 VldToProc/VldToProcIntf.h
        GfgToGcfg/GfgToGcfgImpl.h    ProcToVld/ProcToVldImpl.h
 VldToSfd/VldToSfdImpl.h
        GfgToGcfg/GfgToGcfgIntf.h    ProcToVld/ProcToVldIntf.h
 VldToSfd/VldToSfdIntf.h
    )

-- 
Ing. Gabriele Greco, DARTS Engineering
Tel: +39-0105761240  Fax: +39-0105760224
s-mail: Via G.T. Invrea 14 - 16129 GENOVA (ITALY)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110414/012f82c0/attachment.htm>


More information about the CMake mailing list