-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
147 lines (124 loc) · 3.17 KB
/
CMakeLists.txt
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
cmake_minimum_required(VERSION 3.0)
# Project settings
project(SIKE NONE)
enable_language(C)
enable_language(CXX)
enable_language(ASM)
# Environment settings
set(PERL_EXECUTABLE "perl")
# Check ARCH
if(NO_ASM)
set(ARCH "generic")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(ARCH "x86_64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
set(ARCH "x86_64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
# used on windows
set(ARCH "x86_64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
set(ARCH "aarch64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
set(ARCH "aarch64")
else()
set(ARCH "generic")
endif()
# Set per ARCH defaults
if(${ARCH} STREQUAL "aarch64")
set(
CRYPTO_ARCH_SOURCES
asm/fp-aarch64.S
)
set(CMAKE_C_FLAGS "-DARCH_AARCH64 -DCPU_64_BIT -DHAS_UINT128")
set(CMAKE_CXX_FLAGS "-DARCH_AARCH64 -DCPU_64_BIT -DHAS_UINT128")
elseif(${ARCH} STREQUAL "x86_64")
set(
CRYPTO_ARCH_SOURCES
asm/fp-x86_64.S
)
set(CMAKE_C_FLAGS "-DARCH_X86_64 -DCPU_64_BIT -DHAS_UINT128")
set(CMAKE_CXX_FLAGS "-DARCH_X86_64 -DCPU_64_BIT -DHAS_UINT128")
elseif(${ARCH} STREQUAL "generic")
set(
CRYPTO_ARCH_SOURCES
src/sike-p434-sha256/asm/fp_generic.c
)
set(CMAKE_C_FLAGS "-DARCH_GENERIC")
else()
message(FATAL_ERROR "Something got wrong for CPU:" ${CMAKE_SYSTEM_PROCESSOR})
endif()
# Set compilation flags
if(DEBUG)
set(CMAKE_C_FLAGS "-g")
else()
set(CMAKE_C_FLAGS "-O3")
endif()
# Common include directories
include_directories(
3rd
3rd/googletest/include
includes
)
# Add minimal googletest targets.
add_library(boringssl_gtest 3rd/googletest/src/gtest-all.cc)
target_include_directories(boringssl_gtest PRIVATE 3rd/googletest)
# Generates ASM file
add_custom_command(
OUTPUT asm/fp-x86_64.S
COMMAND ${CMAKE_COMMAND} -E make_directory asm
COMMAND ${PERL_EXECUTABLE} ../src/sike-p434-sha256/asm/fp-x86_64.pl -o asm/fp-x86_64.S
DEPENDS
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/src/sike-p434-sha256/asm/fp-x86_64.pl
${PROJECT_SOURCE_DIR}/3rd/boringssl/arm-xlate.pl
${PROJECT_SOURCE_DIR}/3rd/boringssl/x86_64-xlate.pl
WORKING_DIRECTORY .
)
add_custom_command(
OUTPUT asm/fp-aarch64.S
COMMAND ${CMAKE_COMMAND} -E make_directory asm
COMMAND ${PERL_EXECUTABLE} ../src/sike-p434-sha256/asm/fp-aarch64.pl -o asm/fp-aarch64.S
DEPENDS
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/src/sike-p434-sha256/asm/fp-aarch64.pl
${PROJECT_SOURCE_DIR}/3rd/boringssl/arm-xlate.pl
${PROJECT_SOURCE_DIR}/3rd/boringssl/x86_64-xlate.pl
WORKING_DIRECTORY .
)
# SIKE/p434 library
add_library(
sike434sha256
src/sike-p434-sha256/fpx.c
src/sike-p434-sha256/isogeny.c
src/sike-p434-sha256/params.c
src/sike-p434-sha256/sike.c
${CRYPTO_ARCH_SOURCES}
3rd/random/randombytes.c
3rd/sha2/sha256.c
)
# Tests
add_executable(
testsike434
test/p434.cc
3rd/googletest/src/gtest_main.cc
)
include_directories(
src/sike-p434-sha256
)
target_link_libraries(
testsike434
sike434sha256
boringssl_gtest
pthread)
# Speed
add_executable(
speedsike434
test/speed434.cc
)
include_directories(
src/sike-p434-sha256
src/internal
)
target_link_libraries(
speedsike434
sike434sha256)