File: FindIPPCrypto.cmake

package info (click to toggle)
ipp-crypto 1%3A1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,248 kB
  • sloc: ansic: 182,172; asm: 36,521; pascal: 9,645; python: 2,677; cpp: 1,874; makefile: 43
file content (115 lines) | stat: -rw-r--r-- 3,824 bytes parent folder | download
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
#=========================================================================
# Copyright (C) 2019 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
# library detection routine.
#
# If found the following variables will be available:
#       IPPCRYPTO_FOUND
#       IPPCRYPTO_ROOT_DIR
#       IPPCRYPTO_INCLUDE_DIRS
#       IPPCRYPTO_LIBRARIES
#

include(FindPackageHandleStandardArgs)

macro(ippcp_not_found)
  set(IPPCRYPTO_FOUND OFF)
  set(IPPCRYPTO_ROOT_DIR "${IPPCRYPTO_ROOT_DIR}" CACHE PATH "Path to Intel Cryptography Primitives Library root directory")
  return()
endmacro()

# Try to find Intel Cryptography Primitives Library on the system if root dir is not defined externally
if (NOT IPPCRYPTO_ROOT_DIR OR NOT EXISTS "${IPPCRYPTO_ROOT_DIR}/include/ippcp.h")
  set(ippcp_search_paths
    ${CMAKE_CURRENT_SOURCE_DIR}/../.build
    $ENV{IPPCRYPTOROOT})

  if(WIN32)
    list(APPEND ippcp_search_paths
      $ENV{ProgramFiles\(x86\)}/IntelSWTools/compilers_and_libraries/windows/ippcp
      $ENV{ProgramFiles\(x86\)}/Intel/oneAPI/ippcp/latest)
  endif()

  if(UNIX)
    list(APPEND ippcp_search_paths
      /opt/intel/ippcp
      $ENV{HOME}/intel/ippcp
      /opt/intel/oneapi/ippcp/latest
      $ENV{HOME}/intel/oneapi/ippcp/latest)
  endif()

  find_path(IPPCRYPTO_ROOT_DIR include/ippcp.h PATHS ${ippcp_search_paths})
endif()

set(IPPCRYPTO_INCLUDE_DIRS "${IPPCRYPTO_ROOT_DIR}/include" CACHE PATH "Path to Intel Cryptography Primitives Library include directory" FORCE)

# Check found directory
if(NOT IPPCRYPTO_ROOT_DIR
    OR NOT EXISTS "${IPPCRYPTO_ROOT_DIR}"
    OR NOT EXISTS "${IPPCRYPTO_INCLUDE_DIRS}"
    OR NOT EXISTS "${IPPCRYPTO_INCLUDE_DIRS}/ippcp.h"
    )
  ippcp_not_found()
endif()

# Determine ARCH
set(IPPCRYPTO_ARCH "ia32")
if(CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8)
  set(IPPCRYPTO_ARCH "intel64")
endif()
if(CMAKE_SIZEOF_VOID_P)
  set(IPPCRYPTO_ARCH "intel64")
endif()

# Define list of libraries to search
set(IPPCP_SUFFIX "")
if(WIN32)
  set(IPPCP_SUFFIX "mt") # static lib on Windows
endif()
set(ippcp_search_libraries
  ippcp${IPPCP_SUFFIX})

# Define library search paths (TODO: to handle nonpic libraries)
set(ippcp_lib_search_paths "")
list(APPEND ippcp_lib_search_paths
  ${IPPCRYPTO_ROOT_DIR}/lib
  ${IPPCRYPTO_ROOT_DIR}/lib/${IPPCRYPTO_ARCH})

# Set preferences to look for static libraries only
if(WIN32)
  list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .lib .a)
else()
  set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
endif()

foreach(lib ${ippcp_search_libraries})
  find_library(${lib} ${lib} ${ippcp_lib_search_paths})
  if(NOT ${lib})
    ippcp_not_found()
  endif()
  list(APPEND IPPCRYPTO_LIBRARIES ${${lib}})
endforeach()

list(REMOVE_DUPLICATES IPPCRYPTO_LIBRARIES)

message(STATUS "Found Intel Cryptography Primitives Library at: ${IPPCRYPTO_ROOT_DIR}")

set(IPPCRYPTO_FOUND ON)
set(IPPCRYPTO_ROOT_DIR "${IPPCRYPTO_ROOT_DIR}" CACHE PATH "Path to Intel Cryptography Primitives Library root directory")
set(IPPCRYPTO_INCLUDE_DIRS "${IPPCRYPTO_INCLUDE_DIRS}" CACHE PATH "Path to Intel Cryptography Primitives Library include directory")
set(IPPCRYPTO_LIBRARIES "${IPPCRYPTO_LIBRARIES}" CACHE STRING "Intel Cryptography Primitives Library libraries")