Skip to content

Commit 25624bc

Browse files
committed
print MPI::MPI_Fortran target props
1 parent 24fb5c1 commit 25624bc

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ LANGUAGES C Fortran
66

77
enable_testing()
88

9-
message(STATUS "CMake ${CMAKE_VERSION} Generator ${CMAKE_GENERATOR}")
9+
message(STATUS "CMake ${CMAKE_VERSION} Generator ${CMAKE_GENERATOR} Build type ${CMAKE_BUILD_TYPE}")
1010

1111
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
1212

1313
# this has checks that can be reused in other projects as well
1414
include(cmake/mpi.cmake)
1515

16+
include(cmake/print_target_props.cmake)
17+
print_target_props(MPI::MPI_Fortran)
18+
1619
include(cmake/compilers.cmake)
1720

1821
add_subdirectory(test)

cmake/mpi.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
include(CheckSourceCompiles)
22

33
set(MPI_DETERMINE_LIBRARY_VERSION true)
4+
45
find_package(MPI REQUIRED COMPONENTS C Fortran)
6+
57
message(STATUS "MPI Library Version: ${MPI_C_LIBRARY_VERSION_STRING}")
68

79
# Cray FindMPI.cmake has a bug where the plain CMake variables aren't defined, only imported target is

cmake/print_target_props.cmake

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
execute_process(COMMAND ${CMAKE_COMMAND} --help-property-list
2+
OUTPUT_VARIABLE _props OUTPUT_STRIP_TRAILING_WHITESPACE
3+
)
4+
5+
STRING(REGEX REPLACE "\n" ";" _props "${_props}")
6+
7+
list(REMOVE_DUPLICATES _props)
8+
9+
function(print_target_props tgt)
10+
if(NOT TARGET ${tgt})
11+
message(WARNING "Target ${tgt} not found")
12+
return()
13+
endif()
14+
15+
message(STATUS "Target: ${tgt} properties")
16+
foreach(p IN LISTS _props)
17+
if(p MATCHES "<CONFIG>" AND NOT CMAKE_BUILD_TYPE)
18+
continue()
19+
endif()
20+
21+
string(REPLACE "<CONFIG>" "${CMAKE_BUILD_TYPE}" p "${p}")
22+
23+
get_property(v TARGET ${tgt} PROPERTY "${p}")
24+
if(v)
25+
message(STATUS "${tgt} ${p} = ${v}")
26+
endif()
27+
endforeach()
28+
endfunction()

0 commit comments

Comments
 (0)