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()
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:
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:
The Windows Intel oneAPI compilers present Visual Studio-like command line options.
Intel
oneAPI toolkit
includes the Intel
MPI library,
which provides “mpiexec” needed to run MPI programs and
MPI compiler wrappers.
While Windows MPI users might find using WSL for MPI more convenient and performant, even using
Intel compilers in WSL,
some users may prefer native Windows MPI with Intel oneAPI.
The Intel oneAPI command prompt environment can be used or
use a script
Newer versions of Intel MPI have “mpiicx”, “mpiicpx” and “mpiifx” compiler wrappers.
Intel MPI on Windows is only for Intel oneAPI compiler and Visual Studio.
Although not often needed, a separate username can be used for Windows Intel MPI jobs by from Command Prompt:
runas /user:username cmd
Environment variables are not passed to the new window, so it may be necessary to run Intel compilervars.bat again.
It’s possible to
register
the user credential in the Windows registry.
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.