diff options
author | Brad King <brad.king@kitware.com> | 2021-06-15 12:39:29 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-06-15 12:39:37 (GMT) |
commit | 9a31298ed6485813de1996f098230f3dfa50c3e5 (patch) | |
tree | a46ead5ac3a7eff48fb45688f1900621548c2885 | |
parent | b302dd776cfd5ad22aff343c3c90a4949e6bbd13 (diff) | |
parent | 0665d9092e5099c581e47f3be5360d711d176c2d (diff) | |
download | CMake-9a31298ed6485813de1996f098230f3dfa50c3e5.zip CMake-9a31298ed6485813de1996f098230f3dfa50c3e5.tar.gz CMake-9a31298ed6485813de1996f098230f3dfa50c3e5.tar.bz2 |
Merge topic 'CMakeDependentOption'
0665d9092e CMakeDependentOption: Allow parentheses in the depends string
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6225
-rw-r--r-- | Modules/CMakeDependentOption.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeDependentOption/Parentheses-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeDependentOption/Parentheses.cmake | 7 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeDependentOption/RunCMakeTest.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 1 |
5 files changed, 16 insertions, 1 deletions
diff --git a/Modules/CMakeDependentOption.cmake b/Modules/CMakeDependentOption.cmake index 96855d2..0a291f2 100644 --- a/Modules/CMakeDependentOption.cmake +++ b/Modules/CMakeDependentOption.cmake @@ -42,7 +42,10 @@ macro(CMAKE_DEPENDENT_OPTION option doc default depends force) if(${option}_ISSET MATCHES "^${option}_ISSET$") set(${option}_AVAILABLE 1) foreach(d ${depends}) - string(REGEX REPLACE " +" ";" CMAKE_DEPENDENT_OPTION_DEP "${d}") + 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) if(${CMAKE_DEPENDENT_OPTION_DEP}) else() set(${option}_AVAILABLE 0) diff --git a/Tests/RunCMake/CMakeDependentOption/Parentheses-stdout.txt b/Tests/RunCMake/CMakeDependentOption/Parentheses-stdout.txt new file mode 100644 index 0000000..15b56a1 --- /dev/null +++ b/Tests/RunCMake/CMakeDependentOption/Parentheses-stdout.txt @@ -0,0 +1 @@ +-- USE_FOO='ON' diff --git a/Tests/RunCMake/CMakeDependentOption/Parentheses.cmake b/Tests/RunCMake/CMakeDependentOption/Parentheses.cmake new file mode 100644 index 0000000..c2951f1 --- /dev/null +++ b/Tests/RunCMake/CMakeDependentOption/Parentheses.cmake @@ -0,0 +1,7 @@ +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}'") diff --git a/Tests/RunCMake/CMakeDependentOption/RunCMakeTest.cmake b/Tests/RunCMake/CMakeDependentOption/RunCMakeTest.cmake new file mode 100644 index 0000000..bbdd3e5 --- /dev/null +++ b/Tests/RunCMake/CMakeDependentOption/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake_script(Parentheses) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 4e28549..dafb174 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -233,6 +233,7 @@ add_RunCMake_test(BuildDepends if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") add_RunCMake_test(Byproducts) endif() +add_RunCMake_test(CMakeDependentOption) add_RunCMake_test(CMakeRoleGlobalProperty) add_RunCMake_test(CMakeRelease -DCMake_TEST_JQ=${CMake_TEST_JQ}) if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") |