FindOPENSSL.cmake 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 "libssl.lib")
  25. ELSEIF (APPLE)
  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/1.1/${osdir}/include" NO_DEFAULT_PATH)
  48. FIND_LIBRARY (OPENSSL_LIBRARIES NAMES ${ssl_lib} PATHS "${EXTERNALS_DIRECTORY}/openssl/1.1/${osdir}/lib" NO_DEFAULT_PATH)
  49. ENDIF()
  50. ENDIF()
  51. if (USE_NATIVE_LIBRARIES)
  52. if (APPLE)
  53. FIND_PATH (OPENSSL_INCLUDE_DIR NAMES openssl/ssl.h PATHS /opt/local/include /usr/local/include NO_DEFAULT_PATH)
  54. FIND_LIBRARY (OPENSSL_LIBRARIES NAMES ${ssl_lib} PATHS /opt/local/lib /usr/local/lib NO_DEFAULT_PATH)
  55. else()
  56. # if we didn't find in externals, look in system include path
  57. FIND_PATH (OPENSSL_INCLUDE_DIR NAMES openssl/ssl.h)
  58. FIND_LIBRARY (OPENSSL_LIBRARIES NAMES ${ssl_lib})
  59. endif()
  60. endif()
  61. include(FindPackageHandleStandardArgs)
  62. find_package_handle_standard_args(OPENSSL DEFAULT_MSG
  63. OPENSSL_LIBRARIES
  64. OPENSSL_INCLUDE_DIR
  65. )
  66. IF (OPENSSL_FOUND)
  67. STRING(REPLACE "/${ssl_lib}" "" OPENSSL_LIBRARY_DIR "${OPENSSL_LIBRARIES}")
  68. STRING(REPLACE "libssl" "libcrypto" OPENSSL_EXTRA "${OPENSSL_LIBRARIES}")
  69. set (OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} ${OPENSSL_EXTRA} )
  70. ENDIF()
  71. MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)
  72. ENDIF()