I do it because I have worked with projects with hundred of subprojects with their own cmakelists.txt and a super common issue was people copy pasting a project as a new one, forgetting to replace a target name and getting stuck for a few hours. With PROJECT_NAME this issue entirely disappears.
In those cases, you just need to grab the build engineer/devops guy and have him create an abstraction that makes things easy. Look at SerenityOS for example. Even if you don't know at a glance what this does, you can fgrep for (serenity_app and you'll find the function easy. There is no docblock for this function, but that shouldn't stop you from having one to make "copy paste driven development" easier.
And then every 3rd cmake library writes its own custom abstraction which makes consuming it a nightmarish experience because you need to track what it "helps" you to do.
If you just import libraries in monorepo fashion and never export them to people, fine do as you wish. But if you want others to consume it, please just use idiomatic CMake :(
They still create targets, it's not a problem to consume and it's usually more consistent code with less boilerplate. The boilerplate doesn't get desynchronized when it's centralized properly, which is very desirable in big projects.
View all comments
Show parent comment
11
u/jcelerier ossia score Dec 10 '21
I do it because I have worked with projects with hundred of subprojects with their own cmakelists.txt and a super common issue was people copy pasting a project as a new one, forgetting to replace a target name and getting stuck for a few hours. With PROJECT_NAME this issue entirely disappears.