Skip to content

Commit

Permalink
add feature JSON output
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Sep 29, 2024
1 parent 8de69e5 commit 1b6ab5d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -40,3 +41,5 @@ foreach(a IN ITEMS git system)
endforeach()

file(GENERATE OUTPUT .gitignore CONTENT "*")

include(cmake/features.cmake)
9 changes: 9 additions & 0 deletions cmake/f2018rank.cmake
Original file line number Diff line number Diff line change
@@ -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)
29 changes: 29 additions & 0 deletions cmake/features.cmake
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 1b6ab5d

Please sign in to comment.