You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

58 lines
2.6 KiB

  1. cmake_minimum_required(VERSION 3.13)
  2. include(ExternalProject)
  3. find_program(MAKE_PROGRAM make)
  4. # The Configure script will set the CFLAGS
  5. set(CMAKE_C_FLAGS "")
  6. set(OPENSSL_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/openssl-build)
  7. # Indicates where OpenSSL is placed after build. That path is used in
  8. # PQSDK build, but that's not the same as installing a package.
  9. set(OPENSSL_BUILD_INSTALL_ROOT ${CMAKE_CURRENT_BINARY_DIR}/openssl-install)
  10. set(OPENSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../openssl)
  11. set(OPENSSL_INCLUDE_DIR ${OPENSSL_BUILD_INSTALL_ROOT}/include)
  12. # OpenSSL is compiled with -prefix and --openssldir set to ${OPENSSL_PREFIX_OPENSSLDIR},
  13. # without RPATH. When used for PQS Engine testing it is placed in :
  14. # ${OPENSSL_BUILD_INSTALL_ROOT}/${OPENSSL_PREFIX_OPENSSLDIR}
  15. # But when installing it is placed in
  16. # ${OPENSSL_PREFIX_OPENSSLDIR}
  17. set(OPENSSL_PREFIX_OPENSSLDIR ${CMAKE_INSTALL_PREFIX}${PQSDK_INSTALL_DIR}/openssl)
  18. include(libdefs.cmake)
  19. message("OpenSSL root dir: ${OPENSSL_ROOT_DIR}")
  20. message("OpenSSL install dir: ${OPENSSL_BUILD_INSTALL_ROOT}")
  21. message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}")
  22. message("OpenSSL crypto lib: ${OPENSSL_LIB_CRYPTO}")
  23. message("OpenSSL ssl lib: ${OPENSSL_LIB_SSL}")
  24. # TODO: add no-deprecated. Need to get rid of ERR_load_crypto_strings and OBJ_cleanup first
  25. set(OPENSSL_CONFIG_ARGS no-shared shared threads)
  26. if(DEBUG)
  27. set(OPENSSL_CONFIG_ARGS ${OPENSSL_CONFIG_ARGS} -d -g3 -O0 no-asm -fno-omit-frame-pointer -fno-inline-functions)
  28. elseif(OQS_SPEED_COMPARE AND OQS_GENERIC)
  29. set(OPENSSL_CONFIG_ARGS ${OPENSSL_CONFIG_ARGS} no-asm)
  30. endif()
  31. # Define dependencies on libcrypto.so and libssl.so
  32. add_dependencies(
  33. OpenSSL_crypto_shared
  34. OpenSSL)
  35. add_dependencies(
  36. OpenSSL_ssl_shared
  37. OpenSSL)
  38. # Add OpenSSL as external project
  39. ExternalProject_Add(OpenSSL
  40. SOURCE_DIR ${OPENSSL_ROOT_DIR}
  41. BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/openssl-build
  42. CONFIGURE_COMMAND <SOURCE_DIR>/config -debug ${OPENSSL_CONFIG_ARGS} --prefix=${OPENSSL_PREFIX_OPENSSLDIR} --openssldir=${OPENSSL_PREFIX_OPENSSLDIR} --strict-warnings
  43. BUILD_COMMAND ${MAKE_PROGRAM} CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_LINKER}
  44. INSTALL_DIR /
  45. INSTALL_COMMAND make DESTDIR=${OPENSSL_BUILD_INSTALL_ROOT} install
  46. )
  47. install(DIRECTORY ${OPENSSL_BUILD_INSTALL_ROOT}/${OPENSSL_PREFIX_OPENSSLDIR}/.. DESTINATION ${OPENSSL_PREFIX_OPENSSLDIR})
  48. install(DIRECTORY ${OPENSSL_BUILD_INSTALL_ROOT}${OPENSSL_PREFIX_OPENSSLDIR}/bin/ DESTINATION
  49. ${OPENSSL_PREFIX_OPENSSLDIR}/bin
  50. FILE_PERMISSIONS OWNER_EXECUTE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ)
  51. set_property(GLOBAL PROPERTY openssl_build_dir_property ${OPENSSL_BUILD_DIR})