MantisBT - CMake
View Issue Details
0015075CMakeCMakepublic2014-08-10 07:522015-06-01 08:38
Cameron Garnham 
Brad King 
normalmajoralways
closedfixed 
Apple MacOS X10.9.4
CMake 3.0 
CMake 3.2CMake 3.2 
0015075: Wrong version found when overriding System OpenSSL with custom path (-DCMAKE_PREFIX_PATH=)
cmake should report the latest version of OpenSSL found on the prefix path.
however the pgk-config version overrides a custom path's version.
(OS Mac X)

$ brew install openssl
(will install to /usr/local/opt/openssl as an optional package)

$ cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/openssl

cmake will report:
 "-- Found OpenSSL: /usr/local/opt/openssl/lib/libssl.dylib;/usr/local/opt/openssl/lib/libcrypto.dylib (found version "0.9.8y")"
yet the version in:
/usr/local/opt/openssl/include/openssl is: OPENSSL_VERSION_NUMBER 0x1000109fL

No tags attached.
Issue History
2014-08-10 07:52Cameron GarnhamNew Issue
2014-08-10 08:10Cameron GarnhamNote Added: 0036586
2014-08-10 08:13Nils GladitzSummaryUnable to Override System OpenSSL with custom path (-DCMAKE_PREFIX_PATH=) => Wrong version found when overriding System OpenSSL with custom path (-DCMAKE_PREFIX_PATH=)
2014-08-10 08:13Nils GladitzDescription Updatedbug_revision_view_page.php?rev_id=1542#r1542
2014-08-11 10:18Brad KingNote Added: 0036591
2014-08-11 10:18Brad KingTarget Version => CMake 3.1
2014-10-03 09:28Brad KingNote Added: 0036896
2014-10-03 09:28Brad KingStatusnew => backlog
2014-10-03 09:28Brad KingTarget VersionCMake 3.1 =>
2015-01-11 15:34Brad KingNote Added: 0037666
2015-01-11 15:34Brad KingAssigned To => Brad King
2015-01-11 15:34Brad KingStatusbacklog => resolved
2015-01-11 15:34Brad KingResolutionopen => fixed
2015-01-11 15:34Brad KingFixed in Version => CMake 3.2
2015-01-11 15:34Brad KingTarget Version => CMake 3.2
2015-06-01 08:38Robert MaynardNote Added: 0038833
2015-06-01 08:38Robert MaynardStatusresolved => closed

Notes
(0036586)
Cameron Garnham   
2014-08-10 08:10   
misleading title: perhaps edit to:

0015075: Wrong version found when overriding System OpenSSL with custom path (-DCMAKE_PREFIX_PATH=)

and description:

cmake should report the latest version of OpenSSL found on the prefix path.
however the pgk-config version overrides a custom path's version.
(0036591)
Brad King   
2014-08-11 10:18   
So the right location of OpenSSL is found, but the wrong value of OPENSSL_VERSION is reported?

It appears that the computation for OPENSSL_VERSION trusts the pkg-config output regardless of where the headers and libraries were actually found:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/FindOpenSSL.cmake;hb=v3.0.1#l278 [^]

Try this patch (untested):

diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake
index 340b417..a9295d2 100644
--- a/Modules/FindOpenSSL.cmake
+++ b/Modules/FindOpenSSL.cmake
@@ -275,9 +275,7 @@ function(from_hex HEX DEC)
 endfunction()
 
 if (OPENSSL_INCLUDE_DIR)
- if (_OPENSSL_VERSION)
- set(OPENSSL_VERSION "${_OPENSSL_VERSION}")
- elseif(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
+ if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
     file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str
          REGEX "^#define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*")
(0036896)
Brad King   
2014-10-03 09:28   
Moving to backlog awaiting feedback on patch in 0015075:0036591.
(0037666)
Brad King   
2015-01-11 15:34   
The change in 0015075:0036591 was also proposed here:

 https://github.com/Kitware/CMake/pull/138 [^]

and tested by the author. Applied:

 FindOpenSSL: Always extract version from detected header (0015075)
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=99b13820 [^]

(0038833)
Robert Maynard   
2015-06-01 08:38   
Closing resolved issues that have not been updated in more than 4 months.