FindITT.cmake 2.04 KB
Newer Older
1
# Copyright (C) 2018-2019 Intel Corporation
openvino-pushbot's avatar
openvino-pushbot committed
2 3 4 5 6 7 8 9 10 11 12
# SPDX-License-Identifier: Apache-2.0
#

unset(ITT_INCLUDE_DIR CACHE)
unset(ITT_LIB CACHE)

if(NOT DEFINED INTEL_VTUNE_DIR AND DEFINED ENV{INTEL_VTUNE_DIR})
    set(INTEL_VTUNE_DIR "$ENV{INTEL_VTUNE_DIR}")
endif()
if(NOT DEFINED INTEL_VTUNE_DIR)
    if(EXISTS "/opt/intel/vtune_amplifier_xe/include")
13
        set(INTEL_VTUNE_DIR "/opt/intel/vtune_amplifier_xe")
openvino-pushbot's avatar
openvino-pushbot committed
14 15 16 17 18 19
    elseif(EXISTS "/opt/intel/vtune_amplifier/include")
        set(INTEL_VTUNE_DIR "/opt/intel/vtune_amplifier")
    elseif (EXISTS "C:/Program Files (x86)/IntelSWTools/VTune Amplifier XE")
        set(INTEL_VTUNE_DIR "C:/Program Files (x86)/IntelSWTools/VTune Amplifier XE")
    elseif (EXISTS "C:/Program Files (x86)/IntelSWTools/VTune Amplifier")
        set(INTEL_VTUNE_DIR "C:/Program Files (x86)/IntelSWTools/VTune Amplifier")
20 21
    elseif (EXISTS "$ENV{HOME}/intel/vtune_amplifier_2019")
        set(INTEL_VTUNE_DIR "$ENV{HOME}/intel/vtune_amplifier_2019")
openvino-pushbot's avatar
openvino-pushbot committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
    endif()
endif()

if(DEFINED INTEL_VTUNE_DIR)
    message(STATUS "INTEL_VTUNE_DIR = ${INTEL_VTUNE_DIR}")

    find_path(ITT_INCLUDE_DIR
    FILES
        ittnotify.h
    PATHS "${INTEL_VTUNE_DIR}/include/")

    find_library(ITT_LIB
    "libittnotify${CMAKE_STATIC_LIBRARY_SUFFIX}"
    PATHS ${INTEL_VTUNE_DIR}/lib64)

37
    set(Located_ITT_LIBS ${ITT_LIB})
openvino-pushbot's avatar
openvino-pushbot committed
38 39 40 41 42 43 44 45 46 47 48 49
    set(Located_ITT_INCLUDE_DIRS ${ITT_INCLUDE_DIR})
else()
    message(STATUS "INTEL_VTUNE_DIR is not defined")
endif()

# Handle find_package() arguments, and set INTEL_ITT_FOUND
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(INTEL_ITT
    REQUIRED_VARS
        Located_ITT_INCLUDE_DIRS
        Located_ITT_LIBS)

50 51 52 53 54
if(INTEL_ITT_FOUND)
    add_library(ittnotify STATIC IMPORTED GLOBAL)
    set_target_properties(ittnotify PROPERTIES IMPORTED_LOCATION "${Located_ITT_LIBS}"
                                               INTERFACE_INCLUDE_DIRECTORIES ${Located_ITT_INCLUDE_DIRS}
                                               INTERFACE_COMPILE_DEFINITIONS ENABLE_PROFILING_ITT)
openvino-pushbot's avatar
openvino-pushbot committed
55

56
    set(INTEL_ITT_LIBS ittnotify ${CMAKE_DL_LIBS})
openvino-pushbot's avatar
openvino-pushbot committed
57
endif()