To ensure the user set compile flags take precedence by appearing later in the command line vs. CMake’s automatic flags, use
add_compile_options
to set language-specific or project-wide compiler options.
target_compile_options
is similar, but applies to only one target.
The
generator expression$<$<COMPILE_LANGUAGE:C>:...> is used to only add the flag for the C language.
This is important as many compiler options are language-specific, particularly for C / C++ and Fortran projects.
If one truly needs to wipe out all CMake automatic flags, try settingCMAKE_FLAGS
variable to an
empty string.
Raspberry Pi 3 or newer, as GNU Radio can tax the CPU and IO of modest ARM processors. GNU Radio requires at least an ARMv7 processor. However many applications benefit from Raspberry Pi 4 or newer. Get at least the 4 GB RAM model.
Install GNU Radio. This takes more than 10 minutes even with a fast SD card.
Git uses the
GIT_EDITOR
environment variable to determine the text editor to use for commit messages.
Alternatively, to keep the editor configuration in the ~/.gitconfig file, set the Git text editor via the core.editor configuration variable.
This is done via Git global config:
Most environment variable have alphanumeric names and don’t need any special consideration to access.
On Windows, some important programs still use the “Program Files (x86)” directory, denoted by environment variable “ProgramFiles(x86)”.
programenvimplicitnoneinteger::icharacter(100)::pathcallget_environment_variable('ProgramFiles(x86)',path,status=i)if(i/=0)error stop"env var ProgramFiles(x86) not found"print'(a)',pathendprogramenv
If rotating tick labels, the overall axes typically need to be positioned to allow for the rotated labels, otherwise the tick labels can be cut off the figure edges.
The axes position is updated automatically with
constrained_layout
option of figure().
If a DLL conflicts with a programs needed DLLs, the program may quit with a specific message, or it may silently exit.
The
return code
may correspond to segfault or other error.
To help see if a DLL conflict is occurring, use
gdb
to run the program.
This works even for general programs that weren’t built on the system.
We suggest obtaining GDB via
MSYS2.
If there is a problem with a DLL, GDB will often print the name of the DLL.
If the DLL is in an unexpected location, this may indicate a directory that should not be in environment variable Path.
CMake has built-in support for C/C++ static code analysis tools such as
CppCheck.
Apply CppCheck to CMake targets with
CMakeLists.txt
by setting
CMAKE_CXX_CPPCHECK.
File “cppcheck.supp” contains suppressions for false positives.
NOTE: CMake runs cppcheck from an arbitrary directory, so per-file suppressions in the file don’t work as usual.
To suppress a warning for a specific file, use the --suppress option to cppcheck in CMakeLists.txt like:
Users (or developers!) may not realize that the shell expands glob asterisk * unless enclosed in quotes.
This can surprise users unfamiliar with this shell behavior, say when using Python argparse with position-based arguments.
Say a user has a single file to process in a directory, and doesn’t want to type the long filename, so they type:
python myScript.py ~/data/*.h5 32
Here we assume myScript.py expects two positional arguments, the first being a filename, and the second being an integer.
If more than one “*.h5” file subsequently exists and myScript.py is run, the actual input to Python would be like:
CMake ExternalProject works for many types of sub-projects across CMake generators.
An implementation detail of Ninja is by default ExternalProject doesn’t print progress until each ExternalProject step is finished.
For large external projects that take several minutes to download and build, users could be confused thinking CMake has frozen up.
To make ExternalProject show live progress as it does with Makefiles generators, add the
USES_TERMINAL_* true
arguments to ExternalProject_Add.