CMake: Improve main C++ CMakeLists.txt

- Move CMake scripts to cmake subfolder
- Build qt, nb and z depending on the flags and found libraries
- Improve config.h