Removing files from a set

前端 未结 1 1153
挽巷
挽巷 2021-01-12 06:51

I have a directory with files that either belong to a set that makes up a Qt project, and other files that do not. That is, files A.cxx, ADriver.cxx and A.ui all belong to a

相关标签:
1条回答
  • 2021-01-12 07:35

    First, gather all files with a glob:

    file(GLOB ALL_SRCS *)
    

    Then select ui files and create Qt targets for them, substracting them from the ALL_SRCS list at the same time:

    file(GLOB UIS *.ui)
    
    foreach(ui ${UIS})
    get_filename_component(f ${ui} NAME_WE)
    
    # Do Qt stuff
    qt4_wrap_ui( ${f}uis ${ui} )
    qt4_wrap_cpp( ${f}srcs ${f}.cpp ${f}Driver.cpp )
    add_executable( ${f} ${f}uis ${f}srcs )
    
    list(REMOVE_ITEM ALL_SRCS ${ui} ${f}.cpp ${f}Driver.cpp)
    endforeach()
    

    After this you'll have all non-qt sources in ALL_SRCS.

    0 讨论(0)
提交回复
热议问题