diff --git a/CMakeLists.txt b/CMakeLists.txt index 71488f7..ba16b01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,13 +6,16 @@ LANGUAGES C Fortran enable_testing() -message(STATUS "CMake ${CMAKE_VERSION} Generator ${CMAKE_GENERATOR}") +message(STATUS "CMake ${CMAKE_VERSION} Generator ${CMAKE_GENERATOR} Build type ${CMAKE_BUILD_TYPE}") list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) # this has checks that can be reused in other projects as well include(cmake/mpi.cmake) +include(cmake/print_target_props.cmake) +print_target_props(MPI::MPI_Fortran) + include(cmake/compilers.cmake) add_subdirectory(test) diff --git a/cmake/mpi.cmake b/cmake/mpi.cmake index 586f345..496b2fa 100644 --- a/cmake/mpi.cmake +++ b/cmake/mpi.cmake @@ -1,7 +1,9 @@ include(CheckSourceCompiles) set(MPI_DETERMINE_LIBRARY_VERSION true) + find_package(MPI REQUIRED COMPONENTS C Fortran) + message(STATUS "MPI Library Version: ${MPI_C_LIBRARY_VERSION_STRING}") # Cray FindMPI.cmake has a bug where the plain CMake variables aren't defined, only imported target is diff --git a/cmake/print_target_props.cmake b/cmake/print_target_props.cmake new file mode 100644 index 0000000..3b27cfa --- /dev/null +++ b/cmake/print_target_props.cmake @@ -0,0 +1,28 @@ +execute_process(COMMAND ${CMAKE_COMMAND} --help-property-list +OUTPUT_VARIABLE _props OUTPUT_STRIP_TRAILING_WHITESPACE +) + +STRING(REGEX REPLACE "\n" ";" _props "${_props}") + +list(REMOVE_DUPLICATES _props) + +function(print_target_props tgt) + if(NOT TARGET ${tgt}) + message(WARNING "Target ${tgt} not found") + return() + endif() + + message(STATUS "Target: ${tgt} properties") + foreach(p IN LISTS _props) + if(p MATCHES "" AND NOT CMAKE_BUILD_TYPE) + continue() + endif() + + string(REPLACE "" "${CMAKE_BUILD_TYPE}" p "${p}") + + get_property(v TARGET ${tgt} PROPERTY "${p}") + if(v) + message(STATUS "${tgt} ${p} = ${v}") + endif() + endforeach() +endfunction()