CMake uses
CMakeConfigureLog.yaml
to log configure output.
CMakeConfigureLog.yaml replaces CMakeOutput.log and CMakeError.log from older CMake.
message(CONFIGURE_LOG)
also writes to CMakeConfigureLog.yaml.
CMake can do a variety of configure-time checks that help avoid confusing build errors.
The fundamental functions for these checks are
try_compile
and
try_run.
Higher level CMake functions like
check_source_compiles,
check_source_runs,
check_symbol_exists,
etc. wrap these functions and add logic to only run the check once.
In general for CMake try_compile() and try_run(), include directories are specified like:
CMake
file-api
is the canonical way to programmatically interact with CMake from external build systems and tools.
CMake file-api uses JSON files to communicate CMake state and target graph to external tools.
CMake file-api replaces the removed cmake-server API.
CTest can output JSON
describing the test graph, especially useful to understand complex test dependencies including
test fixtures.
CTest runs can take an arbitrarily long time depending on the number and duration of tests configured in a CMake project.
Whether one accidentally hit Ctrl+C
in the Terminal window or intentionally stopped a CTest run with options like --stop-on-failure, it’s possible to resume from where CTest left off with
ctest -F.
If CTest ran all tests (whether or not there were failures of tests), then CTest will ignore “-F” and run all tests again or as specified by other CTest command line options.
NOTE: using git rebase in general can wipe out a lot of work in difficult or impossible to recover ways.
Before doing operations like this, create a copy of the Git branch and push it to recover from undesired outcomes.
Git
rebase
or
merge
operations on a feature branch with numerous commits can be fatiguing when it’s known that all of either the local or remote changes should be accepted in conflicts.
This auto-accept of changes can be done on some or all changed files.
Git rebase auto-accept operations have the reverse sense of merge.
Rebase on “main”, auto-accept all local changes in conflicts:
git rebase -X theirs main
Rebase on “main”, auto-accept all remote changes in conflicts:
git rebase -X ours main
Git merge auto-accept operations have the reverse sense of rebase.
Merge “main”, auto-accept all local changes in conflicts:
git merge -X ours main
Merge “main”, auto-accept all remote changes in conflicts:
CMake FetchContent and ExternalProject bring remote projects into the top-level project to avoid making a monorepo or vendoring code into the top-level project.
For those who desire more control over the remote project download process for FetchContent and ExternalProject, a method demonstrated in this
script
can be used:
CMake is a meta build system that
generates build files
such as Makefile, build.ninja etc. consumed by the build system such as GNU Make, Ninja, etc. corresponding to the CMake Generator selected.
The input files for the build system generated by CMake themselves require CMake.
They are not directory portable.
The most general approach uses CMake’s build command after configuration like:
cmake -B build
cmake --build build
An equivalent alternative is to directly invoke the build tool like:
cmake -B build -G "Unix Makefiles"make -C build
or
cmake -B build -G Ninja
ninja -C build
Even when directory invoking the build tool, observe that editing the CMake script then invoking the build tool directory reconfigures CMake before commencing the build.
Numeric-focused libraries and programs may wise to “raise” and/or “catch” warnings generated by Numpy operations.
By default for Numpy data types operations that raise with plain Python types may only warn with Numpy types.
Use
numpy.errstate
context manager or decorator to raise Numpy arithmetic warnings as errors.
We do this INSTEAD of “numpy.seterr()” that changes the global Numpy settings.
That is, scripts or packages that call this module would be affected by numpy.seterr() in surprising ways,
while numpy.errstate as decorated or context manager limits the scope of the change to the function or context.
Some servers may block Matlab or GNU Octave download traffic from web operations like websave() or webread().
A web browser from the same computer may work–this is a symptom of server user agent blocking.
This script demonstrates setting a custom HTTP user agent using
Matlab
or
GNU Octave
factory function weboptions() to get around servers that block non-allow-listed user agents.
Some servers may block CMake download traffic such as
file(DOWNLOAD …).
A web browser from the same computer may work–this is a symptom of server user agent blocking.
This script demonstrates setting a custom HTTP user agent to get around servers that block non-allow-listed user agents.
The proper “sink” may need to be selected to hear sound.
Inspect the device list looking for say “Macbook Speakers” and set the default audio output device like: