How to give custom path to the object files

I want to give custom path to the object files. All the generated object files should be in this location instead of cmake own path.

CMake doesn’t have control over this for all generators (e.g., Xcode and Visual Studio), so it doesn’t offer a way to change where they go. It also doesn’t offer control over the filename to be used either (other than through the filename of the source file itself).

What is the usecase for relocating them?

Thanks for the explanation @ben.boeckel

@What is the usecase for relocating them? – as a final software package, deliver with collection of object files and list files in a single location

In that case, you can do install(TARGET ${tgt} OBJECTS DESTINATION), though it might only make sense for OBJECT libraries.