CMake: improve output of fl_debug_target()

Todo: check "*LOCATION" properties ...
This commit is contained in:
Albrecht Schlosser 2024-05-05 19:40:27 +02:00
parent 38e1d6b099
commit 53543acb2e

View File

@ -97,25 +97,36 @@ function(fl_debug_target name)
set(var "${name}") set(var "${name}")
fl_expand_name(var "${name}" 40) fl_expand_name(var "${name}" 40)
# these properties are always supported: if(NOT TARGET ${name})
set(_props ALIASED_TARGET TYPE) message(STATUS "${var} = <not a target>")
message(STATUS "")
# these properties are not supported before 3.20 for *some* target types return()
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20)
list(APPEND _props
LOCATION
IMPORTED_LOCATION
INTERFACE_LOCATION)
endif() endif()
get_target_property(_type ${name} TYPE)
# message(STATUS "${var} = target, type = ${_type}")
# these properties are always supported: # these properties are always supported:
set(_props NAME TYPE ALIASED_TARGET)
# these properties can't be read from executable target types
### if(NOT _type STREQUAL "EXECUTABLE")
### list(APPEND _props
### LOCATION
### IMPORTED_LOCATION
### INTERFACE_LOCATION)
### endif()
list(APPEND _props list(APPEND _props
INCLUDE_DIRECTORIES
LINK_DIRECTORIES
LINK_LIBRARIES
COMPILE_DEFINITIONS
INTERFACE_COMPILE_DEFINITIONS
INTERFACE_INCLUDE_DIRECTORIES INTERFACE_INCLUDE_DIRECTORIES
INTERFACE_LINK_DIRECTORIES INTERFACE_LINK_DIRECTORIES
INTERFACE_LINK_LIBRARIES) INTERFACE_LINK_LIBRARIES)
if(TARGET ${name})
message(STATUS "${var} = <target>")
foreach(prop ${_props}) foreach(prop ${_props})
get_target_property(${prop} ${name} ${prop}) get_target_property(${prop} ${name} ${prop})
if(NOT ${prop}) if(NOT ${prop})
@ -123,9 +134,6 @@ function(fl_debug_target name)
endif() endif()
fl_debug_var(${prop}) fl_debug_var(${prop})
endforeach() endforeach()
else()
message(STATUS "${var} = <not a target>")
endif()
message(STATUS "") message(STATUS "")
endfunction(fl_debug_target) endfunction(fl_debug_target)