OpenSSL.cmake 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. include(ProcessorCount)
  2. ProcessorCount(NPROC)
  3. if(DEFINED OPENSSL_ARCH)
  4. set(_cross_arch ${OPENSSL_ARCH})
  5. else()
  6. if(WIN32)
  7. set(_cross_arch "VC-WIN64A")
  8. elseif(APPLE)
  9. set(_cross_arch "darwin64-arm64-cc")
  10. endif()
  11. endif()
  12. if(WIN32)
  13. set(_conf_cmd perl Configure )
  14. set(_cross_comp_prefix_line "")
  15. set(_make_cmd nmake)
  16. set(_install_cmd nmake install_sw )
  17. else()
  18. if(APPLE)
  19. set(_conf_cmd ./Configure )
  20. else()
  21. set(_conf_cmd "./config")
  22. endif()
  23. set(_cross_comp_prefix_line "")
  24. set(_make_cmd make -j${NPROC})
  25. set(_install_cmd make -j${NPROC} install_sw)
  26. if (CMAKE_CROSSCOMPILING)
  27. set(_cross_comp_prefix_line "--cross-compile-prefix=${TOOLCHAIN_PREFIX}-")
  28. if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
  29. set(_cross_arch "linux-aarch64")
  30. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armhf") # For raspbian
  31. # TODO: verify
  32. set(_cross_arch "linux-armv4")
  33. endif ()
  34. endif ()
  35. endif()
  36. ExternalProject_Add(dep_OpenSSL
  37. #EXCLUDE_FROM_ALL ON
  38. URL "https://github.com/openssl/openssl/archive/OpenSSL_1_1_1k.tar.gz"
  39. URL_HASH SHA256=b92f9d3d12043c02860e5e602e50a73ed21a69947bcc74d391f41148e9f6aa95
  40. DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/OpenSSL
  41. CONFIGURE_COMMAND ${_conf_cmd} ${_cross_arch}
  42. "--openssldir=${DESTDIR}/usr/local"
  43. "--prefix=${DESTDIR}/usr/local"
  44. ${_cross_comp_prefix_line}
  45. no-shared
  46. no-asm
  47. no-ssl3-method
  48. no-dynamic-engine
  49. BUILD_IN_SOURCE ON
  50. BUILD_COMMAND ${_make_cmd}
  51. INSTALL_COMMAND ${_install_cmd}
  52. )
  53. ExternalProject_Add_Step(dep_OpenSSL install_cmake_files
  54. DEPENDEES install
  55. COMMAND ${CMAKE_COMMAND} -E copy_directory openssl "${DESTDIR}/usr/local/${CMAKE_INSTALL_LIBDIR}/cmake/openssl"
  56. WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}"
  57. )