Skip to content

Commit 1b6ab5d

Browse files
committed
add feature JSON output
1 parent 8de69e5 commit 1b6ab5d

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ include(CheckSourceRuns)
1717

1818
# --- compiler checks
1919

20-
foreach(i IN ITEMS f03abstract f03charalloc f03ieee f03utf8 f03selectType
21-
f08contig f08execute f08kind
22-
f18abstract f18assumed_rank f18prop f18random f2018rank
23-
f2023rank_integer f2023ternary f2023tokenize f2023real16)
20+
set(f2003features f03abstract f03charalloc f03ieee f03utf8 f03selectType)
21+
set(f2008features f08contig f08execute f08kind)
22+
set(f2018features f18abstract f18assumed_rank f18prop f18random f2018rank)
23+
set(f2023features f2023rank_integer f2023ternary f2023tokenize f2023real16)
2424

25+
foreach(i IN LISTS f2003features f2008features f2018features f2023features)
2526
include(cmake/${i}.cmake)
2627
endforeach()
2728

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

4243
file(GENERATE OUTPUT .gitignore CONTENT "*")
44+
45+
include(cmake/features.cmake)

cmake/f2018rank.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
2+
3+
check_source_compiles(Fortran "subroutine poly(A)
4+
intrinsic :: rank
5+
real, intent(in) :: A(:)
6+
real :: B(rank(A))
7+
B = A
8+
end subroutine"
9+
f2018rank)

cmake/features.cmake

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
set(j "{}")
2+
3+
foreach(s IN LISTS f2003features f2008features f2018features f2023features)
4+
foreach(f IN LISTS s)
5+
if(${f})
6+
set(hasf true)
7+
else()
8+
set(hasf false)
9+
endif()
10+
11+
string(JSON j SET ${j} ${f} ${hasf})
12+
endforeach()
13+
endforeach()
14+
15+
16+
string(JSON j SET ${j} compiler "{}")
17+
string(JSON j SET ${j} compiler vendor \"${CMAKE_Fortran_COMPILER_ID}\")
18+
string(JSON j SET ${j} compiler version \"${CMAKE_Fortran_COMPILER_VERSION}\")
19+
string(JSON j SET ${j} compiler system \"${CMAKE_SYSTEM_NAME}\")
20+
string(JSON j SET ${j} compiler system_version \"${CMAKE_SYSTEM_VERSION}\")
21+
string(JSON j SET ${j} compiler target \"${CMAKE_SYSTEM_PROCESSOR}\")
22+
string(JSON j SET ${j} compiler flags \"${CMAKE_Fortran_FLAGS}\")
23+
string(JSON j SET ${j} compiler sysroot \"${CMAKE_OSX_SYSROOT}\")
24+
25+
set(feature_file ${CMAKE_CURRENT_BINARY_DIR}/features.json)
26+
27+
file(WRITE ${feature_file} ${j})
28+
29+
message(STATUS "See ${feature_file} for features enabled")

0 commit comments

Comments
 (0)