CMAKE_LINK_LIBRARY_USING_FEATURE
doesn’t have a
feature
to delay loading import for MSVC-like compilers flag like
/delayload.
Nonetheless, /delayload can be accomplished in a compact way as in the following example:
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.
Most Internet sites require SSL / TLS to function.
Confusing errors result for CMake network operations like file(DOWNLOAD) may result if CMake is built without SSL support.
Saving PDF of plots from Matlab is an effective way to use Matlab plots in LaTeX or for general sharing of high quality plots.
Matlab
exportgraphics,
helps create production-ready plots from Matlab.
We also recommend
tiledlayout
for creating subplots.
Use “exportgraphics” instead of the “print” and “saveas” functions, which are generally not recommended for saving plots.
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.