janicicpredrag / gclc

GCLC is a mathematical software tool for producing high-quality mathematical illustrations, for teaching mathematics, and for automated proving of geometry theorems.
http://www.matf.bg.ac.rs/~janicic/gclc/
Other
53 stars 7 forks source link

port CLI and GUI build systems to CMake #40

Closed Smattr closed 6 months ago

Smattr commented 6 months ago

Wrt #23, this ports (1), (2), and (4) to CMake. I expect this will take a bit of experimentation (read: force-pushing) to figure out the exact build.yml changes to meet CI’s expectations.

A couple of things:

  1. While doing this, I discovered I think source/cGCLC.pro just describes a Qt-based build of the same thing in Makefile and/or Makefile.win. Is this correct? If so, do we want to retain/port/delete it?
  2. I left source/gGCLC.pro intact despite porting it under the assumption users may wish to still use Qt Creator on this. Is that correct?
  3. For now, I held off on porting Makefile.web, which I figure we can tackle after working out the kinks on this PR.
  4. I dropped -static as I think we discussed it’s not working, and this PR does not yet make any steps to re-enable it. Maybe we want to figure out whether that is easy/possible before landing this?

CMake primer

I guess not everyone reading this will be familiar with CMake, so here is a brief getting started guide…

tl;dr

# build everything
cmake -B my-build-folder -S . # ← configure the build
cmake --build my-build-folder # ← run compilation

# build only the CLI
cmake -B my-build-folder -S .
cmake --build my-build-folder --target gclc

more…

You read on the internet that CMake is not a build system but a “meta build system”. This statement is both accurate and thoroughly useless for helping you understand CMake. What people mean when they say this is that CMake generates build system files (e.g. Makefiles) that then become inputs to an actual build system (e.g. GNU Make).

The overwhelming main benefit of CMake is cross-platform portability. You could think of it as a variant of Autotools that plays nicer on Windows and has fewer opportunities for life-ruining typos. As the name suggests, it is biased towards building C/C++ projects.

You configure things with one or more files named CMakeLists.txt. What is possible and how the syntax works is explained at https://cmake.org/cmake/help/latest/. Though admittedly it is sometimes hard to know the right terms to search for and you have to resort to cribbing things from strangers’ existing CMakeLists.txt files.

There are a few notable bells and whistles that CMake gives you out of the box: