CTest CDash scripts can use the function
ctest_empty_binary_directory
to recursively remove a CMake build directory to avoid hidden state between test runs in an overall build-test cycle.
However, this function will cause the overall CTest run to return a non-zero error code if CMakeCache.txt isn’t present in the build directory.
This is confusing in a CI system particularly.
While we do appreciate this safety feature over simply using
file(REMOVE_RECURSE),
it’s necessary to enclose in if() statements like below to avoid false errors.
Linux
modules
are often used by HPC systems allow using more current versions of software than are in the default system repositories.
A typical approach is to create an .sh file for a particular job type.
To avoid unexpected conflicts or hidden state, load only the modules necessary for a particular project.
Cray PE
Programming Environment
allows easy switching of compilers for
developing
and running applications on Cray supercomputers.
Use the Cray compiler wrappers cc, CC, and ftn instead of directly referencing the compiler backends gcc, g++, and gfortran.
In CMake script, detect if Cray PE is being used, regardless of compiler backend by detecting if environment variable
CRAYPE_VERSION
is set.
if(DEFINEDENV{CRAYPE_VERSION})message("Cray PE detected")endif()
CMake superprojects may have one project that builds binary executables with MPI and another project that runs those targets.
To avoid the overhead of FindMPI, one can use the following find_program() command to use “mpiexec”.
find_program(MPIEXEC_EXECUTABLENAMESmpiexecHINTS ${MPI_ROOT} ENVMPI_ROOTENVI_MPI_ROOTPATHS/usr/lib64ENVMINGWROOTENVMSMPI_BINPATH_SUFFIXESbinopenmpi/binmpich/binDOC"Runs an MPI program"REQUIRED)
The CMake generator expression
TARGET_FILE
yields the full path to a binary target file.
This is useful with add_custom_command() and add_test() when a script is used as part of those commands.
For CMake native commands, it’s usually not necessary to use TARGET_FILE.
Git doesn’t have any general letter-specific restrictions on branch names.
Organizations can implement push restrictions with services like GitHub to restrict branch names–for example bad words or regex patterns.
The Windows operating system has
general filename restrictions
that restrict several keywords from Git branch names.
A list of case-insensitive prohibited branch names
includes
Windows devices names.
For example on Windows:
> git switch -c con
fatal: cannot lock ref 'refs/heads/con': Unable to create '.git/refs/heads/con.lock': Invalid argument
Note that one can work with those branch names using Windows Subsystem for Linux (WSL), but even if you create such a branch, it will not work from native Windows:
Speed up Octave startup by a factor of 10-100x by not autoloading packages.
For each of the
Octave config files
that exist, comment out the line:
# pkg ("load", "auto");
Verify GNU Octave speedup fix: in Octave type
pkg list
if all packages are starred, that means you’re autoloading, which greatly slows down Octave startup.
The factor of 100 improvement in GNU Octave speedup was estimated with the command
time octave --eval'exit'
Before fix 4.904 seconds, after fix 0.072 seconds to load Octave.
CMake
implements
a
file(DOWNLOAD INACTIVITY_TIMEOUT)
option that uses curl CURLOPT_LOW_SPEED_TIME to fail much earlier than a TIMEOUT option would when the connection speed is extremely slow.
However, some systems intentionally block downloads, but do so in a way that fools the underlying curl library into not tripping INACTIVITY_TIMEOUT.
Rather than try to figure out a direct fix in curl for this apparently longstanding problem, we instead decide to implement a CMake configure-time
internet connectivity detection.
When a CTest test is comprised of a CMake script, this test can be setup as a FIXTURES_SETUP to avoid calling it repeatedly for each test, instead just once for a set of tests.
The key technique here is the URL connectivitycheck.gstatic.com/generate_204 that is used by Android devices to check connectivity.
Any similar URL with zero or tiny download size would also be suitable.