mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 03:39:43 -06:00
CMakeDependentOption: Revert "Allow parentheses in the depends string"
Revert commit 0665d9092e (CMakeDependentOption: Allow parentheses in the
depends string, 2021-06-13, v3.21.0-rc1~32^2). It broke existing use
cases with parentheses in regular expressions. Also add a test for this.
Fixes: #22447
This commit is contained in:
@@ -42,10 +42,7 @@ macro(CMAKE_DEPENDENT_OPTION option doc default depends force)
|
||||
if(${option}_ISSET MATCHES "^${option}_ISSET$")
|
||||
set(${option}_AVAILABLE 1)
|
||||
foreach(d ${depends})
|
||||
string(REPLACE "(" " ( " _CMAKE_CDO_DEP "${d}")
|
||||
string(REPLACE ")" " ) " _CMAKE_CDO_DEP "${_CMAKE_CDO_DEP}")
|
||||
string(REGEX REPLACE " +" ";" CMAKE_DEPENDENT_OPTION_DEP "${_CMAKE_CDO_DEP}")
|
||||
unset(_CMAKE_CDO_DEP)
|
||||
string(REGEX REPLACE " +" ";" CMAKE_DEPENDENT_OPTION_DEP "${d}")
|
||||
if(${CMAKE_DEPENDENT_OPTION_DEP})
|
||||
else()
|
||||
set(${option}_AVAILABLE 0)
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
include(CMakeDependentOption)
|
||||
|
||||
set(A 1)
|
||||
set(B 1)
|
||||
set(C 0)
|
||||
cmake_dependent_option(USE_FOO "Use Foo" ON "A AND (B OR C)" OFF)
|
||||
message(STATUS "USE_FOO='${USE_FOO}'")
|
||||
5
Tests/RunCMake/CMakeDependentOption/Regex.cmake
Normal file
5
Tests/RunCMake/CMakeDependentOption/Regex.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
include(CMakeDependentOption)
|
||||
|
||||
set(FOO "lower")
|
||||
cmake_dependent_option(USE_FOO "Use Foo" ON "FOO MATCHES (UPPER|lower)" OFF)
|
||||
message(STATUS "USE_FOO='${USE_FOO}'")
|
||||
@@ -1,3 +1,3 @@
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake_script(Parentheses)
|
||||
run_cmake_script(Regex)
|
||||
|
||||
Reference in New Issue
Block a user