FindOPENSSL.cmake 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. ################################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ################################################################################
  16. # - Try to find the OPENSSL library
  17. # Once done this will define
  18. #
  19. # OPENSSL_FOUND - system has the OPENSSL library
  20. # OPENSSL_INCLUDE_DIR - the OPENSSL include directory
  21. # OPENSSL_LIBRARIES - The libraries needed to use OPENSSL
  22. IF (NOT OPENSSL_FOUND)
  23. IF (WIN32)
  24. SET (ssl_lib "ssleay32.lib")
  25. ELSEIF ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin" )
  26. SET (ssl_lib "libssl.dylib")
  27. ELSE()
  28. SET (ssl_lib "libssl.so")
  29. ENDIF()
  30. IF (NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
  31. IF (UNIX)
  32. IF (${ARCH64BIT} EQUAL 1)
  33. SET (osdir "linux64_gcc4.1.1")
  34. ELSE()
  35. SET (osdir "linux32_gcc4.1.1")
  36. ENDIF()
  37. ELSEIF(WIN32)
  38. IF (${ARCH64BIT} EQUAL 1)
  39. SET (osdir "win64")
  40. ELSE()
  41. SET (osdir "win32")
  42. ENDIF()
  43. ELSE()
  44. SET (osdir "unknown")
  45. ENDIF()
  46. IF (NOT ("${osdir}" STREQUAL "unknown"))
  47. FIND_PATH (OPENSSL_INCLUDE_DIR NAMES openssl/ssl.h PATHS "${EXTERNALS_DIRECTORY}/openssl/${osdir}/include" NO_DEFAULT_PATH)
  48. FIND_LIBRARY (OPENSSL_LIBRARIES NAMES ${ssl_lib} PATHS "${EXTERNALS_DIRECTORY}/openssl/${osdir}/lib" NO_DEFAULT_PATH)
  49. ENDIF()
  50. ENDIF()
  51. if (USE_NATIVE_LIBRARIES)
  52. # if we didn't find in externals, look in system include path
  53. FIND_PATH (OPENSSL_INCLUDE_DIR NAMES openssl/ssl.h)
  54. FIND_LIBRARY (OPENSSL_LIBRARIES NAMES ${ssl_lib})
  55. endif()
  56. include(FindPackageHandleStandardArgs)
  57. find_package_handle_standard_args(OPENSSL DEFAULT_MSG
  58. OPENSSL_LIBRARIES
  59. OPENSSL_INCLUDE_DIR
  60. )
  61. IF (OPENSSL_FOUND)
  62. STRING(REPLACE "/${ssl_lib}" "" OPENSSL_LIBRARY_DIR "${OPENSSL_LIBRARIES}")
  63. IF (NOT WIN32)
  64. STRING(REPLACE "libssl" "libcrypto" OPENSSL_EXTRA "${OPENSSL_LIBRARIES}")
  65. ELSE()
  66. STRING(REPLACE "ssleay32" "libeay32" OPENSSL_EXTRA "${OPENSSL_LIBRARIES}")
  67. ENDIF()
  68. set (OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} ${OPENSSL_EXTRA} )
  69. ENDIF()
  70. MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)
  71. ENDIF()