KallistiOS / kos-ports

Ported library collection for KallistiOS
Other
52 stars 33 forks source link

Update build to allow cmake, initial port of cglm #55

Closed QuzarDC closed 4 months ago

QuzarDC commented 6 months ago

This is a proposed update of the build.mk kos-ports scripts to allow cmake as an optional build system (alongside autotools). Instead of a flag for 'PORT_AUTOTOOLS', now there is a variable to set 'PORT_BUILD' that can be set to autotools or cmake (and would be open to expansion in the future).

I'm not very familiar with the way cmake works and I think that the values I'm passing in manually in build.mk may well belong more in the base cmake scripts since they would be global to the kos/kos-ports environment:

-DCMAKE_INSTALL_INCLUDEDIR=${KOS_PORTS}/${PORTNAME}/inst/include -DCMAKE_INSTALL_LIBDIR=${KOS_PORTS}/${PORTNAME}/inst/lib

Another thing is that this would, without some other work, make cmake a dependency for kos-ports. configure already is so perhaps that's not bad, but some help would probably be good in making sure it can soft-fail and still let people without cmake build the rest.

Making this update required updating the makefiles for the existing ports that relied on the PORT_AUTOTOOLS flag to use the new scheme.

Additionally I provided a sample port of cglm, an OpenGL math library, which uses cmake and is buildable with this (including using cmake to build the tests that are provided into the examples folder).

Update: I've now also introduced a new option "CMAKE_OUTSOURCE". When defined, it sets the behavior to automatically create a build folder and build from it. This seemed fairly common when I was surveying software using cmake, but perhaps has a standard name or should take a parameter for the path name?

Additionally I've added 2 other ports that help demonstrate the functionalities and possible additional work needed: Chipmunk2D and cmark Both required a fixup to get the build library to where its expected and cmark required the OUTSOURCE functionality.

Update2: One additional option that I've added is PREBUILD. This is a counterpart to PREINSTALL and allows similarly adding directives, but that will happen directly before cmake/configure/make are called. This is needed, for instance, for autotools ports that require running an autogen.sh first.

QuzarDC commented 6 months ago

As @Kazade and @gyrovorbis are credited for the kos/utils/cmake scripts, I'm hoping you might have some input here, especially on the best way to handle those forced defines for setting the install_include and install_lib dirs.

QuzarDC commented 5 months ago

Moving this to 'ready for review'. https://github.com/KallistiOS/KallistiOS/pull/496 is required for the libchimpmunk port to build correctly, but otherwise this should be ready.