Discussion:
[cmake-developers] Retrieving OS Version in CMake
Brad King
2018-06-05 14:54:06 UTC
Permalink
Would there be a use case for a Module that could retrieve
OS name and version
We do have these variables:

https://cmake.org/cmake/help/v3.11/variable/CMAKE_HOST_SYSTEM_NAME.html
https://cmake.org/cmake/help/v3.11/variable/CMAKE_HOST_SYSTEM_VERSION.html

and this command:

https://cmake.org/cmake/help/v3.11/command/cmake_host_system_information.html

but...
(e.g. on macOS parse “sw_vers” to get “Mac OS X” and “10.13.4”, on Linux
parse /etc/os-release to get “Fedora” and “28”)?
...they don't go down to this level of detail. Perhaps the

cmake_host_system_information

command could be taught additional queries for that.

-Brad
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailma
Harry Mallon
2018-06-05 15:24:45 UTC
Permalink
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 ***@codex.online | T +44 203 7000 989
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-deve
Brad King
2018-06-05 15:38:24 UTC
Permalink
Post by Harry Mallon
Or is it best to add new fields?
We should only add new fields and revise documentation to match
existing behavior.
Post by Harry Mallon
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"
A separate LINUX_DISTRO sounds good, but we'd need to make sure
whatever convention is used for the version (in the name or as
a separate value) makes sense for all distros' conventions.

-Brad
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers
Loading...