Yes, that would work.
Update: What follows is not very relevant anymore because nowadays CMake supports response files, so there shouldn't be problems with too long command lines.
However you might have troubles when the number of files get too high, and the command line too long for your compiler to be able to handle it. A possible solution is to add a static library for each subdirectory, add them to a list "ALL_MY_SUB_LIBS", and link them to the main target foo in this way:
target_link_libraries(foo "-Wl,--whole-archive") #like opening a parenthesis
target_link_libraries(foo ${ALL_MY_SUB_LIBS})
target_link_libraries(foo "-Wl,--no-whole-archive") #like closing a parenthesis
ld linker question: the --whole-archive option