Helper function that prints all variables matching pattern
function(print_cmake_variables_matching pattern)
get_cmake_property(_variableNames VARIABLES)
string(TOLOWER "${pattern}" pattern_lower)
foreach (_variableName ${_variableNames})
string(TOLOWER "${_variableName}" variable_lower)
if (variable_lower MATCHES "${pattern_lower}")
message(STATUS "${_variableName}=${${_variableName}}")
endif()
endforeach()
endfunction()
print_cmake_variables_matching("^OpenCV")
function(print_target_properties target)
get_all_properties(_props)
foreach(_prop IN LISTS _props)
get_target_property(_value ${target} ${_prop})
if(NOT _value STREQUAL "NOTFOUND")
message(STATUS "${target} - ${_prop} = ${_value}")
endif()
endforeach()
endfunction()
# Helper function to get all known target properties
function(get_all_properties out_var)
set(_all_props
# General
NAME
TYPE
IMPORTED
LINK_LIBRARIES
LINK_INTERFACE_LIBRARIES
INTERFACE_LINK_LIBRARIES
INTERFACE_LINK_DEPENDS
INTERFACE_LINK_OPTIONS
INTERFACE_INCLUDE_DIRECTORIES
INTERFACE_COMPILE_DEFINITIONS
INTERFACE_COMPILE_FEATURES
INTERFACE_COMPILE_OPTIONS
INTERFACE_SOURCES
SOURCES
INCLUDE_DIRECTORIES
COMPILE_DEFINITIONS
COMPILE_OPTIONS
COMPILE_FEATURES
POSITION_INDEPENDENT_CODE
C_STANDARD
CXX_STANDARD
CUDA_STANDARD
LINK_OPTIONS
OUTPUT_NAME
VERSION
ARCHIVE_OUTPUT_DIRECTORY
LIBRARY_OUTPUT_DIRECTORY
RUNTIME_OUTPUT_DIRECTORY
)
set(${out_var} "${_all_props}" PARENT_SCOPE)
endfunction()
print_target_properties(MyTarget)
function(print_all_target_properties target)
get_target_property(_dummy ${target} NAME)
if(_dummy STREQUAL "NOTFOUND")
message(FATAL_ERROR "Target '${target}' does not exist.")
endif()
get_property(_props GLOBAL PROPERTY TARGET_PROPERTIES)
list(REMOVE_DUPLICATES _props)
foreach(_prop IN LISTS _props)
get_target_property(_value ${target} ${_prop})
if(NOT _value STREQUAL "NOTFOUND")
message(STATUS "${target} - ${_prop} = ${_value}")
endif()
endforeach()
endfunction()
print_all_target_properties(MyTarget)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug$<$<CONFIG:Debug>Debug>")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Release>Release>")