-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically detect target dependencies #3
Labels
Comments
Great idea! with this code appended to include(FeatureSummary)
feature_summary(
WHAT ALL
FILENAME ${CMAKE_CURRENT_SOURCE_DIR}/FeatureSummary.log) I will get his file contents:
|
This version seems better to parse and get only the list of include(FeatureSummary)
feature_summary(
WHAT REQUIRED_PACKAGES_FOUND
QUIET_ON_EMPTY
DESCRIPTION ""
FILENAME ${CMAKE_CURRENT_SOURCE_DIR}/RequiredPackagesFound.log) |
@TheLartians This seems a good starting point: set(current_targets main)
get_property(
_depends
TARGET ${current_targets}
PROPERTY INTERFACE_LINK_LIBRARIES
)
message(STATUS "${current_targets}: ${_depends}\n")
set(_property "PACKAGES_FOUND")
set(_currentFeatureText "")
get_property(_EnabledFeatures GLOBAL PROPERTY ${_property})
if(_EnabledFeatures)
list(REMOVE_DUPLICATES _EnabledFeatures)
endif()
message(STATUS "${_property}: ${_EnabledFeatures}")
set(_currentFeature PACKAGES_FOUND)
get_property(
_importedTargets
DIRECTORY ${CMAKE_CURRENT_SORUCE_DIR}
PROPERTY IMPORTED_TARGETS
)
foreach(_target ${_importedTargets})
list(FIND _depends ${_target} _indexInList)
if(NOT "${_indexInList}" STREQUAL "-1")
# NOTE: we need the unalias target name! CK
string(REGEX REPLACE "([^:]+::)" "" _targetName ${_target})
get_property(_version GLOBAL PROPERTY _CMAKE_${_targetName}_REQUIRED_VERSION)
message(STATUS "IMPORTED_TARGETS: ${_targetName} ${_version}")
endif()
endforeach()
# _CMAKE_dependency_REQUIRED_VERSION: >= 1.2
# _CMAKE_namespaced_dependency_REQUIRED_VERSION: >= 4.5.6
# _CMAKE_transitive_dependency_REQUIRED_VERSION: >= 7.8.9
# -- main: dependency;ns::namespaced_dependency;transitive_dependency::transitive_dependency
#
# -- PACKAGES_FOUND: dependency;namespaced_dependency;fmt;cxxopts;transitive_dependency
# -- IMPORTED_TARGETS: dependency >= 1.2
# -- IMPORTED_TARGETS: namespaced_dependency >= 4.5.6
# -- IMPORTED_TARGETS: transitive_dependency >= 7.8.9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Perhaps this is possible using FeatureSummary as suggested on the CMake slack.
The text was updated successfully, but these errors were encountered: