xref: /aosp_15_r20/external/google-benchmark/cmake/Modules/FindPFM.cmake (revision dbb99499c3810fa1611fa2242a2fc446be01a57c)
1# If successful, the following variables will be defined:
2# PFM_FOUND.
3# PFM_LIBRARIES
4# PFM_INCLUDE_DIRS
5# the following target will be defined:
6# PFM::libpfm
7
8include(FeatureSummary)
9include(FindPackageHandleStandardArgs)
10
11set_package_properties(PFM PROPERTIES
12                       URL http://perfmon2.sourceforge.net/
13                       DESCRIPTION "A helper library to develop monitoring tools"
14                       PURPOSE "Used to program specific performance monitoring events")
15
16find_library(PFM_LIBRARY NAMES pfm)
17find_path(PFM_INCLUDE_DIR NAMES perfmon/pfmlib.h)
18
19find_package_handle_standard_args(PFM REQUIRED_VARS PFM_LIBRARY PFM_INCLUDE_DIR)
20
21if (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}")
26endif()
27
28mark_as_advanced(PFM_LIBRARY PFM_INCLUDE_DIR)
29