I have a cmake project leveraging another cmake library project, the dir looks like this:
/CMakeList.txt /main.c /.gitmodules /patch/patch.c /vendor/CMakeList.txt /vendor/vendor.c /vendor/... In /CMakeList.txt, I used add_subdirectory(vendor) to include/link vendor library to my own project.
In /vendor/CMakeList.txt, source file is added by FILE(GLOB SRC_VEN vendor.c ...)
I want to inject /patch/patch.c into vendor library without touching /vendor directory, which is a git submodule
Is it possible to use cmake to achieve this in my root CMakeList.txt?
Thanks!
/vendor/CMakeList.txtreally look like? Doesn't it use a wildcard inFILE(GLOB ...)? What do you mean "without touching"? Could any files be changed automatically?target_sources(vendor_target PRIVATE "patch/patch.c")after youradd_subdirectory(vendor)call? But you need to know the target's name you want to inject into (vendor_targetis just a placeholder). See here for more details./vendor/CMakeLists.txtuses wildcard, i mentioned 'without touch' vendor because I can modify/vendor/CMakeLists.txta little bit, andignore=dirtyin my.gitmodulesso that the change will not be committed