Skip to content

Conversation

@johnbartholomew
Copy link
Collaborator

Minimum CMake version is increased to 3.15. That is chosen based on guidance from here:

https://cliutils.gitlab.io/modern-cmake/README.html#shouldn-t-i-support-the-oldest-version-possible

Notes on this:

  • Global variables are barely used at all now. There is one to hold the jsonnet version number.
  • Most config is set through target properties.
  • Target dependencies are cleaner.
  • Reduced use of CMakeLists.txt in subdirectories. This isn't "better" it's just my personal preference.
  • The generated file std.jsonnet.h is put in the CMake output dir, instead of being written back to the source directory.

Dependency graph

Using GoogleTest just makes it more uniform with other tests so it
can be added to Bazel and CMake test suites.

However, unfortunately it means removing the test from the Makefile
test set.
@He-Pin
Copy link
Contributor

He-Pin commented Jan 31, 2026

Nice, I have to replace it when importing this project in Clion

Minimum CMake version is increased to 3.15. That is chosen based
on guidance from here:

https://cliutils.gitlab.io/modern-cmake/README.html#shouldn-t-i-support-the-oldest-version-possible

Notes on this:

    * Global variables are barely used at all now.
		  There is one to hold the jsonnet version number.

		* Most config is set through target properties.

		* Target dependencies are cleaner.

		* Reduced use of CMakeLists.txt in subdirectories.
		  This isn't strictly better it's just my personal preference.

		* The generated file std.jsonnet.h is put in the CMake output dir,
		  instead of being written back to the source directory.
The CMake test step runs the regression test which is super slow
if the jsonnet binary has been built in Debug (no optimisations)
mode.

And using Ninja means that we can exploit multiple cores on the
CI action runner, if it has multiple cores, without needing to
do extra stuff to find out a core count or correctly set a -j flag.
This works around an annoyance with gtest_discover_tests.
The test discovery system works by running the test binary with flags
to make it produce a JSON file that gives details of all the tests.
However, that file is written to the working directory. If we set the
working directory for the tests to be the source directory, then
the tests can access their test data by relative paths, but the
JSON test details files for test discovery get written to the
source directory, which is ugly.

So, we instead provide the location of the source tree through an
environment variable, and then in the tests themselves we change
the current working directory to the source tree directory.

Why change CWD instead of just using absolute paths for input files?
Because error messages produced by jsonnet include the file paths,
and we need (or at least want) those to still be relative paths so
that we can compare against stable golden outputs.
@johnbartholomew johnbartholomew merged commit 5f0ea43 into google:master Feb 1, 2026
12 checks passed
@johnbartholomew johnbartholomew deleted the rewrite-cmake branch February 1, 2026 14:44
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.

2 participants