mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-03 21:00:01 -05:00
FeatureSummary: Introduce policy CMP0183 for full Condition Syntax
Closes: #26468
This commit is contained in:
@@ -57,6 +57,7 @@ Policies Introduced by CMake 3.32
|
|||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 1
|
:maxdepth: 1
|
||||||
|
|
||||||
|
CMP0183: add_feature_info() supports full Condition Syntax. </policy/CMP0183>
|
||||||
CMP0182: Create shared library archives by default on AIX. </policy/CMP0182>
|
CMP0182: Create shared library archives by default on AIX. </policy/CMP0182>
|
||||||
CMP0181: Link command-line fragment variables are parsed and re-quoted. </policy/CMP0181>
|
CMP0181: Link command-line fragment variables are parsed and re-quoted. </policy/CMP0181>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
CMP0183
|
||||||
|
-------
|
||||||
|
|
||||||
|
.. versionadded:: 3.32
|
||||||
|
|
||||||
|
:command:`add_feature_info` supports full :ref:`Condition Syntax`.
|
||||||
|
|
||||||
|
The ``<enabled>`` parameter accepts a :ref:`semicolon-separated list <CMake
|
||||||
|
Language Lists>` of conditions. CMake 3.31 and lower evaluate each
|
||||||
|
``condition`` as ``if(${condition})``, which does not properly handle
|
||||||
|
conditions with nested paren groups. CMake 3.32 and above instead prefer
|
||||||
|
to evaluate each ``condition`` as ``if(<condition>)``, where ``<condition>``
|
||||||
|
is re-parsed as if literally written in a call to :command:`if`. This
|
||||||
|
allows expressions like::
|
||||||
|
|
||||||
|
"A AND (B OR C)"
|
||||||
|
|
||||||
|
but requires expressions like::
|
||||||
|
|
||||||
|
"FOO MATCHES (UPPER|lower)"
|
||||||
|
|
||||||
|
to be re-written as::
|
||||||
|
|
||||||
|
"FOO MATCHES \"(UPPER|lower)\""
|
||||||
|
|
||||||
|
Policy ``CMP0183`` provides compatibility for projects that have not
|
||||||
|
been updated to expect the new behavior.
|
||||||
|
|
||||||
|
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.32
|
||||||
|
.. |WARNS_OR_DOES_NOT_WARN| replace:: warns
|
||||||
|
.. include:: STANDARD_ADVICE.txt
|
||||||
|
|
||||||
|
.. include:: DEPRECATED.txt
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
add_feature_info
|
||||||
|
----------------
|
||||||
|
|
||||||
|
* The :module:`FeatureSummary` module :command:`add_feature_info`
|
||||||
|
command now supports full :ref:`Condition Syntax`.
|
||||||
|
See policy :policy:`CMP0183`.
|
||||||
@@ -627,6 +627,10 @@ endfunction()
|
|||||||
.. versionchanged:: 3.8
|
.. versionchanged:: 3.8
|
||||||
``<enabled>`` can be a list of conditions.
|
``<enabled>`` can be a list of conditions.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.32
|
||||||
|
Full :ref:`Condition Syntax` is now supported for ``<enabled>``.
|
||||||
|
See policy :policy:`CMP0183`.
|
||||||
|
|
||||||
Example for setting the info for a feature:
|
Example for setting the info for a feature:
|
||||||
|
|
||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
@@ -635,15 +639,29 @@ endfunction()
|
|||||||
add_feature_info(Foo WITH_FOO "The Foo feature provides very cool stuff.")
|
add_feature_info(Foo WITH_FOO "The Foo feature provides very cool stuff.")
|
||||||
#]=======================================================================]
|
#]=======================================================================]
|
||||||
function(ADD_FEATURE_INFO _name _depends _desc)
|
function(ADD_FEATURE_INFO _name _depends _desc)
|
||||||
|
cmake_policy(GET CMP0183 _CDO_CMP0183
|
||||||
|
PARENT_SCOPE # undocumented, do not use outside of CMake
|
||||||
|
)
|
||||||
set(_enabled 1)
|
set(_enabled 1)
|
||||||
foreach(_d ${_depends})
|
if("x${_CDO_CMP0183}x" STREQUAL "xNEWx")
|
||||||
string(REGEX REPLACE " +" ";" _d "${_d}")
|
foreach(_d ${_depends})
|
||||||
if(${_d})
|
cmake_language(EVAL CODE "
|
||||||
else()
|
if(${_d})
|
||||||
set(_enabled 0)
|
else()
|
||||||
break()
|
set(_enabled 0)
|
||||||
endif()
|
endif()"
|
||||||
endforeach()
|
)
|
||||||
|
endforeach()
|
||||||
|
else()
|
||||||
|
foreach(_d ${_depends})
|
||||||
|
string(REGEX REPLACE " +" ";" _d "${_d}")
|
||||||
|
if(${_d})
|
||||||
|
else()
|
||||||
|
set(_enabled 0)
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
if (${_enabled})
|
if (${_enabled})
|
||||||
set_property(GLOBAL APPEND PROPERTY ENABLED_FEATURES "${_name}")
|
set_property(GLOBAL APPEND PROPERTY ENABLED_FEATURES "${_name}")
|
||||||
else ()
|
else ()
|
||||||
@@ -651,6 +669,12 @@ function(ADD_FEATURE_INFO _name _depends _desc)
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set_property(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_desc}" )
|
set_property(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_desc}" )
|
||||||
|
|
||||||
|
if("x${_CDO_CMP0183}x" STREQUAL "xx" AND "x${_depends}x" MATCHES "[^A-Za-z0-9_.; ]")
|
||||||
|
cmake_policy(GET_WARNING CMP0183 _CDO_CMP0183_WARNING)
|
||||||
|
message(AUTHOR_WARNING "${_CDO_CMP0183_WARNING}")
|
||||||
|
endif()
|
||||||
|
unset(_CDO_CMP0183)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -550,7 +550,10 @@ class cmMakefile;
|
|||||||
"Link command-line fragment variables are parsed and re-quoted.", 3, \
|
"Link command-line fragment variables are parsed and re-quoted.", 3, \
|
||||||
32, 0, WARN) \
|
32, 0, WARN) \
|
||||||
SELECT(POLICY, CMP0182, \
|
SELECT(POLICY, CMP0182, \
|
||||||
"Create shared library archives by default on AIX.", 3, 32, 0, WARN)
|
"Create shared library archives by default on AIX.", 3, 32, 0, WARN) \
|
||||||
|
SELECT(POLICY, CMP0183, \
|
||||||
|
"add_feature_info() supports full Condition Syntax.", 3, 32, 0, \
|
||||||
|
WARN)
|
||||||
|
|
||||||
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
|
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
|
||||||
#define CM_FOR_EACH_POLICY_ID(POLICY) \
|
#define CM_FOR_EACH_POLICY_ID(POLICY) \
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
-- The following features have been enabled:
|
||||||
|
|
||||||
|
\* Foo, Foo\.
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
include(FeatureSummary)
|
||||||
|
|
||||||
|
cmake_policy(SET CMP0183 NEW)
|
||||||
|
|
||||||
|
set(WITH_FOO 1)
|
||||||
|
set(WITH_BAR 1)
|
||||||
|
set(WITH_BAZ 0)
|
||||||
|
|
||||||
|
add_feature_info(Foo "WITH_FOO AND (WITH_BAR OR WITH_BAZ)" "Foo.")
|
||||||
|
|
||||||
|
feature_summary(WHAT ALL)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
^CMake Warning \(dev\) at [^
|
||||||
|
]*/Modules/FeatureSummary\.cmake:[0-9]+ \(message\):
|
||||||
|
Policy CMP0183 is not set: add_feature_info\(\) supports full Condition
|
||||||
|
Syntax\. Run "cmake --help-policy CMP0183" for policy details. Use the
|
||||||
|
cmake_policy command to set the policy and suppress this warning\.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
FeatureSummaryParentheses-CMP0183-WARN\.cmake:[0-9]+ \(add_feature_info\)
|
||||||
|
CMakeLists\.txt:[0-9]+ \(include\)
|
||||||
|
This warning is for project developers. Use -Wno-dev to suppress it.$
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
-- The following features have been enabled:
|
||||||
|
|
||||||
|
\* Bar, Bar\.
|
||||||
|
|
||||||
|
-- The following features have been disabled:
|
||||||
|
|
||||||
|
\* Foo, Foo\.
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
include(FeatureSummary)
|
||||||
|
|
||||||
|
set(WITH_FOO 1)
|
||||||
|
set(WITH_BAR 1)
|
||||||
|
set(WITH_BAZ 0)
|
||||||
|
|
||||||
|
add_feature_info(Foo "WITH_FOO AND (WITH_BAR OR WITH_BAZ)" "Foo.")
|
||||||
|
add_feature_info(Bar "WITH_FOO;WITH_BAR" "Bar.")
|
||||||
|
|
||||||
|
feature_summary(WHAT ALL)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
-- The following features have been enabled:
|
||||||
|
|
||||||
|
\* Foo, Foo\.
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
include(FeatureSummary)
|
||||||
|
|
||||||
|
cmake_policy(SET CMP0183 NEW)
|
||||||
|
|
||||||
|
set(FOO "lower")
|
||||||
|
add_feature_info(Foo "FOO MATCHES \"(UPPER|lower)\"" "Foo.")
|
||||||
|
|
||||||
|
feature_summary(WHAT ALL)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
-- The following features have been enabled:
|
||||||
|
|
||||||
|
\* Foo, Foo\.
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
include(FeatureSummary)
|
||||||
|
|
||||||
|
cmake_policy(SET CMP0183 OLD)
|
||||||
|
|
||||||
|
set(FOO "lower")
|
||||||
|
add_feature_info(Foo "FOO MATCHES (UPPER|lower)" "Foo.")
|
||||||
|
|
||||||
|
feature_summary(WHAT ALL)
|
||||||
@@ -21,3 +21,7 @@ run_cmake(FeatureSummaryCustomRequired)
|
|||||||
run_cmake(FeatureSummaryCustomRequiredListA)
|
run_cmake(FeatureSummaryCustomRequiredListA)
|
||||||
run_cmake(FeatureSummaryCustomRequiredListB)
|
run_cmake(FeatureSummaryCustomRequiredListB)
|
||||||
run_cmake(FeatureSummaryCustomDescription)
|
run_cmake(FeatureSummaryCustomDescription)
|
||||||
|
run_cmake(FeatureSummaryParentheses-CMP0183-NEW)
|
||||||
|
run_cmake(FeatureSummaryParentheses-CMP0183-WARN)
|
||||||
|
run_cmake(FeatureSummaryRegex-CMP0183-NEW)
|
||||||
|
run_cmake(FeatureSummaryRegex-CMP0183-OLD)
|
||||||
|
|||||||
Reference in New Issue
Block a user