@@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.5)
2
2
3
3
4
4
find_program (CCACHE_FOUND ccache)
5
- if (CCACHE_FOUND)
5
+ if (CCACHE_FOUND)
6
6
set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
7
7
set_property (GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
8
- endif (CCACHE_FOUND)
8
+ endif (CCACHE_FOUND)
9
9
10
10
11
11
include ("cmake/Hunter/init.cmake" )
@@ -23,23 +23,23 @@ project(ed25519 VERSION ${SOVERSION} LANGUAGES C CXX)
23
23
24
24
enable_language (ASM)
25
25
26
- set (CMAKE_POSITION_INDEPENDENT_CODE TRUE )
27
- set (CMAKE_C_VISIBILITY_PRESET hidden)
28
- set (CMAKE_CXX_VISIBILITY_PRESET hidden)
29
- set (CMAKE_VISIBILITY_INLINES_HIDDEN 1 )
30
- set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
26
+ set (CMAKE_POSITION_INDEPENDENT_CODE TRUE )
27
+ set (CMAKE_C_VISIBILITY_PRESET hidden)
28
+ set (CMAKE_CXX_VISIBILITY_PRESET hidden)
29
+ set (CMAKE_VISIBILITY_INLINES_HIDDEN ON )
30
+ set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
31
31
32
- set (CMAKE_C_STANDARD 11) # force std=c11
33
- set (CMAKE_C_STANDARD_REQUIRED ON )
34
- set (CMAKE_C_EXTENSIONS OFF )
32
+ set (CMAKE_C_STANDARD 11) # force std=c11
33
+ set (CMAKE_C_STANDARD_REQUIRED ON )
34
+ set (CMAKE_C_EXTENSIONS OFF )
35
35
36
- set (CMAKE_CXX_STANDARD 11) # force std=c++11
37
- set (CMAKE_CXX_STANDARD_REQUIRED ON )
38
- set (CMAKE_CXX_EXTENSIONS OFF )
36
+ set (CMAKE_CXX_STANDARD 11) # force std=c++11
37
+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
38
+ set (CMAKE_CXX_EXTENSIONS OFF )
39
39
40
- option (TESTING "Enable testing" OFF )
41
- option (COVERAGE "Enable coverage" OFF )
42
- option (BENCHMARKING "Enable benchmarking" OFF )
40
+ option (TESTING "Enable testing" OFF )
41
+ option (COVERAGE "Enable coverage" OFF )
42
+ option (BENCHMARKING "Enable benchmarking" OFF )
43
43
44
44
include_directories (
45
45
${CMAKE_BINARY_DIR} /
@@ -50,57 +50,37 @@ include(GNUInstallDirs)
50
50
include (cmake/dependencies.cmake)
51
51
include (cmake/functions.cmake)
52
52
include (cmake/ed25519_init.cmake)
53
- include (cmake/ed25519_export.cmake)
54
53
include (cmake/ed25519_target_link_libraries.cmake)
55
54
include (cmake/ed25519_add_library.cmake)
56
55
include (cmake/ed25519_merge_libraries.cmake)
57
56
include (cmake/ed25519_add_test.cmake)
57
+ include (cmake/ed25519_select_supported_impl.cmake)
58
58
test_build_amd64(CAN_BUILD_AMD64)
59
59
60
60
ed25519_init(EDIMPL HASH RANDOM)
61
61
62
- # resulting shared/static library will export these symbols as GLOBAL symbols, and
63
- # mark all others as LOCAL (hidden)
64
- ed25519_export(
65
- ed25519_create_keypair
66
- ed25519_derive_public_key
67
- ed25519_sign
68
- ed25519_verify
69
- sha512_init
70
- sha512_final
71
- sha512_update
72
- sha512
73
- sha256_init
74
- sha256_final
75
- sha256_update
76
- sha256
77
- randombytes
78
- )
62
+ add_subdirectory (lib)
79
63
80
64
## DEFAULTS
81
- if (NOT EDIMPL)
82
- set (EDIMPL " ref10" )
83
- endif ()
84
- if (NOT HASH)
85
- set (HASH "sha3_brainhub" )
86
- endif ()
87
- if (NOT RANDOM)
65
+ if (NOT EDIMPL)
66
+ ed25519_select_supported_impl (EDIMPL amd64-64-24k-pic ref10)
67
+ endif ()
68
+ if (NOT HASH)
69
+ ed25519_select_supported_impl (HASH sha2_sphlib sha2_openssl )
70
+ endif ()
71
+ if (NOT RANDOM)
88
72
# https://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers/
89
- if (WIN32 )
90
- set (RANDOM "bcryptgenrandom" )
91
- else ()
92
- set (RANDOM "dev_urandom" )
93
- endif ()
94
- endif ()
95
- if (NOT BUILD )
96
- set (BUILD "STATIC" )
97
- endif ()
98
-
99
-
100
- if (NOT CMAKE_ASM_COMPILER_WORKS)
73
+ ed25519_select_supported_impl(RANDOM dev_urandom bcryptgen rand_openssl)
74
+ endif ()
75
+ if (NOT BUILD )
76
+ set (BUILD "STATIC" )
77
+ endif ()
78
+
79
+
80
+ if (NOT CMAKE_ASM_COMPILER_WORKS)
101
81
message (WARNING "Can not find ASM compiler. Only EDIMPL=ref10 is available." )
102
82
set (CAN_BUILD_AMD64 FALSE )
103
- endif ()
83
+ endif ()
104
84
105
85
106
86
## OPTIONS
@@ -117,64 +97,65 @@ ENUM(RANDOM "${RANDOM}" "RNG implementation"
117
97
rand_openssl
118
98
dev_random
119
99
dev_urandom
120
- bcryptgenrandom
100
+ bcryptgen
121
101
)
122
102
ENUM(BUILD "${BUILD} " "library build type"
123
103
SHARED
124
104
STATIC
125
105
)
126
106
127
- add_subdirectory (lib)
128
-
129
107
130
108
ed25519_merge_libraries(ed25519 ${BUILD}
131
109
LIBRARIES
132
- ${EDIMPL}
133
- ${HASH}
134
- ${RANDOM}
110
+ ${EDIMPL}
111
+ ${HASH}
112
+ ${RANDOM}
135
113
VERSION
136
- VERSION -${SOVERSION} -${EDIMPL} -${HASH} -${RANDOM} -${BUILD} -${CMAKE_BUILD_TYPE}
114
+ VERSION -${SOVERSION} -${EDIMPL} -${HASH} -${RANDOM} -${BUILD} -${CMAKE_BUILD_TYPE}
137
115
)
138
116
set_target_properties (ed25519 PROPERTIES
139
- VERSION ${SOVERSION}
117
+ VERSION ${SOVERSION}
140
118
SOVERSION ${SOVERSION}
141
119
INTERFACE_ed25519_MAJOR_VERSION ${ED25519_MAJOR_VERSION}
142
120
)
143
121
set_property (
144
122
TARGET ed25519
145
123
APPEND PROPERTY
146
124
COMPATIBLE_INTERFACE_STRING ed25519_MAJOR_VERSION
147
- )
125
+ )
148
126
install (TARGETS ed25519 EXPORT ed25519Config
149
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
150
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
151
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
152
- INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
127
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
128
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
129
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
130
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
153
131
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
154
- FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX}
132
+ FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX}
155
133
)
156
134
install (
157
- DIRECTORY ${CMAKE_SOURCE_DIR} /include /ed25519
135
+ DIRECTORY ${CMAKE_SOURCE_DIR} /include /ed25519
158
136
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
159
- )
137
+ )
160
138
install (
161
139
EXPORT ed25519Config
162
140
DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/ed25519
163
141
NAMESPACE iroha::
164
- )
142
+ )
143
+ install (
144
+ FILES ${CMAKE_SOURCE_DIR} /linker_exportmap
145
+ DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/ed25519
146
+ )
165
147
export (
166
148
TARGETS ed25519
167
149
FILE ed25519Config.cmake
168
- )
169
-
150
+ )
170
151
171
152
172
- if (TESTING)
153
+ if (TESTING)
173
154
enable_testing ()
174
155
add_subdirectory (test )
175
- endif ()
156
+ endif ()
176
157
177
158
178
- if (BENCHMARK)
159
+ if (BENCHMARK)
179
160
add_subdirectory (benchmark)
180
- endif ()
161
+ endif ()
0 commit comments