r/cpp • • Aug 03 '26

Common Problems I see with Public Libraries Build Scripts

Hi, I'm an early user of Common Package Specification and C++ modules. I package and port libraries for my own use frequently.

I want to talk about issues I see constantly.

- Having specific options for sanitizers, exceptions etc, this is a toolchain problem, if I wanna build your library with sanitizers I can just add the flags to my cmake toolchain file same as allocators.

- Not separating build options to a separate file, meson already does this, it ain't that hard to do in cmake, just cache variables in a separate file at project dir which you include before subdirs

- Making tests separate cmake projects rather than just executables, just why?

- Vendoring dependencies, copy pasting files from other projects rather than just consuming these external libs via packages.

- Using unnecessary helper functions that really makes the cmake script unreadable. Build scripts don't need to be over engineered, they are just basic scripts in which you define very basic information.

I could go on but I'm tired.

26 Upvotes

52 comments sorted by

View all comments

Show parent comment

9

u/trad_emark Aug 04 '26

i have had CI builds failing so many times because some third-party library failed to download. all the gitlab server or basically any other git service providers are extremely unreliable. i have strict policy that all third party are on github, or i fork them onto github.

8

u/delta_p_delta_x Aug 04 '26

some third-party library failed to download

The solution is built artifact/binary caching.

0

u/TheRavagerSw Aug 04 '26

This is an unreasonable take, you do not need to clone every time you build. Most companies already fork all the OSS projects they use, so chances are they can be acquired via other means too if github goes down(it never does though)

8

u/trad_emark Aug 04 '26

how else do i build the code in github CI if i dont clone the source?

-8

u/TheRavagerSw Aug 04 '26

I'm talking about local builds, I recommend not building your library via CI, you can just run tests on it instead. But again I'm the minority here.

But yeah you can't build on CI if you don't clone all the time