How to avoid mixing test and production code using GoogleTest?
<p>I am starting to use GoogleTest. It seems that it needs a main file for running the tests:</p>

<p><a href="https://stackoverflow.com/questions/7443970/separate-test-cases-across-multiple-files-in-google-test">Separate test cases across multiple files in google test</a></p>

<p>But currently in my demo application I already have a main file:</p>

<pre><code>src/
-&gt; MyType.h
-&gt; main.cpp
-&gt; Makefile
</code></pre>

<p>Which will eventually be my "production" application. I don't want to clutter that with gtest includes, macros etc. </p>

<p>Should I just create another main.cpp file in another folder e.g.: <code>test/</code> that will contain all the specific gtest configuration so I would end up with:</p>

<pre><code>src/
-&gt; MyType.h
-&gt; main.cpp
-&gt; Makefile // Makefile for producing production code/binaries
Test/
-&gt; MyTypeTest.h // Unittest for MyType
-&gt; main.cpp // The "Test runner"
-&gt; Makefile // Makefile for producing test executable
</code></pre>

<p><strong>EDIT:</strong></p>

<p>Found this based on cmake:</p>

<p><a href="http://www.kaizou.org/2014/11/gtest-cmake/" rel="nofollow noreferrer">http://www.kaizou.org/2014/11/gtest-cmake/</a></p>

<p>which seems to be exactly what I am looking for.</p>