Here is what I want to do:
make all
will build my library and the docs for it.make test
will build my lib (if necessary), gtest and then my testsmake check
runs make test
if needed and then runs the executableRight now I've only managed to get the first to work. The problem I'm having is the conditional include of gtest.
Gtest uses CMake which is nice, in theory all I need to do is to include the gtest directory with add_subdirectory
but then gtest will always be built.
My structure right now is:
CMakeLists.txt (Here I add targets for doc and the library) doc (my doxygen docs) include (my headers) lib (where my compiled libraries go) src (where my .cpp files go) test CMakeLists.txt (Here I add targets for gest and my tests) bin (where the test executable will go) contrib (where gtest is) src (my tests)
I'm trying to figure out how to add gtest as a dependency to the test
-target but not build gtest every time.
I'm really annoyed and the little to none information there is about learning CMake so if anyone know any in depth tutorials (available freely on the interwebs) that would be awesome.
CTest is an executable that comes with CMake; it handles running the tests for the project. While CTest works well with CMake, you do not have to use CMake in order to use CTest.
Run the tests in parallel using the given number of jobs. This option tells CTest to run the tests in parallel using given number of jobs. This option can also be set by setting the CTEST_PARALLEL_LEVEL environment variable. This option can be used with the PROCESSORS test property.
To build with just cmake change directory into where you want the binaries to be placed. For an in-place build you then run cmake and it will produce a CMakeCache. txt file that contains build options that you can adjust using any text editor.
The trick is to do add_subdirectory(test EXCLUDE_FROM_ALL)
and then none of the targets in that CMakeList.txt will added to the ALL target.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With