cmake: convert qibuild function into pure CMake