MantisBT - CMake
View Issue Details
0015887CMakeModulespublic2015-12-18 19:442016-06-10 14:21
Patrick Spendrin 
 
normalminoralways
closedfixed 
WindowsWindows
CMake 3.4.1 
CMake 3.6CMake 3.6 
0015887: FindOpenssl can't find self built openssl but prefers slproweb openssl
When having a pre-built package of openssl installed from slproweb.com and you try to find a self-built openssl package in a different location, the slproweb stuff is always preferred.
1) Install slproweb openssl development package (including import libraries and headers).
2a) Build openssl yourself
or
2b) copy over the include directory and the lib directory from the slproweb location and delete the VC and the MinGW folder inside the lib dir.
3) run find_package(OpenSSL)

-> you will not be able to find the new location, which contains both ssleay32.lib and libeay32.lib
The problem occurs because ssleay32MD.lib/ssleay32MT.lib and libeay32MD.lib/libeay32MT.lib are searched before trying to find ssleay32.lib and libeay32.lib. Since the registry paths are by default in the HINTS section, these will be used first.

Attached patch fixes this by providing an option OPENSSL_MSVC_NO_RT_MODE which disables searching for MD/MT libraries.
No tags attached.
patch 0001-Make-it-possible-to-ignore-slproweb-OpenSSL.patch (2,004) 2015-12-18 19:44
https://public.kitware.com/Bug/file/5593/0001-Make-it-possible-to-ignore-slproweb-OpenSSL.patch
patch 0001-FindOpenSSL-set-NAMES_PER_DIR-in-all-find_library-in.patch (2,619) 2016-04-04 08:33
https://public.kitware.com/Bug/file/5666/0001-FindOpenSSL-set-NAMES_PER_DIR-in-all-find_library-in.patch
Issue History
2015-12-18 19:44Patrick SpendrinNew Issue
2015-12-18 19:44Patrick SpendrinFile Added: 0001-Make-it-possible-to-ignore-slproweb-OpenSSL.patch
2015-12-21 08:29Brad KingNote Added: 0040006
2016-04-04 08:33Hannes MezgerFile Added: 0001-FindOpenSSL-set-NAMES_PER_DIR-in-all-find_library-in.patch
2016-04-04 08:39Hannes MezgerNote Added: 0040802
2016-04-05 09:37Brad KingNote Added: 0040812
2016-04-05 09:37Brad KingStatusnew => resolved
2016-04-05 09:37Brad KingResolutionopen => fixed
2016-04-05 09:37Brad KingFixed in Version => CMake 3.6
2016-04-05 09:37Brad KingTarget Version => CMake 3.6
2016-06-10 14:21Kitware RobotNote Added: 0041202
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0040006)
Brad King   
2015-12-21 08:29   
Corresponding mailing list thread:

 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/15308 [^]
(0040802)
Hannes Mezger   
2016-04-04 08:39   
We have the same problem with self-built OpenSSL libraries not being found if slproweb's OpenSSL is installed. There actually is an additional problem: OPENSSL_INCLUDE_DIR points to the location of the self-built OpenSSL, but the OPENSSL_LIBRARIES point to slproweb's OpenSSL.

My proposal is not to modify the OPENSSL_MSVC_STATIC_RT behaviour, but to use the NAMES_PER_DIR option of find_library. This changes the logic for looking for libraries to check all given names for one directory at once and then go to the next directory. This would lead to the self-built OpenSSL to be found first.

A patch containing the needed changes is attached as 0001-FindOpenSSL-set-NAMES_PER_DIR-in-all-find_library-in.patch
(0040812)
Brad King   
2016-04-05 09:37   
Re 0015887:0040802: Great, thanks. Applied:

FindOpenSSL: Prefer libs early in search path regardless of name
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b1484403 [^]
(0041202)
Kitware Robot   
2016-06-10 14:21   
This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.