The handling of the optional version argument in the find_dependency()
macro is just wrong.  It is only set if ${ARGV1} (rather than ARGV1)
evaluates to true, and otherwise it remains unchanged from whatever its
previous value was (instead of being cleared).

Either of the attached patches fixes this.

Alex
>From 57b10901f1f857bde0471f2be4398dace5c36253 Mon Sep 17 00:00:00 2001
From: Alex Merry <k...@randomguy3.me.uk>
Date: Sat, 22 Feb 2014 13:35:14 +0000
Subject: [PATCH] Always set version variable of find_dependency macro

If there is no ARGV1, that is fine; version will be made empty, and no
version will be passed to find_package().
---
 Modules/CMakeFindDependencyMacro.cmake | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/Modules/CMakeFindDependencyMacro.cmake b/Modules/CMakeFindDependencyMacro.cmake
index 0f1f56d..c0a0ef7 100644
--- a/Modules/CMakeFindDependencyMacro.cmake
+++ b/Modules/CMakeFindDependencyMacro.cmake
@@ -29,9 +29,7 @@
 
 macro(find_dependency dep)
   if (NOT ${dep}_FOUND)
-    if (${ARGV1})
-      set(version ${ARGV1})
-    endif()
+    set(version ${ARGV1})
     set(exact_arg)
     if(${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_EXACT)
       set(exact_arg EXACT)
-- 
1.9.0

>From d9da7a712d331e647d94fc12162e2c4df29ca7eb Mon Sep 17 00:00:00 2001
From: Alex Merry <k...@randomguy3.me.uk>
Date: Sat, 22 Feb 2014 13:35:14 +0000
Subject: [PATCH] Fix settings of the version variable of find_dependency macro

It should be reset before use, as this is a macro, and the test should
be against ARGV1, not its value.
---
 Modules/CMakeFindDependencyMacro.cmake | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Modules/CMakeFindDependencyMacro.cmake b/Modules/CMakeFindDependencyMacro.cmake
index 0f1f56d..6f7dbe8 100644
--- a/Modules/CMakeFindDependencyMacro.cmake
+++ b/Modules/CMakeFindDependencyMacro.cmake
@@ -29,7 +29,8 @@
 
 macro(find_dependency dep)
   if (NOT ${dep}_FOUND)
-    if (${ARGV1})
+    set(version)
+    if (ARGV1)
       set(version ${ARGV1})
     endif()
     set(exact_arg)
-- 
1.9.0

-- 

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to