summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLéo Lam <leolino.lam@gmail.com>2018-04-14 23:12:17 +0200
committerGitHub <noreply@github.com>2018-04-14 23:12:17 +0200
commitaafa8a10e10e26b4068b19cdc5b1bb36dfa9fbf2 (patch)
treecf79d2532e5ea1258d3dba0f63664f8e1a436f35
parente253d3d919e13439ac65ba265246c1990e2c3e1d (diff)
parentb31281527a6d3b156b742d03917d82a61cbd99ad (diff)
Merge pull request #6643 from lioncash/oprofile
CMakeLists: Define an OProfile target and use it
-rw-r--r--CMake/FindOProfile.cmake16
-rw-r--r--CMakeLists.txt1
-rw-r--r--Source/Core/Common/CMakeLists.txt2
3 files changed, 15 insertions, 4 deletions
diff --git a/CMake/FindOProfile.cmake b/CMake/FindOProfile.cmake
index b82e47307d..7f349307f0 100644
--- a/CMake/FindOProfile.cmake
+++ b/CMake/FindOProfile.cmake
@@ -7,13 +7,25 @@
find_path(OPROFILE_INCLUDE_DIR opagent.h)
find_library(OPROFILE_LIBRARY opagent
- PATH_SUFFIXES oprofile)
+ 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)
+ OPROFILE_LIBRARY OPROFILE_INCLUDE_DIR
+)
+
+if (OPROFILE_FOUND)
+ if (NOT TARGET OProfile::OProfile)
+ add_library(OProfile::OProfile UNKNOWN IMPORTED)
+ set_target_properties(OProfile::OProfile PROPERTIES
+ IMPORTED_LOCATION ${OPROFILE_LIBRARIES}
+ INTERFACE_INCLUDE_DIRECTORIES ${OPROFILE_INCLUDE_DIRS}
+ )
+ endif()
+endif()
mark_as_advanced(OPROFILE_INCLUDE_DIR OPROFILE_LIBRARY)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eae9557eac..d8f280f534 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -473,7 +473,6 @@ if(OPROFILING)
if(OPROFILE_FOUND)
message(STATUS "OProfile found, enabling profiling support")
add_definitions(-DUSE_OPROFILE=1)
- include_directories(${OPROFILE_INCLUDE_DIRS})
else()
message(FATAL_ERROR "OProfile not found. Can't build profiling support.")
endif()
diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt
index 4ef3af3ac5..15c79c3d3b 100644
--- a/Source/Core/Common/CMakeLists.txt
+++ b/Source/Core/Common/CMakeLists.txt
@@ -146,7 +146,7 @@ if(USE_UPNP)
endif()
if(OPROFILE_FOUND)
- target_link_libraries(common PRIVATE ${OPROFILE_LIBRARIES})
+ target_link_libraries(common PRIVATE OProfile::OProfile)
endif()
if(UNIX)