Pārlūkot izejas kodu

Merge topic 'fix--D-command-line-parsing'

aee7e4a0 cmCacheManager: parse -D flags more strictly
368e8de4 Tests: test -D parsing on the command line
Brad King 11 gadi atpakaļ
vecāks
revīzija
2e953c7657

+ 1 - 1
Source/cmCacheManager.cxx

@@ -139,7 +139,7 @@ bool cmCacheManager::ParseEntry(const std::string& entry,
 {
   // input line is:         key:type=value
   static cmsys::RegularExpression reg(
-    "^([^:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
+    "^([^=:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
   // input line is:         "key":type=value
   static cmsys::RegularExpression regQuoted(
     "^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");

+ 3 - 0
Tests/RunCMake/CommandLine/CMakeLists.txt

@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)

+ 1 - 0
Tests/RunCMake/CommandLine/D_nested_cache-stderr.txt

@@ -0,0 +1 @@
+^-->-DBAR:BOOL=BAZ<--$

+ 1 - 0
Tests/RunCMake/CommandLine/D_nested_cache.cmake

@@ -0,0 +1 @@
+message("-->${FOO}<--")

+ 1 - 0
Tests/RunCMake/CommandLine/D_typed_nested_cache-stderr.txt

@@ -0,0 +1 @@
+^-->-DBAR:BOOL=BAZ<--$

+ 1 - 0
Tests/RunCMake/CommandLine/D_typed_nested_cache.cmake

@@ -0,0 +1 @@
+message("-->${FOO}<--")

+ 8 - 0
Tests/RunCMake/CommandLine/RunCMakeTest.cmake

@@ -43,3 +43,11 @@ run_cmake_command(E_sleep-bad-arg2 ${CMAKE_COMMAND} -E sleep 1 -1)
 run_cmake_command(E_sleep-one-tenth ${CMAKE_COMMAND} -E sleep 0.1)
 
 run_cmake_command(P_directory ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR})
+
+set(RunCMake_TEST_OPTIONS
+  "-DFOO=-DBAR:BOOL=BAZ")
+run_cmake(D_nested_cache)
+
+set(RunCMake_TEST_OPTIONS
+  "-DFOO:STRING=-DBAR:BOOL=BAZ")
+run_cmake(D_typed_nested_cache)