I understand that add_executable is getting a bit abused in here but even the official CMake example https://cmake.org/cmake/help/latest/prop_tgt/RESOURCE.html adds resource files like that and otherwise my resource files won’t get copied into my .app folder.
With my shader files this works flawlessly though but I get a problem when adding models. Then CMake fails with following error: [build] ld: unknown file type in '.../models/cube.obj'
I understand that this occurs because add_executable does nothing else than passing the files to the compiler and the compiler probably doesn’t like the .objextension.
My current solution is to simply rename my models, for example to models/cube.model but this is very unsatisfactory, is there another way to add resources that is more elegant? Thanks in advance
Potentially the *.obj files are being identified as object files (i.e. compiled sources), not OBJ 3D data. You could try setting the HEADER_FILE_ONLY source file property to true on these *.obj files. That might be enough to convince CMake to not treat them as (compiled) object files. Ignore the fact that the property name mentions headers, it’s primary role is to prevent that file from being compiled.