I know this is normally bad practice, but I need to compile code twice in vastly different contexts within the same project. Therefore I want to #include "file.cpp" in two different source files.
How can I express a dependency using CMAKE so that the two files get recompiled when file.cpp is changed?
One solution is to put the code in a header instead, but CMAKE will compile the entire project when a header is changed, which is overkill and slows down development. Is there a more fine-grained solution?
Including .cpp files is not a duplicate. That question is about not understanding static functions. When do I need to #include .cpp files? is also not a duplicate, as this user also fails to understand linking. Both questions have answers saying it is bad practice and not suitable in the specific case. That is not applicable to this question.