CMake with the Ninja and Ninja Multi-Config generators virtually always work well together, including with Fortran projects.
To generate the dependency graph, CMake directs the Fortran compiler to
preprocess each Fortran code file
when using the Ninja generator.
In rare cases, some legacy Fortran large code files can generate unexpected and spurious syntax errors when using CMake + Ninja.
The workaround seems to be to use the GNU Make backend, we have found that works for the rare case this became an issue.
Windows can control WiFi from the Command Prompt, including WiFi AP preference order.
Via the Windows WiFi settings GUI page, the latest added WiFi pushes to the top of the preference stack.
This is typically not desired, as when setting up a device in general, one usually connects to the most needed WiFi AP first, and over time adds temporary or less desired WiFi, which Windows keeps at the top of the WiFi preference list.
command prompt procedure allows correcting the Windows WiFi preference order.
Show known WiFi AP
This command lists the known (previously connected) WiFi AP, just like shown in the Windows WiFi settings GUI:
netsh wlan show profiles
The WiFi AP are listed in preference order, from most preferred at the top to least preferred at the bottom.
A key piece of information needed from this command is:
Profiles on interface “Wi-Fi”
The name might be “Wi-Fi 2” or other if multiple WiFi adapters are in the PC.
Set WiFi preference order
Using the information from:
netsh wlan show profiles
Put the WiFi APs in the desired priority order like:
netsh wlan set profileorder my_work_wifi Wi-Fi 1
netsh wlan set profileorder my_home_wifi Wi-Fi 2
where the trailing integer is the position in the Windows WiFi preference.
Android 10 defaults to task switching swipe navigation.
Some workflows are much easier via the traditional 3-button navigation used by Android since Android 3.x / 4.x.
Also when wearing gloves, using 3-button navigation can work better.
Switch an Android 10 device back to traditional 3-button navigation (back, home, switch or triangle, circle square)
by going to Settings → System → Gestures → System navigation and select “3-button navigation”.
CMake can set compiler flags with three broad scope categories.
We set global and per-language options near the beginning of the top-level CMakeLists.txt, before any targets are declared, to avoid confusion about scope.
COMPILE_DEFINITIONS works in a similar fashion.
Note: where using
add_compile_options() can only be overridden for the fetched project by using the “negative” option in the fetched project.
While the per-language method can be overridden just by setting it again in the fetched project.
For example, the main project may desire -Wall but this may cause megabytes of warnings from a legacy Fetched project.
In this case, we suggest using the per-language rather than global method.
This example is for a C and Fortran project, where some flags apply to C and Fortran, and other flags are Fortran-specific.
project(FooLANGUAGESCFortran)if(CMAKE_Fortran_COMPILER_IDSTREQUALGNU)# options applying to any project language for this compiler
add_compile_options(-march=native)# Fortran-specific, note LEADING space
string(APPENDCMAKE_Fortran_FLAGS" -fimplicit-none")# options for Debug build type
string(APPENDCMAKE_Fortran_FLAGS_DEBUG" -Werror=array-bounds") if(CMAKE_Fortran_COMPILER_VERSIONVERSION_GREATER_EQUAL8) string(APPENDCMAKE_Fortran_FLAGS" -std=f2018") endif()endif()add_library(oldOBJECTlegacy.fold.f)# these options apply only to target "old"
The HDF5 format can be used for almost anything, including image stacks.
To signal graphical interactive HDF5 viewers that a dataset is an image stack, add
HDF5 image metadata,
as in this Python
import numpy as np
# images is a numpy ndarray N x X x Y imageswith h5py.File("image.h5", "w") as f:
h = f.create_dataset("/images", data=images)
h.attrs["CLASS"] = np.string_("IMAGE")
h.attrs["IMAGE_VERSION"] = np.string_("1.2")
h.attrs["IMAGE_SUBCLASS"] = np.string_("IMAGE_GRAYSCALE")
h.attrs["DISPLAY_ORIGIN"] = np.string_("LL")
h.attrs["IMAGE_WHITE_IS_ZERO"] = np.uint8(0)
will show an optional video player for this dataset due to the image metadata added.
For hand-written Makefile the order of libraries matters completely.
CMake attempts to determine the graph for library files, starting from the user specified order.
CMake will try a finite multiplicity to resolve the graph, but in tough cases of library interdependency library ordering may need to be influenced by
undefined reference to
occurs at linking of main executable: be sure the library is actually linked to the user library with
cmake --build build -v
Fortran module include
be sure the *.mod file directory is included, particularly to the main executable by setting the target properties like:
Finding Python is made more robust in CMake >= 3.15, which prioritizes location over version number.
Prior to CMake 3.15, even specifying Python3_ROOT could be overriden if the other Python was a higher vrsion.
Using the Python interpreter in CMake should generally be via PYTHON3_EXECUTABLE and not Python3::Interpreter.
CMake provides the imported target
only when the
This means that Python3::Interpreter is not available when using CTest, which is often when using the Python3 interpreter is desired.
Normally, to use Python interpreter from a CMake script, including in
typically default to OLD behavior compatible with prior versions of CMake.
automatically sets all the CMake policies to “new” through the minimum CMake version.
For example, a project with cmake_minimum_required(VERSION 3.14) implicitly sets to NEW all CMake policies CMP0088 and older.
New versions of CMake don’t get the benefits of new behaviors until specifying the new behavior is OK, either implicitly via cmake_minimum_required() or explicitly via cmake_policy().
The downsides of a too-old cmake_minimum_required() include that you have to set if(CMAKE_VERSION VERSION_GREATER_EQUAL ...) statements around extra cmake_policy() statements.
Here are a few CMake policies we generally use, typically implicitly by choosing at least CMake 3.13: