38 lines · plain
1# CMake module for finding libpfm4.2#3# If successful, the following variables will be defined:4# HAVE_LIBPFM5#6# Libpfm can be disabled by setting LLVM_ENABLE_LIBPFM to 0.7 8include(CheckIncludeFile)9include(CheckLibraryExists)10include(CheckCXXSourceCompiles)11 12if (LLVM_ENABLE_LIBPFM)13 check_library_exists(pfm pfm_initialize "" HAVE_LIBPFM_INITIALIZE)14 if(HAVE_LIBPFM_INITIALIZE)15 check_include_file(perfmon/perf_event.h HAVE_PERFMON_PERF_EVENT_H)16 check_include_file(perfmon/pfmlib.h HAVE_PERFMON_PFMLIB_H)17 check_include_file(perfmon/pfmlib_perf_event.h HAVE_PERFMON_PFMLIB_PERF_EVENT_H)18 if(HAVE_PERFMON_PERF_EVENT_H AND HAVE_PERFMON_PFMLIB_H AND HAVE_PERFMON_PFMLIB_PERF_EVENT_H)19 set(HAVE_LIBPFM 1)20 # Check to see if perf_branch_entry has the field 'cycles'.21 # We couldn't use CheckStructHasMember here because 'cycles' is a bit field which is not22 # supported by CheckStructHasMember.23 CHECK_CXX_SOURCE_COMPILES("24 #include <perfmon/perf_event.h>25 int main() {26 perf_branch_entry entry;27 entry.cycles = 2;28 return 0;29 }" COMPILE_WITH_CYCLES)30 if(COMPILE_WITH_CYCLES)31 set(LIBPFM_HAS_FIELD_CYCLES 1)32 endif()33 endif()34 endif()35endif()36 37 38