summaryrefslogtreecommitdiffstats
path: root/cmake/modules/BuildISALCrypto.cmake
blob: 26fb4a8f9cd581f1939ee4f7d8e301976f484bf4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# use an ExternalProject to build isa-l_crypto using its makefile
function(build_isal_crypto)
  set(ISAL_CRYPTO_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/crypto/isa-l/isa-l_crypto)
  set(ISAL_CRYPTO_INCLUDE_DIR "${ISAL_CRYPTO_SOURCE_DIR}/include")
  set(ISAL_CRYPTO_LIBRARY "${ISAL_CRYPTO_SOURCE_DIR}/bin/isa-l_crypto.a")

  include(FindMake)
  find_make("MAKE_EXECUTABLE" "make_cmd")

  include(ExternalProject)
  ExternalProject_Add(isal_crypto_ext
    SOURCE_DIR ${ISAL_CRYPTO_SOURCE_DIR}
    CONFIGURE_COMMAND ""
    BUILD_COMMAND ${make_cmd} -f <SOURCE_DIR>/Makefile.unx
    BUILD_IN_SOURCE 1
    BUILD_BYPRODUCTS ${ISAL_CRYPTO_LIBRARY}
    INSTALL_COMMAND ""
    UPDATE_COMMAND ""
    LOG_CONFIGURE ON
    LOG_BUILD ON
    LOG_MERGED_STDOUTERR ON
    LOG_OUTPUT_ON_FAILURE ON)

  # add imported library target ISAL::Crypto
  add_library(ISAL::Crypto STATIC IMPORTED GLOBAL)
  add_dependencies(ISAL::Crypto isal_crypto_ext)
  set_target_properties(ISAL::Crypto PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES ${ISAL_CRYPTO_INCLUDE_DIR}
    IMPORTED_LINK_INTERFACE_LANGUAGES "C"
    IMPORTED_LOCATION ${ISAL_CRYPTO_LIBRARY})
endfunction()