This flow doesn't work at all. If you call just one group, core gets build for that group. And in combination of different build dir for each group... You end up building the core for each group again and again.
You can use the same build directory for all but indeed it will **install** always the core in your `DESTDIR`.
--- So I introduced the components found in cmake `install` commands in https://github.com/kamailio/kamailio/tree/cmake **branch**.
**Unfortunately, this requires `CMake 3.15`, if we can afford it.**
What you can do now is:
Provide all the groups in the configuration phase like you did before `-DMODULE_GROUP_NAME='KSTANDARD KJSON KPERL'`. Try using the K-variations, otherwise the components won't be defined for later. You can do for example the `ALL` but if you don't provide the `KJSON` as well, the component `KJSON` won't be there (only the `ALL`) even if the module is going to be compiled.
Then you proceed to build everything in one go, in the same build directory `cmake --build build_folder -j8` . (remember to use specific targets as well if you need non default files like dbschema for example).
and lastly to install a specific component you can use
`DESTDIR=path_to_folder cmake --install build_folder --component component_name`
where component_name can be `kamailio-core` for installing everything related to core, such `kamctl`, `kamdbctl`, docs, man, configs, (if I didn't miss anything...) or any of the provided `MODULE_GROUP_NAME`.
You can't give yet multiple components to the command, as noted in [issue](https://gitlab.kitware.com/cmake/cmake/-/issues/24335). You can run the same command with the same `DESTDIR` with diff component and it will install only the related files.
If this is not desirable, I will try to find some other alternatives...
Cheers, Xenofon