CMake - Only link a library to an executable if it is needed
问题 I have a project that includes several source files, and I am using the GoogleTest library to create unit tests for some of these source files. The tests are all separate .cpp files and each includes the header of the respective source file to be tested. I want to create a separate executable for each unit test. To do this I have a loop that creates an executable for each member in a test_sources list, and names it according to a test_names list. The problem is that a couple of my unit tests