-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathCMakeLists.txt
257 lines (221 loc) · 9.24 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#=========================================================================
# Copyright (C) 2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=========================================================================
#
# Intel® Cryptography Primitives Library
#
cmake_minimum_required(VERSION 3.12)
include("${CMAKE_CURRENT_SOURCE_DIR}/sources/cmake/ippcp-utils.cmake")
ippcp_getlibversion("${CMAKE_CURRENT_SOURCE_DIR}/include/ippcpversion.h")
if ((NOT DEFINED IPPCP_VERSION_MAJOR) OR
(NOT DEFINED IPPCP_VERSION_MINOR) OR
(NOT DEFINED IPPCP_VERSION_UPDATE) OR
(NOT DEFINED IPPCP_INTERFACE_VERSION_MAJOR) OR
(NOT DEFINED IPPCP_INTERFACE_VERSION_MINOR))
message(WARNING "Cannot parse version from ippcpversion.h file. The project might be corrupted.")
endif()
set(PROJECT_FULL_NAME "Intel® Cryptography Primitives Library")
set(PROJECT_VERSION ${IPPCP_VERSION})
set(LIB_NAME ippcp)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
cmake_policy(SET CMP0042 NEW)
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0068 NEW)
if("${CMAKE_GENERATOR}" STREQUAL "NMake Makefiles")
if(NOT(C_COMPILER STREQUAL ""))
set(CMAKE_C_COMPILER ${C_COMPILER})
endif()
if(NOT(CXX_COMPILER STREQUAL ""))
set(CMAKE_CXX_COMPILER ${CXX_COMPILER})
endif()
endif()
# on ninja/WIN32 the build type fallback mechanism needs to be placed before the `project` call
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
message(STATUS "CMAKE_BUILD_TYPE is unset, defaulting to Release")
set(CMAKE_BUILD_TYPE "Release")
endif()
project(${PROJECT_FULL_NAME}
VERSION ${PROJECT_VERSION}
LANGUAGES C CXX)
find_package(Python REQUIRED)
if(WIN32 AND (${CMAKE_GENERATOR} MATCHES "Visual Studio"))
if(CMAKE_GENERATOR_PLATFORM) # VS 2019+ -A param
if(${CMAKE_GENERATOR_PLATFORM} MATCHES "x64")
set(ARCH intel64)
else()
set(ARCH ia32)
endif()
else()
if(${CMAKE_GENERATOR} MATCHES "Win64") # old way of platform setting for VS
set(ARCH intel64)
else()
set(ARCH ia32)
endif()
endif()
else()
if (NOT "${ARCH}" STREQUAL "intel64" AND NOT "${ARCH}" STREQUAL "ia32")
message(FATAL_ERROR "Please, set the ARCH parameter to ia32 or intel64")
endif()
endif(WIN32 AND (${CMAKE_GENERATOR} MATCHES "Visual Studio"))
if ((NOT NONPIC_LIB) AND (NOT CODE_COVERAGE))
set(DYNAMIC_LIB ON)
else()
set(DYNAMIC_LIB OFF)
endif()
if("${MERGED_BLD}" STREQUAL "")
set(MERGED_BLD ON)
endif()
# Crypto_mb merged build flag is set same as IPPCP by default
if(MERGED_BLD)
set(MBX_MERGED_BLD ON)
endif()
# Set default installation directories
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if (UNIX)
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/intel/ippcp_${PROJECT_VERSION}" CACHE PATH "..." FORCE)
else()
set(CMAKE_INSTALL_PREFIX "c:/Program Files (x86)/IntelSWTools/ippcp_${PROJECT_VERSION}" CACHE PATH "..." FORCE)
endif()
endif()
set(IPP_CRYPTO_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(IPP_CRYPTO_INCLUDE_DIR "${IPP_CRYPTO_DIR}/include")
set(IPP_CRYPTO_SOURCES_INCLUDE_DIR "${IPP_CRYPTO_DIR}/sources/include")
set(IPP_CRYPTO_SOURCES_DIR "${IPP_CRYPTO_DIR}/sources/ippcp")
set(IPP_CRYPTO_DISPATCHER_DIR "${IPP_CRYPTO_DIR}/sources/dispatcher")
set(TOOLS_DIR "${IPP_CRYPTO_DIR}/tools")
if(NOT CMAKE_OUTPUT_DIR)
set(CMAKE_OUTPUT_DIR "${CMAKE_BINARY_DIR}/.build")
endif()
message (STATUS "CMAKE_VERSION ......................... " ${CMAKE_VERSION})
if(UNIX AND NOT APPLE)
if(NONPIC_LIB)
message (STATUS "NONPIC_LIB ............................ on")
else()
message (STATUS "NONPIC_LIB ............................ off")
endif()
else()
set(${NONPIC_LIB} false)
endif(UNIX AND NOT APPLE)
set(NONPIC_SUBDIRECTORY "")
if(NONPIC_LIB)
set(NONPIC_SUBDIRECTORY "/nonpic")
endif()
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${CMAKE_OUTPUT_DIR}/${OUTPUTCONFIG}/lib${NONPIC_SUBDIRECTORY}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${CMAKE_OUTPUT_DIR}/${OUTPUTCONFIG}/lib${NONPIC_SUBDIRECTORY}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${CMAKE_OUTPUT_DIR}/${OUTPUTCONFIG}/lib${NONPIC_SUBDIRECTORY}")
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}")
endif()
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}")
endif()
if (CRYPTO_USE_CLANG_TIDY AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "12.0.0")
find_program(DO_CLANG_TIDY NAMES clang-tidy)
set(CMAKE_CXX_CLANG_TIDY ${DO_CLANG_TIDY})
set(CMAKE_C_CLANG_TIDY ${DO_CLANG_TIDY})
endif ()
message (STATUS "PROJECT ............................... " ${PROJECT_FULL_NAME})
message (STATUS "CMAKE_BINARY_DIR ...................... " ${CMAKE_BINARY_DIR})
message (STATUS "CMAKE_OUTPUT_DIR ...................... " ${CMAKE_OUTPUT_DIR})
message (STATUS "CMAKE_SOURCE_DIR ...................... " ${CMAKE_SOURCE_DIR})
message (STATUS "IPP_CRYPTO_DIR ........................ " ${IPP_CRYPTO_DIR})
message (STATUS "CMAKE_GENERATOR ....................... " ${CMAKE_GENERATOR})
message (STATUS "CMAKE_C_COMPILER_ID ................... " ${CMAKE_C_COMPILER_ID})
message (STATUS "CMAKE_CXX_COMPILER_ID ................. " ${CMAKE_CXX_COMPILER_ID})
message (STATUS "IPP_CRYPTO_INCLUDE_DIR ................ " ${IPP_CRYPTO_INCLUDE_DIR})
message (STATUS "IPP_CRYPTO_SOURCES_INCLUDE_DIR ........ " ${IPP_CRYPTO_SOURCES_INCLUDE_DIR})
message (STATUS "IPP_CRYPTO_SOURCES_DIR ................ " ${IPP_CRYPTO_SOURCES_DIR})
message (STATUS "ARCH .................................. " ${ARCH})
message (STATUS "DYNAMIC_LIB ........................... " ${DYNAMIC_LIB})
message (STATUS "CMAKE_INSTALL_PREFIX .................. " ${CMAKE_INSTALL_PREFIX})
if(CRYPTO_USE_CLANG_TIDY)
message (STATUS "CLANG_TIDY ............................ on")
else()
message (STATUS "CLANG_TIDY ............................ off")
endif()
if(Python_Interpreter_FOUND)
message (STATUS "PYTHON_VERSION_STRING ................. " ${Python_VERSION})
else()
message (STATUS "PYTHON_VERSION_STRING ................. Python not found" )
endif()
if(MERGED_BLD)
message (STATUS "MERGED_BLD ............................ on")
else()
message (STATUS "MERGED_BLD ............................ off")
endif()
option(BUILD_EXAMPLES "Build examples" OFF)
if(BUILD_EXAMPLES)
message (STATUS "BUILD_EXAMPLES ........................ on")
else()
message (STATUS "BUILD_EXAMPLES ........................ off")
endif()
# Build with sanitizers
set(SANITIZERS OFF)
if(BUILD_WITH_SANITIZERS AND UNIX AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "12.0.0")
set(ASAN OFF)
set(UBSAN OFF)
set(MSAN OFF)
if("${BUILD_WITH_SANITIZERS}" MATCHES "address")
set(ASAN ON)
list(APPEND PRINT_TYPES_OF_SANITIZERS_LIST "address")
endif()
if("${BUILD_WITH_SANITIZERS}" MATCHES "undefined")
set(UBSAN ON)
list(APPEND PRINT_TYPES_OF_SANITIZERS_LIST "undefined")
endif()
if("${BUILD_WITH_SANITIZERS}" MATCHES "memory")
set(MSAN ON)
list(APPEND PRINT_TYPES_OF_SANITIZERS_LIST "memory")
endif()
if((ASAN OR UBSAN) AND MSAN)
message (FATAL_ERROR "Can not use address | undefined sanitizers with memory sanitizer")
endif()
if(ASAN OR UBSAN OR MSAN)
set(SANITIZERS ON)
endif()
endif()
if(SANITIZERS)
list(JOIN PRINT_TYPES_OF_SANITIZERS_LIST "," PRINT_TYPES_OF_SANITIZERS_STRING)
message (STATUS "BUILD_WITH_SANITIZERS ................. on (${PRINT_TYPES_OF_SANITIZERS_STRING})")
else()
message (STATUS "BUILD_WITH_SANITIZERS ................. off - use -DBUILD_WITH_SANITIZERS=[memory,address,undefined] with CLANG compiler to enable this option")
endif(SANITIZERS)
if((UNIX) AND (NOT APPLE))
set(LINUX ON)
else()
set(LINUX OFF)
endif()
add_subdirectory(sources/ippcp)
if (NOT (CRYPTO_USE_CLANG_TIDY))
if(EXISTS "${IPP_CRYPTO_DIR}/tests/")
add_subdirectory(tests)
endif()
if(EXISTS "${IPP_CRYPTO_DIR}/perf_tests/")
add_subdirectory(perf_tests)
endif()
endif()
if(BUILD_EXAMPLES)
# This helps to organize examples projects structure in IDE by folders
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
add_subdirectory(examples)
endif()