|
1 | 1 | # If successful, the following variables will be defined:
|
2 |
| -# HAVE_LIBPFM. |
3 |
| -# Set BENCHMARK_ENABLE_LIBPFM to 0 to disable, regardless of libpfm presence. |
4 |
| -include(CheckIncludeFile) |
5 |
| -include(CheckLibraryExists) |
| 2 | +# PFM_FOUND. |
| 3 | +# PFM_LIBRARIES |
| 4 | +# PFM_INCLUDE_DIRS |
| 5 | +# the following target will be defined: |
| 6 | +# PFM::libpfm |
| 7 | + |
6 | 8 | include(FeatureSummary)
|
7 |
| -enable_language(C) |
| 9 | +include(FindPackageHandleStandardArgs) |
8 | 10 |
|
9 | 11 | set_package_properties(PFM PROPERTIES
|
10 | 12 | URL http://perfmon2.sourceforge.net/
|
11 |
| - DESCRIPTION "a helper library to develop monitoring tools" |
| 13 | + DESCRIPTION "A helper library to develop monitoring tools" |
12 | 14 | PURPOSE "Used to program specific performance monitoring events")
|
13 | 15 |
|
14 |
| -check_library_exists(libpfm.a pfm_initialize "" HAVE_LIBPFM_INITIALIZE) |
15 |
| -if(HAVE_LIBPFM_INITIALIZE) |
16 |
| - check_include_file(perfmon/perf_event.h HAVE_PERFMON_PERF_EVENT_H) |
17 |
| - check_include_file(perfmon/pfmlib.h HAVE_PERFMON_PFMLIB_H) |
18 |
| - check_include_file(perfmon/pfmlib_perf_event.h HAVE_PERFMON_PFMLIB_PERF_EVENT_H) |
19 |
| - if(HAVE_PERFMON_PERF_EVENT_H AND HAVE_PERFMON_PFMLIB_H AND HAVE_PERFMON_PFMLIB_PERF_EVENT_H) |
| 16 | +find_library(PFM_LIBRARY NAMES pfm) |
| 17 | +find_path(PFM_INCLUDE_DIR NAMES perfmon/pfmlib.h) |
| 18 | + |
| 19 | +find_package_handle_standard_args(PFM REQUIRED_VARS PFM_LIBRARY PFM_INCLUDE_DIR) |
| 20 | + |
| 21 | +if (PFM_FOUND AND NOT TARGET PFM::libpfm) |
| 22 | + add_library(PFM::libpfm UNKNOWN IMPORTED) |
| 23 | + set_target_properties(PFM::libpfm PROPERTIES |
| 24 | + IMPORTED_LOCATION "${PFM_LIBRARY}" |
| 25 | + INTERFACE_INCLUDE_DIRECTORIES "${PFM_INCLUDE_DIR}") |
20 | 26 | message("Using Perf Counters.")
|
21 | 27 | set(HAVE_LIBPFM 1)
|
22 | 28 | set(PFM_FOUND 1)
|
23 |
| - endif() |
24 | 29 | else()
|
25 |
| - message("Perf Counters support requested, but was unable to find libpfm.") |
| 30 | + message("Perf Counters support requested, but was unable to find libpfm.") |
26 | 31 | endif()
|
| 32 | + |
| 33 | +mark_as_advanced(PFM_LIBRARY PFM_INCLUDE_DIR) |
0 commit comments