diff --git a/CMakeLists.txt b/CMakeLists.txt index 30c424a2b6..952cb2290b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -512,13 +512,13 @@ if(NOT ANDROID) endif(PORTAUDIO) if(OPROFILING) - check_lib(OPROFILE "(no .pc for opagent)" opagent opagent.h) - check_lib(BFD "(no .pc for bfd)" bfd bfd.h) - if(OPROFILE_FOUND AND BFD_FOUND) - message("oprofile found, enabling profiling support") + include(FindOProfile) + if(OPROFILE_FOUND) + message("OProfile found, enabling profiling support") add_definitions(-DUSE_OPROFILE=1) + include_directories(${OPROFILE_INCLUDE_DIRS}) else() - message(FATAL_ERROR "oprofile or bfd not found. Can't build profiling support.") + message(FATAL_ERROR "OProfile not found. Can't build profiling support.") endif() endif() endif() diff --git a/CMakeTests/FindOProfile.cmake b/CMakeTests/FindOProfile.cmake new file mode 100644 index 0000000000..b82e47307d --- /dev/null +++ b/CMakeTests/FindOProfile.cmake @@ -0,0 +1,19 @@ +# - Try to find OProfile +# Once done this will define +# OPROFILE_FOUND - System has OProfile +# OPROFILE_INCLUDE_DIRS - The OProfile include directories +# OPROFILE_LIBRARIES - The libraries needed to use OProfile + +find_path(OPROFILE_INCLUDE_DIR opagent.h) + +find_library(OPROFILE_LIBRARY opagent + PATH_SUFFIXES oprofile) + +set(OPROFILE_INCLUDE_DIRS ${OPROFILE_INCLUDE_DIR}) +set(OPROFILE_LIBRARIES ${OPROFILE_LIBRARY}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OProfile DEFAULT_MSG + OPROFILE_LIBRARY OPROFILE_INCLUDE_DIR) + +mark_as_advanced(OPROFILE_INCLUDE_DIR OPROFILE_LIBRARY) diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index 2fd2bf7bb5..bd69afeb80 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -265,7 +265,7 @@ if(PORTAUDIO_FOUND) endif(PORTAUDIO_FOUND) if(OPROFILE_FOUND) - set(LIBS ${LIBS} opagent bfd) + set(LIBS ${LIBS} ${OPROFILE_LIBRARIES}) endif(OPROFILE_FOUND) if(GDBSTUB)