Open Quantum Safe Library Documentation: CMakeLists

# SPDX-License-Identifier: MIT

set(_FRODOKEM_OBJS "")

if(OQS_ENABLE_KEM_frodokem_640_aes)
    set(SRCS kem_frodokem640aes.c external/frodo/frodo640aes.c)
endif()
if(OQS_ENABLE_KEM_frodokem_640_shake)
    set(SRCS ${SRCS} kem_frodokem640shake.c external/frodo/frodo640shake.c)
endif()

if(OQS_ENABLE_KEM_frodokem_976_aes)
    set(SRCS ${SRCS} kem_frodokem976aes.c external/frodo/frodo976aes.c)
endif()
if(OQS_ENABLE_KEM_frodokem_976_shake)
    set(SRCS ${SRCS} kem_frodokem976shake.c external/frodo/frodo976shake.c)
endif()

if(OQS_ENABLE_KEM_frodokem_1344_aes)
    set(SRCS ${SRCS} kem_frodokem1344aes.c external/frodo/frodo1344aes.c)
endif()
if(OQS_ENABLE_KEM_frodokem_1344_shake)
    set(SRCS ${SRCS} kem_frodokem1344shake.c external/frodo/frodo1344shake.c)
endif()

if(OQS_ENABLE_KEM_efrodokem_640_aes)
    set(SRCS ${SRCS} kem_efrodokem640aes.c external/efrodo/efrodo640aes.c)
endif()
if(OQS_ENABLE_KEM_efrodokem_640_shake)
    set(SRCS ${SRCS} kem_efrodokem640shake.c external/efrodo/efrodo640shake.c)
endif()

if(OQS_ENABLE_KEM_efrodokem_976_aes)
    set(SRCS ${SRCS} kem_efrodokem976aes.c external/efrodo/efrodo976aes.c)
endif()
if(OQS_ENABLE_KEM_efrodokem_976_shake)
    set(SRCS ${SRCS} kem_efrodokem976shake.c external/efrodo/efrodo976shake.c)
endif()

if(OQS_ENABLE_KEM_efrodokem_1344_aes)
    set(SRCS ${SRCS} kem_efrodokem1344aes.c external/efrodo/efrodo1344aes.c)
endif()
if(OQS_ENABLE_KEM_efrodokem_1344_shake)
    set(SRCS ${SRCS} kem_efrodokem1344shake.c external/efrodo/efrodo1344shake.c)
endif()

add_library(frodokem OBJECT ${SRCS})
set(_FRODOKEM_OBJS ${_FRODOKEM_OBJS} $<TARGET_OBJECTS:frodokem>)

set(SRCS_AVX2 "")
if(OQS_DIST_X86_64_BUILD OR OQS_USE_AVX2_INSTRUCTIONS)
    if(OQS_ENABLE_KEM_frodokem_640_aes)
        set(SRCS_AVX2 ${SRCS_AVX2} external/frodo/frodo640aes_avx2.c)
    endif()
    if(OQS_ENABLE_KEM_frodokem_976_aes)
        set(SRCS_AVX2 ${SRCS_AVX2} external/frodo/frodo976aes_avx2.c)
    endif()
    if(OQS_ENABLE_KEM_frodokem_1344_aes)
        set(SRCS_AVX2 ${SRCS_AVX2} external/frodo/frodo1344aes_avx2.c)
    endif()

    if(OQS_ENABLE_KEM_frodokem_640_shake)
        set(SRCS_AVX2 ${SRCS_AVX2} external/frodo/frodo640shake_avx2.c)
    endif()
    if(OQS_ENABLE_KEM_frodokem_976_shake)
        set(SRCS_AVX2 ${SRCS_AVX2} external/frodo/frodo976shake_avx2.c)
    endif()
    if(OQS_ENABLE_KEM_frodokem_1344_shake)
        set(SRCS_AVX2 ${SRCS_AVX2} external/frodo/frodo1344shake_avx2.c)
    endif()

    if(OQS_ENABLE_KEM_efrodokem_640_aes)
        set(SRCS_AVX2 ${SRCS_AVX2} external/efrodo/efrodo640aes_avx2.c)
    endif()
    if(OQS_ENABLE_KEM_efrodokem_976_aes)
        set(SRCS_AVX2 ${SRCS_AVX2} external/efrodo/efrodo976aes_avx2.c)
    endif()
    if(OQS_ENABLE_KEM_efrodokem_1344_aes)
        set(SRCS_AVX2 ${SRCS_AVX2} external/efrodo/efrodo1344aes_avx2.c)
    endif()

    if(OQS_ENABLE_KEM_efrodokem_640_shake)
        set(SRCS_AVX2 ${SRCS_AVX2} external/efrodo/efrodo640shake_avx2.c)
    endif()
    if(OQS_ENABLE_KEM_efrodokem_976_shake)
        set(SRCS_AVX2 ${SRCS_AVX2} external/efrodo/efrodo976shake_avx2.c)
    endif()
    if(OQS_ENABLE_KEM_efrodokem_1344_shake)
        set(SRCS_AVX2 ${SRCS_AVX2} external/efrodo/efrodo1344shake_avx2.c)
    endif()

    add_library(frodokem_avx2 OBJECT ${SRCS_AVX2})
    target_compile_options(frodokem_avx2 PRIVATE -mavx2)
    set(_FRODOKEM_OBJS ${_FRODOKEM_OBJS} $<TARGET_OBJECTS:frodokem_avx2>)
endif()

set(FRODOKEM_OBJS ${_FRODOKEM_OBJS} PARENT_SCOPE)