Skip to content
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

CMake: small updates to process_feature() and preparatory cleanup #15251

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 38 additions & 11 deletions cmake/macros/macro_process_feature.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
# search.
#
# Valid suffixes are
# TARGETS TARGETS_RELEASE TARGETS_DEBUG
# LIBRARIES LIBRARIES_RELEASE LIBRARIES_DEBUG
# INCLUDE_DIRS
# DEFINITIONS DEFINITIONS_RELEASE DEFINITIONS_DEBUG
Expand Down Expand Up @@ -143,21 +144,47 @@ macro(process_feature _feature)

else()

if("${${_arg}}" MATCHES "^\\s*$" OR "${${_arg}}" MATCHES "-NOTFOUND")
#
# We prefer that values are specified directly but also have to
# support the old behavior of supplying a variable name:
#
set(_value "${_arg}")
if(DEFINED "${_value}")
# We have encountered a variable name:
set(_value "${${_value}}")
endif()

#
# Sanity checks:
#
# - The final string must neither end in -NOTFOUND which is
# CMake's way of telling us that it wasn't able to find a
# library/file, nor be only whitespace:
#
if("${_value}" MATCHES "-NOTFOUND" OR "${_value}" MATCHES "^\\s*$")
if(_required)
message(STATUS
" ${_feature}_${_current_suffix}: *** Required value/variable \"${_arg}\" empty or set to NOTFOUND ***"
)
set(${_feature}_FOUND FALSE)
endif()
#
# - The final string must either be a target, a (list) of
# file paths, compile/link flags, or a generator expression.
#
elseif( NOT TARGET "${_value}" AND
NOT "${_value}" MATCHES "[;\.\\/]" AND
NOT "${_value}" MATCHES "^-" AND
NOT "${_value}" MATCHES "^\$" AND
NOT "${_current_suffix}" MATCHES "DEFINITION")
if(_required)
if("${${_arg}}" MATCHES "^\\s*$")
message(STATUS
" ${_feature}_${_current_suffix}: *** Required variable \"${_arg}\" empty ***"
)
else()
message(STATUS
" ${_feature}_${_current_suffix}: *** Required variable \"${_arg}\" set to NOTFOUND ***"
)
endif()
message(STATUS
" ${_feature}_${_current_suffix}: *** Required value/variable \"${_arg}\" not set empty or empty ***"
)
set(${_feature}_FOUND FALSE)
endif()
else()
list(APPEND _temp_${_current_suffix} ${${_arg}})
list(APPEND _temp_${_current_suffix} ${_value})
endif()
endif()
endif()
Expand Down