Hi,<div><br></div><div>Currently we have a directory called "test" under each project we have. Each source file (CPP) results in 1 unit test project being created. So if we have a project named "foobar", it would be structured like this on the filesystem:</div>
<div><br></div><div>foobar/test/test1.cpp</div><div>foobar/test/test2.cpp</div><div>foobar/test/test3.cpp</div><div><br></div><div>And the generated visual studio projects (when created via CMake) would be:</div><div><br>
</div><div>foobar</div><div>foobar_test1</div><div>foobar_test2</div><div>foobar_test3</div><div><br></div><div>Obviously this creates a lot of clutter in the solution explorer window in Visual Studio. Is there a more recommended practice for structuring unit tests in CMake? Personal advice is also welcome. One approach I'd like to take is where we only have two projects:</div>
<div><br></div><div>foobar</div><div>foobar_test</div><div><br></div><div>And inside foobar_test, all of the sources under the /test/ directory would be included, so a single project compiles all unit tests.</div><div><br>
</div><div>foobar_test</div><div> test1.cpp</div><div> test2.cpp</div><div> test3.cpp</div><div><br></div><div>However, the reason why I'm currently not doing this is because of compile-time unit testing. Basically, some unit tests are designed to be successful if they fail to compile. For example, perhaps certain template parameters do not meet the requirements of a specific C++ concept, and thus rightfully fail. This unit test would be considered successful because we want to make sure that ONLY types matching this specific concept are accepted by the compiler.</div>
<div><br></div><div>If we include these source files in the same project, then it interrupts the whole compilation process. They have to be separate in order to work properly.</div>