Generalize resource generation and simplify CMake file