File: FindLibPapi.cmake

package info (click to toggle)
eztrace 2.0%2Brepack-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,132 kB
  • sloc: ansic: 23,501; perl: 910; sh: 857; cpp: 771; makefile: 696; fortran: 327; f90: 320; python: 57
file content (81 lines) | stat: -rw-r--r-- 2,486 bytes parent folder | download | duplicates (6)
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
# - Find libpapi include dirs and libraries
# Use this module by invoking find_package with the form:
# find_package(LIBPAPI [REQUIRED]) # Fail with error if libpapi is not found
# This module finds libpapi headers and library.
# Results are reported in variables:
# LIBPAPI_FOUND - True if headers and requested libraries were found
# LIBPAPI_INCLUDE_DIRS - libpapi include directories
# LIBPAPI_LIBRARIES - libpapi component libraries to be linked
# -------------------------------------------------------------------------------------

if (LIBPAPI_LIBRARIES AND LIBPAPI_INCLUDE_DIRS)
  set (LibPapi_FIND_QUIETLY TRUE)
endif (LIBPAPI_LIBRARIES AND LIBPAPI_INCLUDE_DIRS)

unset(_inc_env)
string(REPLACE ":" ";" _path_env "$ENV{include}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{C_include_PATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{CPATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{include_PATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{PATH}")
list(APPEND _inc_env "${_path_env}")
list(REMOVE_DUPLICATES _inc_env)

find_path (LIBPAPI_INCLUDE_DIRS
NAMES
papi.h
PATHS
${_inc_env}
/usr/include
/usr/include/libpapi
/usr/local/include
/usr/local/include/libpapi
/opt/local/include
/opt/local/include/libpapi
ENV CPATH)

## Search library in user defined path (via LD_LIBRARY_PATH and LIBRARY_PATH)
unset(_lib_env)
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
list(APPEND _lib_env "${_path_env}")
string(REPLACE ":" ";" _lib_env "$ENV{LIBRARY_PATH}")
list(APPEND _lib_env "${_path_env}")
string(REPLACE ":" ";" _lib_env "$ENV{MIC_LD_LIBRARY_PATH}")
list(APPEND _lib_env "${_path_env}")
list(REMOVE_DUPLICATES _lib_env)

find_library (
  LIBPAPI_LIBRARIES
  NAMES papi
  HINTS ${_lib_env}
  NO_DEFAULT_PATH
)

## Search in standard path
if (NOT LIBPAPI_LIBRARIES)
  unset(_lib_env)
  list(APPEND _lib_env "/usr/local/lib64")
  list(APPEND _lib_env "/usr/lib64")
  list(APPEND _lib_env "/usr/local/lib")
  list(APPEND _lib_env "/usr/lib")

  find_library (
    LIBPAPI_LIBRARIES
    NAMES papi
    PATHS ${_lib_env}
    )
endif()

include (FindPackageHandleStandardArgs)

# handle the QUIETLY and REQUIRED arguments and set LIBPAPI_FOUND to TRUE if all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibPapi DEFAULT_MSG
LIBPAPI_LIBRARIES
LIBPAPI_INCLUDE_DIRS
)

mark_as_advanced(LIBPAPI_INCLUDE_DIRS LIBPAPI_LIBRARIES)