FindOPENSSL.cmake 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ################################################################################
  2. # Copyright (C) 2011 HPCC Systems.
  3. #
  4. # All rights reserved. This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ################################################################################
  17. # - Try to find the OPENSSL library
  18. # Once done this will define
  19. #
  20. # OPENSSL_FOUND - system has the OPENSSL library
  21. # OPENSSL_INCLUDE_DIR - the OPENSSL include directory
  22. # OPENSSL_LIBRARIES - The libraries needed to use OPENSSL
  23. IF (NOT OPENSSL_FOUND)
  24. IF (WIN32)
  25. SET (ssl_lib "ssleay32.lib")
  26. ELSE()
  27. SET (ssl_lib "libssl.so")
  28. ENDIF()
  29. IF (NOT ${EXTERNALS_DIRECTORY} STREQUAL "")
  30. IF (UNIX)
  31. IF (${ARCH64BIT} EQUAL 1)
  32. SET (osdir "linux64_gcc4.1.1")
  33. ELSE()
  34. SET (osdir "linux32_gcc4.1.1")
  35. ENDIF()
  36. ELSEIF(WIN32)
  37. IF (${ARCH64BIT} EQUAL 1)
  38. SET (osdir "win64")
  39. ELSE()
  40. SET (osdir "win32")
  41. ENDIF()
  42. ELSE()
  43. SET (osdir "unknown")
  44. ENDIF()
  45. IF (NOT ("${osdir}" STREQUAL "unknown"))
  46. FIND_PATH (OPENSSL_INCLUDE_DIR NAMES openssl/ssl.h PATHS "${EXTERNALS_DIRECTORY}/openssl/${osdir}/include" NO_DEFAULT_PATH)
  47. FIND_LIBRARY (OPENSSL_LIBRARIES NAMES ${ssl_lib} PATHS "${EXTERNALS_DIRECTORY}/openssl/${osdir}/lib" NO_DEFAULT_PATH)
  48. ENDIF()
  49. ENDIF()
  50. if (USE_NATIVE_LIBRARIES)
  51. # if we didn't find in externals, look in system include path
  52. FIND_PATH (OPENSSL_INCLUDE_DIR NAMES openssl/ssl.h)
  53. FIND_LIBRARY (OPENSSL_LIBRARIES NAMES ${ssl_lib})
  54. endif()
  55. include(FindPackageHandleStandardArgs)
  56. find_package_handle_standard_args(OPENSSL DEFAULT_MSG
  57. OPENSSL_LIBRARIES
  58. OPENSSL_INCLUDE_DIR
  59. )
  60. IF (OPENSSL_FOUND)
  61. STRING(REPLACE "/${ssl_lib}" "" OPENSSL_LIBRARY_DIR "${OPENSSL_LIBRARIES}")
  62. IF (UNIX)
  63. STRING(REPLACE "libssl" "libcrypto" OPENSSL_EXTRA "${OPENSSL_LIBRARIES}")
  64. ELSE()
  65. STRING(REPLACE "ssleay32" "libeay32" OPENSSL_EXTRA "${OPENSSL_LIBRARIES}")
  66. ENDIF()
  67. set (OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} ${OPENSSL_EXTRA} )
  68. ENDIF()
  69. MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)
  70. ENDIF()