-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprop.cmake
More file actions
37 lines (32 loc) · 1.48 KB
/
Copy pathprop.cmake
File metadata and controls
37 lines (32 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## https://stackoverflow.com/questions/32183975/how-to-print-all-the-properties-of-a-target-in-cmake/56738858#56738858
## https://stackoverflow.com/a/56738858/3743145
## Get all properties 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}")
list(REMOVE_DUPLICATES 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$")
list(SORT CMAKE_PROPERTY_LIST)
function(print_target_properties tgt)
if(NOT TARGET ${tgt})
message("There is no target named '${tgt}'")
return()
endif()
foreach (prop ${CMAKE_PROPERTY_LIST})
#message ( STATUS " prop 1 = ${prop} " )
string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
string(REPLACE "<CONFIG>" "${BUILD_TYPE}" prop ${prop})
#message ( STATUS " prop 2 = ${prop} " )
get_target_property(propval ${tgt} ${prop})
if (propval)
#message ("${tgt} ${prop} = ${propval}")
include(CMakePrintHelpers)
cmake_print_properties(
TARGETS ${tgt}
PROPERTIES ${prop}
)
endif()
endforeach()
endfunction()