Skip to content

build.lunar: Changing the cmake functions to be more inline with normal#187

Merged
dagbrown merged 2 commits intolunar-linux:masterfrom
stumbles:build.lunar
Mar 20, 2026
Merged

build.lunar: Changing the cmake functions to be more inline with normal#187
dagbrown merged 2 commits intolunar-linux:masterfrom
stumbles:build.lunar

Conversation

@stumbles
Copy link
Copy Markdown
Member

@stumbles stumbles commented Dec 2, 2025

usage. While the default Makefile generator defaults to Unix Makefiles, using Ninja streamlines things a bit. One item being cmake -B will create the out of source directory and no cd required and all operations are done at TLD of source. I have tested this on many, many modules and encountered no issues.

If such is encountered then do something like this in $OPTS; -G "Unix Makefiles".

The cmake_build_target function can be removed. Also I got tired of seeing invalid switches like BUILD_TESTING and SYSCONF_INSTALL_DIR during a compile.

Besides, its my itch.

usage. While the default Makefile generator defaults to Unix Makefiles,
using Ninja streamlines things a bit. One item being cmake -B will create
the out of source directory and no cd required and all operations are done
at TLD of source.  I have tested this on many, many modules and encountered
no issues.

If such is encountered then do something like this in $OPTS; -G "Unix Makefiles".

The cmake_build_target function can be removed. Also I got tired of seeing
invalid switches like BUILD_TESTING and SYSCONF_INSTALL_DIR during a compile.

Besides, its my itch.
Comment thread libs/build.lunar
verbose_msg "running \"default_cmake_build\""
default_cmake_config &&
default_make
cmake --build $MODULE-$VERSION &&
Copy link
Copy Markdown
Member

@Ratler Ratler Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stumbles This change looks ok to me overall. However, I think one thing we need to confirm is whether this change breaks the parallel build or not. default_make() handles adding -j$MAKES, I don't think cmake handles this by default. Could you double-check that and adjust if necessary?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should satisfy things;

cmake --build $MODULE-$VERSION -j$(nproc) &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you want is:

cmake --build $MODULE-$VERSION ${MAKES:+-j${MAKES}} &&

The number of parallel builds should be up to the user to choose. They don't necessarily want as many makes as there are processors. Me, I like to set the number of makes to be twice the number of cores, to take advantage of in-memory caching.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works for me dagbrown.

@dagbrown
Copy link
Copy Markdown
Member

dagbrown commented Mar 1, 2026

There is a small issue with this PR which was actually an issue with the previous cmake build: if some module required an out-of-source build (the one I discovered was libjpeg-turbo), the old cmake build makes a directory to build stuff in, and then changes into that directory.

Which means that anything in a module's BUILD script after default_cmake_build might be in a different working directory after the default_cmake_build function finishes, which I think is clearly a bug. So this PR actually fixes that bug, which is good!

But that also means we need to find any other cmake modules which might work around this bug and fix them if they do before we can merge.

@dagbrown dagbrown merged commit f7e5de4 into lunar-linux:master Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants