1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-22 23:48:58 +00:00
pqcrypto/CMakeLists.txt

239 lines
8.2 KiB
CMake
Raw Normal View History

2021-02-10 00:21:31 +00:00
cmake_minimum_required(VERSION 3.13)
project(cryptocore NONE)
enable_language(C)
enable_language(CXX)
enable_language(ASM)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "~/.cmake/Modules")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "3rd/cmake-modules")
set(CMAKE_CXX_STANDARD 11)
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
2021-02-17 13:38:23 +00:00
set(ARCH "ARCH_x86_64")
2021-02-10 00:21:31 +00:00
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
2021-02-17 13:38:23 +00:00
set(ARCH "ARCH_x86_64")
2021-02-10 00:21:31 +00:00
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
2021-02-17 13:38:23 +00:00
set(ARCH "ARCH_x86_64")
2021-02-10 00:21:31 +00:00
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
2021-02-17 13:38:23 +00:00
set(ARCH "ARCH_x86")
2021-02-10 00:21:31 +00:00
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
2021-02-17 13:38:23 +00:00
set(ARCH "ARCH_x86")
2021-02-10 00:21:31 +00:00
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
2021-02-17 13:38:23 +00:00
set(ARCH "ARCH_x86")
2021-02-10 00:21:31 +00:00
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
2021-02-17 13:38:23 +00:00
set(ARCH "ARCH_aarch64")
2021-02-10 00:21:31 +00:00
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
2021-02-17 13:38:23 +00:00
set(ARCH "ARCH_aarch64")
2021-02-10 00:21:31 +00:00
else()
message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR})
endif()
# Arch settings
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX TRUE)
endif()
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(CLANG 1)
endif()
if (MACOSX)
set(CMAKE_C_COMPILER /usr/bin/cc CACHE PATH "" FORCE)
set(CMAKE_CXX_COMPILER /usr/bin/c++ CACHE PATH "" FORCE)
endif()
# Global configuration
set(C_CXX_FLAGS
"-Wno-ignored-qualifiers \
-Wall \
-Werror \
-Wextra \
-Wpedantic \
-Wshadow \
-Wno-variadic-macros \
-Wundef \
-Wunused-result")
if(CLANG)
set(C_CXX_FLAGS
"-Wconditional-uninitialized \
-Wmissing-variable-declarations")
endif()
2021-03-03 06:50:25 +00:00
include(.cmake/common.mk)
2021-02-10 00:21:31 +00:00
# Control Debug/Release mode
if(CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
set(C_CXX_FLAGS "${C_CXX_FLAGS} -g3 -O0 -Wno-unused")
else()
set(C_CXX_FLAGS "${C_CXX_FLAGS} -O3")
endif()
include_directories(
inc
2021-03-03 06:50:25 +00:00
src/common/
2021-02-10 00:21:31 +00:00
src
)
# Set CPU architecture
set(CMAKE_C_FLAGS "${C_CXX_FLAGS} -D${ARCH}")
set(CMAKE_CXX_FLAGS "${C_CXX_FLAGS} -D${ARCH}")
2021-02-17 13:38:23 +00:00
# Define sources of the components
2021-03-03 06:50:25 +00:00
add_subdirectory(src/sign/dilithium/dilithium2/clean)
add_subdirectory(src/sign/dilithium/dilithium3/clean)
add_subdirectory(src/sign/dilithium/dilithium5/clean)
add_subdirectory(src/sign/falcon/falcon-1024/clean)
add_subdirectory(src/sign/falcon/falcon-512/clean)
add_subdirectory(src/sign/rainbow/rainbowV-classic/clean)
add_subdirectory(src/sign/rainbow/rainbowI-classic/clean)
add_subdirectory(src/sign/rainbow/rainbowIII-classic/clean)
add_subdirectory(src/sign/sphincs/sphincs-sha256-192f-simple/clean)
add_subdirectory(src/sign/sphincs/sphincs-shake256-256f-simple/clean)
add_subdirectory(src/sign/sphincs/sphincs-shake256-192f-robust/clean)
add_subdirectory(src/sign/sphincs/sphincs-shake256-128f-simple/clean)
add_subdirectory(src/sign/sphincs/sphincs-shake256-256s-simple/clean)
add_subdirectory(src/sign/sphincs/sphincs-shake256-128s-simple/clean)
add_subdirectory(src/sign/sphincs/sphincs-sha256-128f-robust/clean)
add_subdirectory(src/sign/sphincs/sphincs-sha256-192s-robust/clean)
add_subdirectory(src/sign/sphincs/sphincs-shake256-128f-robust/clean)
add_subdirectory(src/sign/sphincs/sphincs-shake256-128s-robust/clean)
add_subdirectory(src/sign/sphincs/sphincs-shake256-256s-robust/clean)
add_subdirectory(src/sign/sphincs/sphincs-sha256-192s-simple/clean)
add_subdirectory(src/sign/sphincs/sphincs-shake256-192s-simple/clean)
add_subdirectory(src/sign/sphincs/sphincs-shake256-192s-robust/clean)
add_subdirectory(src/sign/sphincs/sphincs-shake256-192f-simple/clean)
add_subdirectory(src/sign/sphincs/sphincs-sha256-256s-simple/clean)
add_subdirectory(src/sign/sphincs/sphincs-sha256-128s-simple/clean)
add_subdirectory(src/sign/sphincs/sphincs-shake256-256f-robust/clean)
add_subdirectory(src/sign/sphincs/sphincs-sha256-256f-robust/clean)
add_subdirectory(src/sign/sphincs/sphincs-sha256-256f-simple/clean)
add_subdirectory(src/sign/sphincs/sphincs-sha256-256s-robust/clean)
add_subdirectory(src/sign/sphincs/sphincs-sha256-128s-robust/clean)
add_subdirectory(src/sign/sphincs/sphincs-sha256-128f-simple/clean)
add_subdirectory(src/sign/sphincs/sphincs-sha256-192f-robust/clean)
2021-02-20 01:45:07 +00:00
2021-02-17 13:56:44 +00:00
# AVX2 targets
if(${ARCH} STREQUAL "ARCH_x86_64")
2021-03-03 06:50:25 +00:00
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mtune=native")
add_subdirectory(src/sign/falcon/falcon-512/avx2)
add_subdirectory(src/sign/falcon/falcon-1024/avx2)
add_subdirectory(src/sign/dilithium/dilithium2/avx2)
add_subdirectory(src/sign/dilithium/dilithium3/avx2)
add_subdirectory(src/sign/dilithium/dilithium5/avx2)
add_subdirectory(src/sign/sphincs/sphincs-shake256-128s-simple/avx2)
add_subdirectory(src/sign/sphincs/sphincs-shake256-128f-robust/avx2)
add_subdirectory(src/sign/sphincs/sphincs-shake256-128s-robust/avx2)
add_subdirectory(src/sign/sphincs/sphincs-shake256-128f-simple/avx2)
add_subdirectory(src/sign/sphincs/sphincs-shake256-192s-simple/avx2)
add_subdirectory(src/sign/sphincs/sphincs-shake256-192f-robust/avx2)
add_subdirectory(src/sign/sphincs/sphincs-shake256-192s-robust/avx2)
add_subdirectory(src/sign/sphincs/sphincs-shake256-192f-simple/avx2)
add_subdirectory(src/sign/sphincs/sphincs-shake256-256f-robust/avx2)
add_subdirectory(src/sign/sphincs/sphincs-shake256-256f-simple/avx2)
add_subdirectory(src/sign/sphincs/sphincs-shake256-256s-simple/avx2)
add_subdirectory(src/sign/sphincs/sphincs-shake256-256s-robust/avx2)
add_subdirectory(src/sign/sphincs/sphincs-sha256-128f-robust/avx2)
add_subdirectory(src/sign/sphincs/sphincs-sha256-128s-simple/avx2)
add_subdirectory(src/sign/sphincs/sphincs-sha256-128s-robust/avx2)
add_subdirectory(src/sign/sphincs/sphincs-sha256-128f-simple/avx2)
add_subdirectory(src/sign/sphincs/sphincs-sha256-192s-simple/avx2)
add_subdirectory(src/sign/sphincs/sphincs-sha256-192f-simple/avx2)
add_subdirectory(src/sign/sphincs/sphincs-sha256-192s-robust/avx2)
add_subdirectory(src/sign/sphincs/sphincs-sha256-192f-robust/avx2)
add_subdirectory(src/sign/sphincs/sphincs-sha256-256s-simple/avx2)
add_subdirectory(src/sign/sphincs/sphincs-sha256-256f-robust/avx2)
add_subdirectory(src/sign/sphincs/sphincs-sha256-256f-simple/avx2)
add_subdirectory(src/sign/sphincs/sphincs-sha256-256s-robust/avx2)
2021-02-17 13:38:23 +00:00
endif()
# The rest of the library
set(SRC_COMMON_GENERIC
2021-03-03 06:50:25 +00:00
src/common/aes.c
src/common/fips202.c
src/common/sp800-185.c
src/common/randombytes.c
src/common/sha2.c
2021-02-17 13:38:23 +00:00
)
if(${ARCH} STREQUAL "ARCH_x86_64")
set(SRC_COMMON_AVX2
2021-03-03 06:50:25 +00:00
src/common/keccak4x/KeccakP-1600-times4-SIMD256.c
)
# KEM - AVX2
add_subdirectory(src/kem/kyber/kyber512/avx2)
add_subdirectory(src/kem/kyber/kyber768/avx2)
add_subdirectory(src/kem/kyber/kyber1024/avx2)
add_subdirectory(src/kem/saber/lightsaber/avx2)
add_subdirectory(src/kem/saber/firesaber/avx2)
add_subdirectory(src/kem/saber/saber/avx2)
add_subdirectory(src/kem/ntru/ntruhps4096821/avx2)
add_subdirectory(src/kem/ntru/ntruhps2048509/avx2)
add_subdirectory(src/kem/ntru/ntruhrss701/avx2)
add_subdirectory(src/kem/ntru/ntruhps2048677/avx2)
add_subdirectory(src/kem/ntru_prime/ntrulpr761/avx2)
add_subdirectory(src/kem/ntru_prime/ntrulpr653/avx2)
add_subdirectory(src/kem/ntru_prime/ntrulpr857/avx2)
2021-02-17 13:38:23 +00:00
endif()
2021-03-03 06:50:25 +00:00
# KEM - clean
add_subdirectory(src/kem/kyber/kyber512/clean)
add_subdirectory(src/kem/kyber/kyber768/clean)
add_subdirectory(src/kem/kyber/kyber1024/clean)
add_subdirectory(src/kem/saber/lightsaber/clean)
add_subdirectory(src/kem/saber/firesaber/clean)
add_subdirectory(src/kem/saber/saber/clean)
add_subdirectory(src/kem/frodo/frodokem640shake/clean)
add_subdirectory(src/kem/frodo/frodokem976shake/clean)
add_subdirectory(src/kem/frodo/frodokem1344shake/clean)
add_subdirectory(src/kem/ntru/ntruhps4096821/clean)
add_subdirectory(src/kem/ntru/ntruhps2048509/clean)
add_subdirectory(src/kem/ntru/ntruhrss701/clean)
add_subdirectory(src/kem/ntru/ntruhps2048677/clean)
add_subdirectory(src/kem/ntru_prime/ntrulpr761/clean)
add_subdirectory(src/kem/ntru_prime/ntrulpr653/clean)
add_subdirectory(src/kem/ntru_prime/ntrulpr857/clean)
2021-02-17 13:38:23 +00:00
add_library(
common
OBJECT
${SRC_COMMON_GENERIC}
${SRC_COMMON_AVX2}
)
2021-02-17 12:40:38 +00:00
add_library(
pqclean
SHARED
)
2021-02-10 00:21:31 +00:00
2021-02-17 12:40:38 +00:00
add_library(
pqclean_s
STATIC
2021-02-10 00:21:31 +00:00
)
2021-02-17 12:40:38 +00:00
target_link_libraries(
pqclean
common
pqclean_dilithium2_clean
2021-02-17 13:38:23 +00:00
pqclean_dilithium3_clean
pqclean_dilithium5_clean
2021-02-10 00:21:31 +00:00
)
target_link_libraries(
2021-02-17 12:40:38 +00:00
pqclean_s
common
pqclean_dilithium2_clean
2021-02-17 13:38:23 +00:00
pqclean_dilithium3_clean
pqclean_dilithium5_clean
2021-02-10 00:21:31 +00:00
)