CMake configure time is often a convenient time to test if a directory or file is writable.
It can be useful to immediately stop with message(FATAL_ERROR) if a path is not writable.
For example, if CMAKE_INSTALL_PREFIX is not in a writable location – we want to fail right then and inform users what to do to correct the problem.
file(TOUCH) and file(MAKE_DIRECTORY) do not halt the configure step.
Rather, if a path isn’t writable CMake only errors at the end of configure.
Example solution:
This snippet generates a fatal error with text telling the user what to try:
set(test_path/path/to/test/.ignore)# could be done with random string filename in the desired path
execute_process(COMMAND ${CMAKE_COMMAND} -Etouch ${test_path}
RESULT_VARIABLEret)if(NOTretEQUAL"0")message(FATAL_ERROR"No write access to ${test_path}
<text for user to resolve issue>")endif()
USB-C display adapters (HDMI, DisplayPort) are a wonderful thing when they work correctly.
I prefer this solution to the docking ports on old bulky laptops.
A symptom is USB-C adapter works on one laptop, but not on another almost identical laptop model.
Symptoms include not being detected by the operating system, to showing a black screen, or very low resolution.
The solution seems to be to stick with expensive OEM display adapters, or at least long established brands.
The temptation of a cheap adapter can quickly turn to frustration or botched presentations.
Another thing to watch for is cheap adapters may fail intermittently when using more than one high bandwidth feature.
For example, using Gigabit Ethernet and HDMI on the cheap USB-C adapter simultaneously may fail intermittently during a conference call or teaching a class, which can be frustrating.
Some adapters that charge the laptop with a USB-C input for power may experience improper operations if the display adapter is plugged into the laptop while the USB-C power input is powered.
This problem may persist upon re-plugging the adapter to laptop and/or power cycling the monitor and laptop.
A workaround we’ve found is to unplug USB-C power input to the adapter, plug into the laptop with all the desired accessories, then finally plug USB-C power input into the adapter.
That is unexpected, but has worked for us sometimes.
SSL certificate checking can add security to web operations.
Some systems may need environment variable SSL_CERT_FILE for Matlab’s vendored curl.
As a last resort, certificate checking can be turned off, but this raises file integrity and security issues.
Instead of disabling certificate checking set environment variable SSL_CERT_FILE to the actual certificate location.
Matlab
or
GNU Octave
use the factory function weboptions() to control HTTP behavior for functions like websave() and webread(), including Timeout and SSL certificate.
This example sets reply timeout to 15 seconds and specifies custom
SSL certificate location
when environment variable SSL_CERT_FILE is set.
Connecting to HTTPS servers with curl or programs using curl such as
Matlab
requires curl knowing the location of system certificates.
If curl doesn’t know the certificates location, accessing HTTPS URLs may fail with:
On Windows if also using MSYS2, don’t add Meld.exe to environment variable Path as it has libstdc++.dll that conflicts with MSYS2 G++.
The symptom is the G++-built executable will segfault silently.
CMake itself is built with SSL by default.
If a user mistakenly builds CMake without SSL support, this is generally not usable as the vast majority of Internet sites require SSL / TLS to function.
Confusing errors result for CMake network operations like file(DOWNLOAD) in this case.
A project had three targets (static libraries) that were always used like:
libfoo.a libfooC.a
or
libfoo.a libfooFortran.a
and the target code reference each other extensively, such that the linker gives up when ld
–start-group
isn’t used.
Meson build system also adds --start-group ld option automatically.
To keep the targets with distinct compile definitions (including for “foo_src”) use CMake Object Libraries:
CMake ExternalProject builds subprojects isolated from the main CMake project.
For Visual Studio NMake projects, it is necessary to invoke the nmake command.
Cray PE can select from multiple compilers as backends for better language standard support while maintaining performance of Cray frontend optimizations.
Compilers such as Intel oneAPI themselves use GCC as a backend on Linux.
Manual configuration may be required as the default system GCC may be too old for the desired language standard features.
Or, the libstdc++ can be too old in the system default GCC.
These issues are remediated by purposeful specification of the Cray-Intel-GCC toolchain in a CMake
toolchain file.
This toolchain file can be copied to a common location like ~ and used among many projects,
such as
cray.cmake.