|
1 |
| -############################################################################# |
2 |
| -# This file was found and adapted from original LLNL tools called perf-dump. |
3 |
| -# |
4 |
| -# Copyright (c) 2013-2014, Lawrence Livermore National Security, LLC. |
5 |
| -# Produced at the Lawrence Livermore National Laboratory. |
6 |
| -# |
7 |
| -# This file is part of perf-dump. |
8 |
| -# Written by Todd Gamblin, [email protected], All rights reserved. |
9 |
| -# LLNL-CODE-647187 |
10 |
| -# |
11 |
| -#For details, see https://scalability-llnl.github.io/perf-dump |
12 |
| -# |
13 |
| -############################################################################# |
14 |
| -# |
15 |
| -# Try to find PAPI headers and libraries. |
16 |
| -# |
17 |
| -# Usage of this module as follows: |
18 |
| -# |
19 |
| -# find_package(PAPI) |
20 |
| -# |
21 |
| -# Variables used by this module, they can change the default behaviour and need |
22 |
| -# to be set before calling find_package: |
23 |
| -# |
24 |
| -# |
25 |
| -# PAPI_ROOT Set this environment variable to the root installation of |
26 |
| -# libpapi if the module has problems finding the |
27 |
| -# proper installation path. |
28 |
| -# |
29 |
| -# Variables defined by this module: |
30 |
| -# |
31 |
| -# PAPI_FOUND System has PAPI libraries and headers |
32 |
| -# PAPI_LIBRARY The PAPI library |
33 |
| -# PAPI_INCLUDE_DIR The location of PAPI headers |
34 |
| - |
35 |
| -find_library(PAPI_LIBRARY |
36 |
| - NAMES libpapi.so libpapi.a papi |
37 |
| - HINTS ENV PAPI_ROOT |
38 |
| - PATH_SUFFIXES lib lib64 |
39 |
| -) |
| 1 | +# - Try to find PAPI performance library |
| 2 | +# Defines: |
| 3 | +# PAPI_FOUND - System has PAPI |
| 4 | +# PAPI::PAPI - Imported target |
40 | 5 |
|
41 | 6 | find_path(PAPI_INCLUDE_DIR
|
42 | 7 | NAMES papi.h
|
43 |
| - HINTS ENV PAPI_ROOT |
| 8 | + HINTS ${PAPI_ROOT} ENV PAPI_ROOT |
44 | 9 | PATH_SUFFIXES include
|
45 | 10 | )
|
46 | 11 |
|
47 |
| -if (PAPI_INCLUDE_DIR AND PAPI_LIBRARY) |
48 |
| - set(PAPI_LIBRARIES ${PAPI_LIBRARY}) |
49 |
| -else() |
| 12 | +find_library(PAPI_LIBRARY |
| 13 | + NAMES papi |
| 14 | + HINTS ${PAPI_ROOT} ENV PAPI_ROOT |
| 15 | + PATH_SUFFIXES lib lib64 |
| 16 | +) |
50 | 17 |
|
51 |
| - set(PAPI_INCLUDE_DIR "") |
52 |
| - set(PAPI_LIBRARIES "") |
53 |
| -endif() |
| 18 | +include(FindPackageHandleStandardArgs) |
| 19 | +find_package_handle_standard_args(PAPI |
| 20 | + REQUIRED_VARS PAPI_LIBRARY PAPI_INCLUDE_DIR |
| 21 | +) |
54 | 22 |
|
| 23 | +if(PAPI_FOUND AND NOT TARGET PAPI::PAPI) |
| 24 | + add_library(PAPI::PAPI UNKNOWN IMPORTED) |
55 | 25 |
|
56 |
| -include(FindPackageHandleStandardArgs) |
57 |
| -find_package_handle_standard_args(PAPI DEFAULT_MSG PAPI_LIBRARIES PAPI_INCLUDE_DIR) |
| 26 | + set_target_properties(PAPI::PAPI PROPERTIES |
| 27 | + INTERFACE_INCLUDE_DIRECTORIES "${PAPI_INCLUDE_DIR}" |
| 28 | + IMPORTED_LOCATION "${PAPI_LIBRARY}" |
| 29 | + ) |
| 30 | +endif() |
58 | 31 |
|
59 |
| -mark_as_advanced(PAPI_INCLUDE_DIR PAPI_LIBRARIES) |
| 32 | +mark_as_advanced( |
| 33 | + PAPI_INCLUDE_DIR |
| 34 | + PAPI_LIBRARY |
| 35 | +) |
0 commit comments