Disable Parallel builds or enforce specific Targets are not built in parallel

I’m using CMake to wrap some Make builds by creating some custom targets that simply call a shell script which invoke make. These existing Make builds are in source builds. I now have two different ways I wish to call make on the existing Make builds. If I run CMake without any parallel options, this works as desired (I’m using GNU Makefile generation). However, if someone where to pass parallel build option, this would break. Effectively I need to ensure these two custom targets aren’t built in parallel, or disable the option to have parallel builds. Is there something I can do to accomplish this?

I think the only reliable way is to make one depend on the other. With Ninja generators, you can add them to the same job pool with size 1, but that doesn’t work for any other generator.

I am not sure if this is an option in your case, but in general, as a workaround, you can write a CMake script that does the sequential work using execute_process, and execute it as add_custom_command(COMMAND ${CMAKE_COMMAND} -P …)