If you want a specific library to always be release then you could use a pre-built binary approach.
We have dependencies on a third party library so we just link against pre-built binaries because we don’t care about debugging this third party library. At a certain point large projects can’t build everything from source.
So you can start formalizing lib1 into a more formal library deliverable. And even consider using a C/C++ package manger liker Conan (Which works well with CMake).
This is what big game engines end up doing. At a certain point they break up their libraries into shared libraries gfx, physics, etc. Because if you are working on gfx you don’t need a debug physics library.
lib1 as such is just an internal library, it has no value outside of my project. So making it an external project or packaging/compiling it independently from the rest of the project does not really make sense.
It’s a shame that there is no simple solution to this problem.
Also if another build system made this easy I’d say it’s a bad idea overall. For lots of reasons I can get into.
We had issues a while back where our debug builds were too slow. And it made us re-evaluate our codebase and it improved the perf of our debug/release builds. Even our debug builds can still run at 30-60 FPS.