Matthias, check out the following article which solves exactly the same
problem as yours, just with GoogleTest as the third party package:
https://crascit.com/2015/07/25/cmake-gtest/
It includes a fully general implementation hosted on github (MIT license)
which you can use directly in your
To solve the dependency order problem, generally you would make a
superbuild which builds your dependencies and also your own project
via ExternalProject, using the DEPENDS option to guarantee build
order. This way all your dependencies are fully built and installed
before it even gets to