File: FindITT.cmake

package info (click to toggle)
cgal 6.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144,952 kB
  • sloc: cpp: 811,597; ansic: 208,576; sh: 493; python: 411; makefile: 286; javascript: 174
file content (204 lines) | stat: -rw-r--r-- 5,460 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# CGAL note: copy from https://raw.githubusercontent.com/dmitry-gurulev/cmake/104ca4a6c462e3d5a1c217571212238c6446cfca/FindITT.cmake
#
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

#.rst:
# FindITT
# ---------
#
# Find Instrumentation and Tracing Technology (ITT) API include dirs and libraries
#
# Use this module by invoking find_package with the form
#
# ::
#
#   find_package(ITT
#     [REQUIRED]         # Fail with error if ITT is not found
#   )
#
# This module finds headers and libraries
# For the former case results are reported in variables
#
# ::
#
#   ITT_FOUND            - True if headers and requested libraries were found
#   ITT_INCLUDE_DIRS     - ITT include directories
#   ITT_LIBRARIES        - ITT libraries to be linked
#
# This module reads hints about search locations from variables
#
# ::
#
#   SEAPI_ROOT                 - Preferred installation path for IntelĀ® Single Event API (IntelĀ® SEAPI)
#                                (https://github.com/intel/IntelSEAPI)
#   ITT_ROOT/
#   CMAKE_ITT_HOME             - Preferred installation path for standalone ITT library
#   INTEL_LIBITTNOTIFY32/
#   INTEL_LIBITTNOTIFY64       - Preferred ITT library directory
#   VTUNE_AMPLIFIER_<YEAR>_DIR - VTune Amplifier XE installation path which is set by amplxe-vars.sh/bat script
#                                See notes about [ITT_NO_VTUNE_PATH] below
#   CMAKE_VTUNE_HOME           - Explicitly defined VTune Amplifier XE installation path
#
# Other variables one may set to control this module are
#
# ::
#
#   ITT_DEBUG            - Set to ON to enable debug output from FindITT.
#                          Please enable this before filing any bug report.
#   ITT_NO_VTUNE_PATH    - Set to ON to not try to find VTUNE_AMPLIFIER_<YEAR>_DIR environment variable
#
# Example to find ITT headers and libraries
#
# ::
#
#   find_package(ITT)
#   if (ITT_FOUND)
#     include_directories(${ITT_INCLUDE_DIRS})
#     add_executable(foo foo.cc)
#     target_link_libraries(foo ${ITT_LIBRARIES})
#   endif()
#
# Example to find ITT library and use imported targets::
#
# ::
#
#   find_package(ITT REQUIRED)
#   add_executable(foo foo.cc)
#   target_link_libraries(foo ITT::ITT)

unset (_itt_INC_DIR_HINT)
unset (_itt_LIB_DIR_HINT)

set (_itt_ARC "")
if (${CMAKE_CXX_COMPILER_ARCHITECTURE_ID} MATCHES "x86")
	set (_itt_ARC "64")
elseif (${CMAKE_CXX_COMPILER_ARCHITECTURE_ID} MATCHES "x64")
	set (_itt_ARC "64")
endif()

if ("x${_itt_ARC}" STREQUAL "x")
	if (CMAKE_SIZEOF_VOID_P EQUAL 8)
		set (_itt_ARC "64")
	else()
		set (_itt_ARC "32")
	endif()
endif()

list (APPEND _itt_INC_DIR_HINT
	$ENV{ITT_ROOT}
	$ENV{SEAPI_ROOT}/ittnotify
	${CMAKE_ITT_HOME}
	${CMAKE_VTUNE_HOME}
)

set (_itt_LIBITTNOTIFY $ENV{INTEL_LIBITTNOTIFY${_itt_ARC}})
if (_itt_LIBITTNOTIFY)
	get_filename_component (_itt_LIB_DIR_HINT ${_itt_LIBITTNOTIFY} DIRECTORY)
	get_filename_component (_itt_INC_DIR_HINT ${_itt_LIB_DIR_HINT} DIRECTORY)
endif()

list (APPEND _itt_INC_DIR_HINT
	${_itt_INC_DIR_HINT}/ittnotify
)

if (NOT ITT_NO_VTUNE_PATH)
	execute_process (COMMAND "${CMAKE_COMMAND}" "-E" "environment"
		OUTPUT_VARIABLE _itt_ENV_LIST
	)

	string (REGEX MATCH "VTUNE_AMPLIFIER_[0-9]+_DIR"
		_itt_VTUNE_DIR ${_itt_ENV_LIST}
	)
endif()

if (_itt_VTUNE_DIR)
	list (APPEND _itt_INC_DIR_HINT $ENV{${_itt_VTUNE_DIR}})
endif()

if (ITT_DEBUG)
	message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
					"_itt_INC_DIR_HINT = ${_itt_INC_DIR_HINT}")
endif()

find_path (ITT_INCLUDE_DIR
	NAMES ittnotify.h
		HINTS
			${_itt_INC_DIR_HINT}
		PATH_SUFFIXES
			include
)

if (ITT_DEBUG)
	message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
	               "ITT_INCLUDE_DIR = ${ITT_INCLUDE_DIR}")
endif()

if (ITT_DEBUG)
	message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
	               "_itt_ARC = ${_itt_ARC}")
endif()

if (ITT_INCLUDE_DIR)
	get_filename_component (_itt_INC_DIR_HINT ${ITT_INCLUDE_DIR} DIRECTORY)
	list (APPEND _itt_LIB_DIR_HINT ${_itt_INC_DIR_HINT})
endif()

list (APPEND _itt_LIB_DIR_HINT
	$ENV{ITT_ROOT}
	$ENV{SEAPI_ROOT}
)

if (ITT_DEBUG)
	message (STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
	               "_itt_LIB_DIR_HINT = ${_itt_LIB_DIR_HINT}")
endif()

find_library (ITT_LIBRARY
	NAMES
		libittnotify
		libittnotify${_itt_ARC}
		ittnotify
		ittnotify${_itt_ARC}
	HINTS
		${_itt_LIB_DIR_HINT}
	PATH_SUFFIXES
		lib${_itt_ARC}
		lib
		bin
)

if (ITT_DEBUG)
	message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
	               "ITT_LIBRARY = ${ITT_LIBRARY}")
endif()

# handle the QUIETLY and REQUIRED arguments and set MFX_FOUND to TRUE if
# all listed variables are TRUE
include (${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS (ITT
	REQUIRED_VARS ITT_INCLUDE_DIR ITT_LIBRARY
)

mark_as_advanced(ITT_INCLUDE_DIR ITT_LIBRARY)

if (ITT_FOUND)
	set (ITT_INCLUDE_DIRS ${ITT_INCLUDE_DIR})
	set (ITT_LIBRARIES  ${ITT_LIBRARY})

	if (NOT TARGET ITT::ITT)
		add_library(ITT::ITT UNKNOWN IMPORTED)

		set_target_properties(ITT::ITT PROPERTIES
			INTERFACE_INCLUDE_DIRECTORIES "${ITT_INCLUDE_DIRS}"
		)

		set_target_properties(ITT::ITT PROPERTIES
			IMPORTED_LOCATION "${ITT_LIBRARIES}"
		)

		set_target_properties(ITT::ITT PROPERTIES
			INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS}"
		)
	endif()
endif()