[cmake-developers] Retrieving OS Version in CMake

Harry Mallon Harry.Mallon at codex.online
Tue Jun 5 11:24:45 EDT 2018


Hi Brad,

I hadn't seen cmake_host_system_information, that is pretty useful. It already parses "sw_vers" on macOS. "OS_RELEASE" is "10.13.5" for example. So that is half of the problem. This does mean that "OS_NAME" does not equal "CMAKE_HOST_SYSTEM_NAME" on macOS, which is indicated by the docs. (https://cmake.org/cmake/help/v3.11/command/cmake_host_system_information.html).

Would you say on Linux we would change the values of current cmake_host_system_information variables to match the intent on macOS? Or is it best to add new fields?

e.g. one of the below?
* OS_NAME: "Linux" -> "Fedora", OS_RELEASE: "$(uname -r)" -> "28"
* OS_RELEASE: "$(uname -r)" -> "Fedora  28"
* LINUX_DISTRO: "Fedora 28"

It seems at the moment that macOS behaves slightly differently to Linux. I haven’t tried Windows or other yet. Maybe the docs for cmake_host_system_information should be expanded to cover behaviour on common platforms and a little more info on intent of each thing?

Best,
Harry


Harry Mallon
CODEX | Senior Software Engineer
60 Poland Street | London | England | W1F 7NT
E harry.mallon at codex.online | T +44 203 7000 989


More information about the cmake-developers mailing list