ceph/cmake/modules/BuildISALCrypto.cmake
Casey Bodley 3bfc1ae3d7 cmake/crypto: use ExternalProject to build isal crypto library
instead of building isa-l_crypto source files directly into the
ceph_crypto_isal plugin, use a cmake ExternalProject to build the
library with make and expose the static library as cmake target
ISAL::Crypto

Signed-off-by: Casey Bodley <cbodley@redhat.com>
2024-09-05 13:19:21 -04:00

32 lines
1.1 KiB
CMake

# 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()