From d85cf49210bc1d58aa17c3d1199a80f4385c65bd Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Tue, 10 Nov 2026 10:43:05 -0500 Subject: [PATCH] v5: Add OS Detection --- CHANGELOG.md | 6 ++++++ esma.cmake | 1 + external_libraries/DetermineOS.cmake | 26 ++++++++++++++++++++++++++ external_libraries/OS.rc.in | 3 +++ 4 files changed, 36 insertions(+) create mode 100644 external_libraries/DetermineOS.cmake create mode 100644 external_libraries/OS.rc.in diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a72cbc..4cf7503 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Security +## [5.26.0] - 2026-11-10 + +### Added + +- Added `DetermineOS.cmake` and `OS.rc.in` files to record OS details at build time + ## [5.25.0] - 2026-11-06 ### Changed diff --git a/esma.cmake b/esma.cmake index 020c26a..36b1663 100644 --- a/esma.cmake +++ b/esma.cmake @@ -104,6 +104,7 @@ else() endif() include(DetermineSite) +include(DetermineOS) find_package(GitInfo) if (MPI_FOUND) include(DetermineMPIStack) diff --git a/external_libraries/DetermineOS.cmake b/external_libraries/DetermineOS.cmake new file mode 100644 index 0000000..f089c5c --- /dev/null +++ b/external_libraries/DetermineOS.cmake @@ -0,0 +1,26 @@ +##### OS Detection ##### + +# At NAS, there are two OSs: TOSS4 and TOSS5. As such, if you build on TOSS5, you +# must submit from TOSS5 to TOSS5 compute nodes (and vice versa). So we need to +# detect the OS and make a file like SITE.rc + +if(LINUX) + cmake_host_system_information(RESULT os_id QUERY DISTRIB_ID) + cmake_host_system_information(RESULT os_version QUERY DISTRIB_VERSION_ID) + cmake_host_system_information(RESULT os_name QUERY DISTRIB_PRETTY_NAME) +elseif(APPLE) + # cmake_host_system_information for distrib_id does not work on macOS + cmake_host_system_information(RESULT os_id QUERY OS_NAME) + cmake_host_system_information(RESULT os_version QUERY OS_RELEASE) + cmake_host_system_information(RESULT os_name QUERY OS_NAME) +endif() + +set(GEOS_OS_ID ${os_id} CACHE STRING "Detected OS ID for use with GEOS setup scripts") +set(GEOS_OS_VERSION ${os_version} CACHE STRING "Detected OS version for use with GEOS setup scripts") +set(GEOS_OS_NAME ${os_name} CACHE STRING "Detected OS name for use with GEOS setup scripts") +message(STATUS "Setting GEOS_OS_ID to ${GEOS_OS_ID}") +message(STATUS "Setting GEOS_OS_VERSION to ${GEOS_OS_VERSION}") +message(STATUS "Setting GEOS_OS_NAME to ${GEOS_OS_NAME}") + +configure_file(${CMAKE_CURRENT_LIST_DIR}/OS.rc.in ${CMAKE_CURRENT_BINARY_DIR}/OS.rc @ONLY) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OS.rc DESTINATION etc) diff --git a/external_libraries/OS.rc.in b/external_libraries/OS.rc.in new file mode 100644 index 0000000..b43baf7 --- /dev/null +++ b/external_libraries/OS.rc.in @@ -0,0 +1,3 @@ +OS_ID: @GEOS_OS_ID@ +OS_VERSION: @GEOS_OS_VERSION@ +OS_NAME: @GEOS_OS_NAME@