aboutsummaryrefslogtreecommitdiff
path: root/cmake/Modules/FindNaCl.cmake
blob: b1a8da457d710bbbc2ea07309a718365a93c183a (plain)
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
# - Try to find NaCl
# Once done this will define
#
#  NACL_FOUND - system has NaCl
#  NACL_INCLUDE_DIRS - the NaCl include directory
#  NACL_LIBRARIES - Link these to use NaCl
#  NACL_DEFINITIONS - Compiler switches required for using NaCl
#
#  Copyright (c) 2010 Andreas Schneider <asn@cryptomilk.org>
#  Copyright (c) 2013 Aris Adamantiadis <aris@badcode.be>
#
#  Redistribution and use is allowed according to the terms of the New
#  BSD license.
#  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#


if (NACL_LIBRARIES AND NACL_INCLUDE_DIRS)
  # in cache already
  set(NACL_FOUND TRUE)
else (NACL_LIBRARIES AND NACL_INCLUDE_DIRS)

  find_path(NACL_INCLUDE_DIR
    NAMES
      nacl/crypto_box_curve25519xsalsa20poly1305.h
    PATHS
      /usr/include
      /usr/local/include
      /opt/local/include
      /sw/include
  )

  find_library(NACL_LIBRARY
    NAMES
      nacl
    PATHS
      /usr/lib
      /usr/local/lib
      /opt/local/lib
      /sw/lib
  )

  set(NACL_INCLUDE_DIRS
    ${NACL_INCLUDE_DIR}
  )

  if (NACL_LIBRARY)
    set(NACL_LIBRARIES
        ${NACL_LIBRARIES}
        ${NACL_LIBRARY}
    )
  endif (NACL_LIBRARY)

  include(FindPackageHandleStandardArgs)
  find_package_handle_standard_args(NaCl DEFAULT_MSG NACL_LIBRARIES NACL_INCLUDE_DIRS)

  # show the NACL_INCLUDE_DIRS and NACL_LIBRARIES variables only in the advanced view
  mark_as_advanced(NACL_INCLUDE_DIRS NACL_LIBRARIES)

endif (NACL_LIBRARIES AND NACL_INCLUDE_DIRS)