Parcourir la source

Merge topic 'find-no-name'

84e33e6da4 Merge branch 'backport-find-no-name' into find-no-name
4c8760c9fb find_path: Fix crash on empty old-style list of names

Acked-by: Kitware Robot <[email protected]>
Merge-request: !3751
Brad King il y a 6 ans
Parent
commit
31c356e366

+ 1 - 1
Source/cmFindBase.cxx

@@ -145,7 +145,7 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
 
   // look for old style
   // FIND_*(VAR name path1 path2 ...)
-  if (!newStyle) {
+  if (!newStyle && !this->Names.empty()) {
     // All the short-hand arguments have been recorded as names.
     std::vector<std::string> shortArgs = this->Names;
     this->Names.clear(); // clear out any values in Names

+ 1 - 0
Tests/RunCMake/find_path/EmptyOldStyle-stdout.txt

@@ -0,0 +1 @@
+-- VAR-NOTFOUND

+ 2 - 0
Tests/RunCMake/find_path/EmptyOldStyle.cmake

@@ -0,0 +1,2 @@
+find_path(VAR ONLY_CMAKE_FIND_ROOT_PATH)
+message(STATUS "${VAR}")

+ 1 - 0
Tests/RunCMake/find_path/RunCMakeTest.cmake

@@ -1,5 +1,6 @@
 include(RunCMake)
 
+run_cmake(EmptyOldStyle)
 run_cmake(FromPATHEnv)
 run_cmake(PrefixInPATH)