From 1b6ab5d221a971870033a0a6b56f279bd9835999 Mon Sep 17 00:00:00 2001 From: scivision Date: Sat, 28 Sep 2024 21:42:08 -0400 Subject: [PATCH] add feature JSON output --- CMakeLists.txt | 11 +++++++---- cmake/f2018rank.cmake | 9 +++++++++ cmake/features.cmake | 29 +++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 cmake/f2018rank.cmake create mode 100644 cmake/features.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4543415..1a6d8e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,11 +17,12 @@ include(CheckSourceRuns) # --- compiler checks -foreach(i IN ITEMS f03abstract f03charalloc f03ieee f03utf8 f03selectType - f08contig f08execute f08kind - f18abstract f18assumed_rank f18prop f18random f2018rank - f2023rank_integer f2023ternary f2023tokenize f2023real16) +set(f2003features f03abstract f03charalloc f03ieee f03utf8 f03selectType) +set(f2008features f08contig f08execute f08kind) +set(f2018features f18abstract f18assumed_rank f18prop f18random f2018rank) +set(f2023features f2023rank_integer f2023ternary f2023tokenize f2023real16) +foreach(i IN LISTS f2003features f2008features f2018features f2023features) include(cmake/${i}.cmake) endforeach() @@ -40,3 +41,5 @@ foreach(a IN ITEMS git system) endforeach() file(GENERATE OUTPUT .gitignore CONTENT "*") + +include(cmake/features.cmake) diff --git a/cmake/f2018rank.cmake b/cmake/f2018rank.cmake new file mode 100644 index 0000000..0e23f2a --- /dev/null +++ b/cmake/f2018rank.cmake @@ -0,0 +1,9 @@ +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +check_source_compiles(Fortran "subroutine poly(A) + intrinsic :: rank + real, intent(in) :: A(:) + real :: B(rank(A)) + B = A +end subroutine" +f2018rank) diff --git a/cmake/features.cmake b/cmake/features.cmake new file mode 100644 index 0000000..aea2087 --- /dev/null +++ b/cmake/features.cmake @@ -0,0 +1,29 @@ +set(j "{}") + +foreach(s IN LISTS f2003features f2008features f2018features f2023features) + foreach(f IN LISTS s) + if(${f}) + set(hasf true) + else() + set(hasf false) + endif() + + string(JSON j SET ${j} ${f} ${hasf}) + endforeach() +endforeach() + + +string(JSON j SET ${j} compiler "{}") +string(JSON j SET ${j} compiler vendor \"${CMAKE_Fortran_COMPILER_ID}\") +string(JSON j SET ${j} compiler version \"${CMAKE_Fortran_COMPILER_VERSION}\") +string(JSON j SET ${j} compiler system \"${CMAKE_SYSTEM_NAME}\") +string(JSON j SET ${j} compiler system_version \"${CMAKE_SYSTEM_VERSION}\") +string(JSON j SET ${j} compiler target \"${CMAKE_SYSTEM_PROCESSOR}\") +string(JSON j SET ${j} compiler flags \"${CMAKE_Fortran_FLAGS}\") +string(JSON j SET ${j} compiler sysroot \"${CMAKE_OSX_SYSROOT}\") + +set(feature_file ${CMAKE_CURRENT_BINARY_DIR}/features.json) + +file(WRITE ${feature_file} ${j}) + +message(STATUS "See ${feature_file} for features enabled")