optimize cmake scripts for subproject use
Reference issue
Fixes #2347 (closed)
What does this implement/fix?
With that, the support for subprojects is improved. E.g. no tests will be builded by default.
Additional information
The use of CMAKE_CXX_FLAGS for tests should be replaced by a test_interface target