From df8f43f0b7a9faa4bd1df68abbf9ff8142c410f9 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Tue, 13 Apr 2021 18:43:59 +0100 Subject: [PATCH] Temporary find portaudio package diagnostics --- CMake/Modules/Findportaudio.cmake | 55 +++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/CMake/Modules/Findportaudio.cmake b/CMake/Modules/Findportaudio.cmake index e64420b5d..2d69d9432 100644 --- a/CMake/Modules/Findportaudio.cmake +++ b/CMake/Modules/Findportaudio.cmake @@ -25,6 +25,59 @@ function(dump_cmake_variables) endforeach() endfunction() +# Get all propreties that cmake supports +execute_process(COMMAND cmake --help-property-list OUTPUT_VARIABLE CMAKE_PROPERTY_LIST) + +# Convert command output into a CMake list +STRING(REGEX REPLACE ";" "\\\\;" CMAKE_PROPERTY_LIST "${CMAKE_PROPERTY_LIST}") +STRING(REGEX REPLACE "\n" ";" CMAKE_PROPERTY_LIST "${CMAKE_PROPERTY_LIST}") +# Fix https://stackoverflow.com/questions/32197663/how-can-i-remove-the-the-location-property-may-not-be-read-from-target-error-i +#list(FILTER CMAKE_PROPERTY_LIST EXCLUDE REGEX "^LOCATION$|^LOCATION_|_LOCATION$") +# For some reason, "TYPE" shows up twice - others might too? +list(REMOVE_DUPLICATES CMAKE_PROPERTY_LIST) + +# build whitelist by filtering down from CMAKE_PROPERTY_LIST in case cmake is +# a different version, and one of our hardcoded whitelisted properties +# doesn't exist! +unset(CMAKE_WHITELISTED_PROPERTY_LIST) +foreach(prop ${CMAKE_PROPERTY_LIST}) + if(prop MATCHES "^(INTERFACE|[_a-z]|IMPORTED_LIBNAME_|MAP_IMPORTED_CONFIG_)|^(COMPATIBLE_INTERFACE_(BOOL|NUMBER_MAX|NUMBER_MIN|STRING)|EXPORT_NAME|IMPORTED(_GLOBAL|_CONFIGURATIONS|_LIBNAME)?|NAME|TYPE|NO_SYSTEM_FROM_IMPORTED)$") + list(APPEND CMAKE_WHITELISTED_PROPERTY_LIST ${prop}) + endif() +endforeach(prop) + +function(print_properties) + message ("CMAKE_PROPERTY_LIST = ${CMAKE_PROPERTY_LIST}") +endfunction(print_properties) + +function(print_whitelisted_properties) + message ("CMAKE_WHITELISTED_PROPERTY_LIST = ${CMAKE_WHITELISTED_PROPERTY_LIST}") +endfunction(print_whitelisted_properties) + +function(print_target_properties tgt) + if(NOT TARGET ${tgt}) + message("There is no target named '${tgt}'") + return() + endif() + + get_target_property(target_type ${tgt} TYPE) + if(target_type STREQUAL "INTERFACE_LIBRARY") + set(PROP_LIST ${CMAKE_WHITELISTED_PROPERTY_LIST}) + else() + set(PROP_LIST ${CMAKE_PROPERTY_LIST}) + endif() + + foreach (prop ${PROP_LIST}) + string(REPLACE "" "${CMAKE_BUILD_TYPE}" prop ${prop}) + # message ("Checking ${prop}") + get_property(propval TARGET ${tgt} PROPERTY ${prop} SET) + if (propval) + get_target_property(propval ${tgt} ${prop}) + message ("${tgt} ${prop} = ${propval}") + endif() + endforeach(prop) +endfunction(print_target_properties) + include (LibFindMacros) libfind_pkg_detect (portaudio portaudio-2.0 @@ -46,6 +99,8 @@ if (portaudio_FOUND AND NOT TARGET portaudio::portaudio) ) endif () +print_target_properties (portaudio::portaudio) + mark_as_advanced ( portaudio_INCLUDE_DIR portaudio_LIBRARY