2
0

Update dyninst to v13 (#190)

Update Dyninst submodule
Refactoring of build scripts to build TBB, Boost, ElfUtils, and LibIberty, since Dyninst build scripts no longer do.
Workflows are now building Dyninst and its dependencies.

---------

Co-authored-by: marantic-amd <marantic@amd.com>
Co-authored-by: David Galiffi <David.Galiffi@amd.com>

[ROCm/rocprofiler-systems commit: 96df9b6d3e]
Este cometimento está contido em:
Pranjal Swarup
2025-06-06 22:52:23 -04:00
cometido por GitHub
ascendente c7c3c3f97e
cometimento 9d94e11e2b
26 ficheiros modificados com 2071 adições e 34 eliminações
+141
Ver ficheiro
@@ -0,0 +1,141 @@
#[=======================================================================[.rst:
FindLibDW
---------
Find libdw, the elfutils library for DWARF data and ELF file or process inspection.
Variables that affect this module
``LibDW_NO_SYSTEM_PATHS``
If `True`, no system paths are searched.
Imported targets
^^^^^^^^^^^^^^^^
This module defines the following :prop_tgt:`IMPORTED` target:
``LibDW::LibDW``
The libdw library, if found.
Result variables
^^^^^^^^^^^^^^^^
This module will set the following variables in your project:
``LibDW_INCLUDE_DIRS``
where to find libdw.h, etc.
``LibDW_LIBRARIES``
the libraries to link against to use libdw.
``LibDW_FOUND``
If false, do not try to use libdw.
``LibDW_VERSION``
the version of the libdw library found
#]=======================================================================]
cmake_policy(SET CMP0074 NEW) # Use <Package>_ROOT
if(LibDW_NO_SYSTEM_PATHS)
set(_find_path_args NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH)
endif()
# There is no way to tell pkg-config to ignore directories, so disable it
if(NOT LibDW_NO_SYSTEM_PATHS)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
if(NOT "x${LibDW_FIND_VERSION}" STREQUAL "x")
set(_version ">=${LibDW_FIND_VERSION}")
endif()
if(LibDW_FIND_QUIETLY)
set(_quiet "QUIET")
endif()
pkg_check_modules(PC_LIBDW ${_quiet} "libdw${_version}")
unset(_version)
unset(_quiet)
endif()
endif()
if(PC_LIBDW_FOUND)
# FindPkgConfig sometimes gets the include dir wrong
if("x${PC_LIBDW_INCLUDE_DIRS}" STREQUAL "x")
pkg_get_variable(PC_LIBDW_INCLUDE_DIRS libdw includedir)
endif()
set(LibDW_INCLUDE_DIRS
${PC_LIBDW_INCLUDE_DIRS}
CACHE PATH "")
set(LibDW_LIBRARIES
${PC_LIBDW_LINK_LIBRARIES}
CACHE PATH "")
set(LibDW_VERSION
${PC_LIBDW_VERSION}
CACHE STRING "")
else()
find_path(
LibDW_INCLUDE_DIRS
NAMES libdw.h
PATH_SUFFIXES elfutils ${_find_path_args})
find_library(
LibDW_LIBRARIES
NAMES libdw dw
PATH_SUFFIXES elfutils ${_find_path_args})
if(EXISTS "${LibDW_INCLUDE_DIRS}/version.h")
file(STRINGS "${LibDW_INCLUDE_DIRS}/version.h" _version_line
REGEX "^#define _ELFUTILS_VERSION[ \t]+[0-9]+")
string(REGEX MATCH "[0-9]+" _version "${_version_line}")
if(NOT "x${_version}" STREQUAL "x")
set(LibDW_VERSION "0.${_version}")
endif()
unset(_version_line)
unset(_version)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
LibDW
FOUND_VAR LibDW_FOUND
REQUIRED_VARS LibDW_LIBRARIES LibDW_INCLUDE_DIRS
VERSION_VAR LibDW_VERSION)
if(LibDW_FOUND)
mark_as_advanced(LibDW_INCLUDE_DIRS)
mark_as_advanced(LibDW_LIBRARIES)
mark_as_advanced(LibDW_VERSION)
# Some platforms explicitly list libelf as a dependency, so separate it out
list(LENGTH LibDW_LIBRARIES _cnt)
if(${_cnt} GREATER 1)
foreach(_l ${LibDW_LIBRARIES})
if(${_l} MATCHES "libdw")
set(_libdw ${_l})
else()
list(APPEND _link_libs ${_l})
endif()
endforeach()
endif()
unset(_cnt)
if(NOT TARGET LibDW::LibDW)
add_library(LibDW::LibDW UNKNOWN IMPORTED)
set_target_properties(LibDW::LibDW PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${LibDW_INCLUDE_DIRS}")
if(NOT "x${_link_libs}" STREQUAL "x")
set_target_properties(
LibDW::LibDW PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LINK_DEPENDENT_LIBRARIES "${_link_libs}")
set(LibDW_LIBRARIES ${_libdw})
unset(_libdw)
unset(_link_libs)
endif()
set_target_properties(
LibDW::LibDW PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${LibDW_LIBRARIES}")
endif()
endif()
unset(_find_path_args)
@@ -0,0 +1,118 @@
#[=======================================================================[.rst:
FindLibDebuginfod
-----------------
Find libdebuginfod, the elfutils library to query debuginfo files from debuginfod servers.
Variables that affect this module
``LibDebuginfod_NO_SYSTEM_PATHS``
If `True`, no system paths are searched.
Imported targets
^^^^^^^^^^^^^^^^
This module defines the following :prop_tgt:`IMPORTED` target:
``LibDebuginfod::LibDebuginfod``
The libdebuginfod library, if found.
Result variables
^^^^^^^^^^^^^^^^
This module will set the following variables in your project:
``LibDebuginfod_INCLUDE_DIRS``
where to find debuginfod.h, etc.
``LibDebuginfod_LIBRARIES``
the libraries to link against to use libdebuginfod.
``LibDebuginfod_FOUND``
If false, do not try to use libdebuginfod.
``LibDebuginfod_VERSION``
the version of the libdebuginfod library found
#]=======================================================================]
cmake_policy(SET CMP0074 NEW) # Use <Package>_ROOT
if(LibDebuginfod_NO_SYSTEM_PATHS)
set(_find_path_args NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH)
endif()
# There is no way to tell pkg-config to ignore directories, so disable it
if(NOT LibDebuginfod_NO_SYSTEM_PATHS)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
if(NOT "x${LibDebuginfod_FIND_VERSION}" STREQUAL "x")
set(_version ">=${LibDebuginfod_FIND_VERSION}")
endif()
if(LibDebuginfod_FIND_QUIETLY)
set(_quiet "QUIET")
endif()
pkg_check_modules(PC_LIBDEBUGINFOD ${_quiet} "libdebuginfod${_version}")
unset(_version)
unset(_quiet)
endif()
endif()
if(PC_LIBDEBUGINFOD_FOUND)
# FindPkgConfig sometimes gets the include dir wrong
if("x${PC_LIBDEBUGINFOD_INCLUDE_DIRS}" STREQUAL "x")
pkg_get_variable(PC_LIBDEBUGINFOD_INCLUDE_DIRS libdebuginfod includedir)
endif()
set(LibDebuginfod_INCLUDE_DIRS
${PC_LIBDEBUGINFOD_INCLUDE_DIRS}
CACHE PATH "")
set(LibDebuginfod_LIBRARIES
${PC_LIBDEBUGINFOD_LINK_LIBRARIES}
CACHE PATH "")
set(LibDebuginfod_VERSION
${PC_LIBDEBUGINFOD_VERSION}
CACHE STRING "")
else()
find_path(
LibDebuginfod_INCLUDE_DIRS
NAMES debuginfod.h
PATH_SUFFIXES elfutils ${_find_path_args})
find_library(
LibDebuginfod_LIBRARIES
NAMES libdebuginfod debuginfod
PATH_SUFFIXES elfutils ${_find_path_args})
if(EXISTS "${LibDebuginfod_INCLUDE_DIRS}/version.h")
file(STRINGS "${LibDebuginfod_INCLUDE_DIRS}/version.h" _version_line
REGEX "^#define _ELFUTILS_VERSION[ \t]+[0-9]+")
string(REGEX MATCH "[0-9]+" _version "${_version_line}")
if(NOT "x${_version}" STREQUAL "x")
set(LibDebuginfod_VERSION "0.${_version}")
endif()
unset(_version_line)
unset(_version)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
LibDebuginfod
FOUND_VAR LibDebuginfod_FOUND
REQUIRED_VARS LibDebuginfod_LIBRARIES LibDebuginfod_INCLUDE_DIRS
VERSION_VAR LibDebuginfod_VERSION)
if(LibDebuginfod_FOUND)
mark_as_advanced(LibDebuginfod_INCLUDE_DIR)
mark_as_advanced(LibDebuginfod_LIBRARIES)
mark_as_advanced(LibDebuginfod_VERSION)
if(NOT TARGET LibDebuginfod::LibDebuginfod)
add_library(LibDebuginfod::LibDebuginfod UNKNOWN IMPORTED)
set_target_properties(
LibDebuginfod::LibDebuginfod
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LibDebuginfod_INCLUDE_DIRS}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${LibDebuginfod_LIBRARIES}")
endif()
endif()
unset(_find_path_args)
@@ -0,0 +1,86 @@
# ===================================================================================
# FindLibDwarf.cmake
#
# Find libdw include dirs and libraries
#
# ----------------------------------------
#
# Use this module by invoking find_package with the form::
#
# find_package(LibDwarf [version] [EXACT] # Minimum or EXACT version e.g. 0.173
# [REQUIRED] # Fail with error if libdw is not found )
#
# This module reads hints about search locations from variables::
#
# LibDwarf_ROOT_DIR - Base directory the of libdw installation
# LibDwarf_INCLUDEDIR - Hint directory that contains the libdw headers files
# LibDwarf_LIBRARYDIR - Hint directory that contains the libdw library files
#
# and saves search results persistently in CMake cache entries::
#
# LibDwarf_FOUND - True if headers and requested libraries were found
# LibDwarf_INCLUDE_DIRS - libdw include directories LibDwarf_LIBRARY_DIRS - Link
# directories for libdw libraries LibDwarf_LIBRARIES - libdw library files
#
# ===================================================================================
# Non-standard subdirectories to search
set(_path_suffixes libdw libdwarf elfutils)
find_path(
LibDwarf_INCLUDE_DIR
NAMES libdw.h
HINTS ${LibDwarf_ROOT_DIR}/include ${LibDwarf_ROOT_DIR} ${LibDwarf_INCLUDEDIR}
PATHS ${DYNINST_SYSTEM_INCLUDE_PATHS}
PATH_SUFFIXES ${_path_suffixes}
DOC "libdw include directories")
find_library(
LibDwarf_LIBRARIES
NAMES libdw.so.1 libdw.so
HINTS ${LibDwarf_ROOT_DIR}/lib ${LibDwarf_ROOT_DIR} ${LibDwarf_LIBRARYDIR}
PATHS ${DYNINST_SYSTEM_LIBRARY_PATHS}
PATH_SUFFIXES ${_path_suffixes})
# Find the library with the highest version
set(_max_ver 0.0)
set(_max_ver_lib)
foreach(l ${LibDwarf_LIBRARIES})
get_filename_component(_dw_realpath ${LibDwarf_LIBRARIES} REALPATH)
string(REGEX MATCH "libdw\\-(.+)\\.so\\.*$" res ${_dw_realpath})
# The library version number is stored in CMAKE_MATCH_1
set(_cur_ver ${CMAKE_MATCH_1})
if(${_cur_ver} VERSION_GREATER ${_max_ver})
set(_max_ver ${_cur_ver})
set(_max_ver_lib ${l})
endif()
endforeach()
# Set the exported variables to the best match
set(LibDwarf_LIBRARIES ${_max_ver_lib})
set(LibDwarf_VERSION ${_max_ver})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
LibDwarf
FOUND_VAR LibDwarf_FOUND
REQUIRED_VARS LibDwarf_LIBRARIES LibDwarf_INCLUDE_DIR
VERSION_VAR LibDwarf_VERSION)
# Export cache variables
if(LibDwarf_FOUND)
set(LibDwarf_INCLUDE_DIRS ${LibDwarf_INCLUDE_DIR})
set(LibDwarf_LIBRARIES ${LibDwarf_LIBRARIES})
# Because we only report the library with the largest version, we are guaranteed there
# is only one file in LibDwarf_LIBRARIES
get_filename_component(_dw_dir ${LibDwarf_LIBRARIES} DIRECTORY)
set(LibDwarf_LIBRARY_DIRS ${_dw_dir})
add_library(LibDwarf::LibDwarf INTERFACE IMPORTED)
target_include_directories(LibDwarf::LibDwarf INTERFACE ${LibDwarf_INCLUDE_DIR})
target_link_directories(LibDwarf::LibDwarf INTERFACE ${LibDwarf_LIBRARY_DIRS})
target_link_libraries(LibDwarf::LibDwarf INTERFACE ${LibDwarf_LIBRARIES})
endif()
@@ -0,0 +1,88 @@
# ========================================================================================
# FindLibElf.cmake
#
# Find libelf include dirs and libraries
#
# ----------------------------------------
#
# Use this module by invoking find_package with the form::
#
# find_package(LibElf [version] [EXACT] # Minimum or EXACT version e.g. 0.173
# [REQUIRED] # Fail with error if libelf is not found )
#
# This module reads hints about search locations from variables::
#
# LibElf_ROOT_DIR - Base directory the of libelf installation LibElf_INCLUDEDIR -
# Hint directory that contains the libelf headers files LibElf_LIBRARYDIR - Hint
# directory that contains the libelf library files
#
# and saves search results persistently in CMake cache entries::
#
# LibElf_FOUND - True if headers and requested libraries were found
# LibElf_INCLUDE_DIRS - libelf include directories LibElf_LIBRARY_DIRS - Link
# directories for libelf libraries LibElf_LIBRARIES - libelf library files
#
# Based on the version by Bernhard Walle <bernhard.walle@gmx.de> Copyright (c) 2008
#
# ========================================================================================
# Non-standard subdirectories to search
set(_path_suffixes libelf libelfls elfutils)
find_path(
LibElf_INCLUDE_DIR
NAMES libelf.h
HINTS ${LibElf_ROOT_DIR}/include ${LibElf_ROOT_DIR} ${LibElf_INCLUDEDIR}
PATHS ${DYNINST_SYSTEM_INCLUDE_PATHS}
PATH_SUFFIXES ${_path_suffixes}
DOC "libelf include directories")
find_library(
LibElf_LIBRARIES
NAMES libelf.so.1 libelf.so
HINTS ${LibElf_ROOT_DIR}/lib ${LibElf_ROOT_DIR} ${LibElf_LIBRARYDIR}
PATHS ${DYNINST_SYSTEM_LIBRARY_PATHS}
PATH_SUFFIXES ${_path_suffixes})
# Find the library with the highest version
set(_max_ver 0.0)
set(_max_ver_lib)
foreach(l ${LibElf_LIBRARIES})
get_filename_component(_elf_realpath ${LibElf_LIBRARIES} REALPATH)
string(REGEX MATCH "libelf\\-(.+)\\.so\\.*$" res ${_elf_realpath})
# The library version number is stored in CMAKE_MATCH_1
set(_cur_ver ${CMAKE_MATCH_1})
if(${_cur_ver} VERSION_GREATER ${_max_ver})
set(_max_ver ${_cur_ver})
set(_max_ver_lib ${l})
endif()
endforeach()
# Set the exported variables to the best match
set(LibElf_LIBRARIES ${_max_ver_lib})
set(LibElf_VERSION ${_max_ver})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
LibElf
FOUND_VAR LibElf_FOUND
REQUIRED_VARS LibElf_LIBRARIES LibElf_INCLUDE_DIR
VERSION_VAR LibElf_VERSION)
# Export cache variables
if(LibElf_FOUND)
set(LibElf_INCLUDE_DIRS ${LibElf_INCLUDE_DIR})
set(LibElf_LIBRARIES ${LibElf_LIBRARIES})
# Because we only report the library with the largest version, we are guaranteed there
# is only one file in LibElf_LIBRARIES
get_filename_component(_elf_dir ${LibElf_LIBRARIES} DIRECTORY)
set(LibElf_LIBRARY_DIRS ${_elf_dir} "${_elf_dir}/elfutils")
add_library(LibElf::LibElf INTERFACE IMPORTED)
target_include_directories(LibElf::LibElf INTERFACE ${LibElf_INCLUDE_DIR})
target_link_directories(LibElf::LibElf INTERFACE ${LibElf_LIBRARY_DIRS})
target_link_libraries(LibElf::LibElf INTERFACE ${LibElf_LIBRARIES})
endif()
@@ -0,0 +1,80 @@
# ========================================================================================
# FindLibIberty.cmake
#
# Find LibIberty include dirs and libraries
#
# ----------------------------------------
#
# Use this module by invoking find_package with the form::
#
# find_package(LibIberty [REQUIRED] # Fail with error if LibIberty is not
# found )
#
# This module reads hints about search locations from variables::
#
# LibIberty_ROOT_DIR - Base directory the of LibIberty installation
# LibIberty_LIBRARYDIR - Hint directory that contains the LibIberty library files
# IBERTY_LIBRARIES - Alias for LibIberty_LIBRARIES (backwards compatibility only)
# LibIberty_INCLUDEDIR - Hint directory that contains the libiberty headers files
#
# and saves search results persistently in CMake cache entries::
#
# LibIberty_FOUND - True if headers and requested libraries were found
# IBERTY_FOUND - Alias for LibIberty_FOUND (backwards compatibility only)
# LibIberty_INCLUDE_DIRS - libiberty include directories LibIberty_LIBRARY_DIRS - Link
# directories for LibIberty libraries LibIberty_LIBRARIES - LibIberty library files
# IBERTY_LIBRARIES - Alias for LibIberty_LIBRARIES (backwards compatibility only)
#
# ========================================================================================
cmake_minimum_required(VERSION 3.13.0 FATAL_ERROR)
# Keep the semantics of IBERTY_LIBRARIES for backward compatibility NB: If both are
# specified, LibIberty_LIBRARIES is ignored
if(NOT "${IBERTY_LIBRARIES}" STREQUAL "")
set(LibIberty_LIBRARIES ${IBERTY_LIBRARIES})
endif()
# Non-standard subdirectories to search
set(_path_suffixes libiberty iberty)
find_path(
LibIberty_INCLUDE_DIRS
NAMES libiberty.h
HINTS ${LibIberty_ROOT_DIR} ${LibIberty_ROOT_DIR}/include ${LibIberty_INCLUDEDIR}
PATHS ${DYNINST_SYSTEM_INCLUDE_PATHS}
PATH_SUFFIXES ${_path_suffixes}
DOC "LibIberty include directories")
# iberty_pic is for Debian <= wheezy
find_library(
LibIberty_LIBRARIES
NAMES iberty_pic iberty
HINTS ${LibIberty_ROOT_DIR} ${LibIberty_LIBRARYDIR} ${IBERTY_LIBRARIES}
PATHS ${DYNINST_SYSTEM_LIBRARY_PATHS}
PATH_SUFFIXES ${_path_suffixes})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
LibIberty
FOUND_VAR LibIberty_FOUND
REQUIRED_VARS LibIberty_INCLUDE_DIRS LibIberty_LIBRARIES)
# For backwards compatibility only
set(IBERTY_FOUND ${LibIberty_FOUND})
if(LibIberty_FOUND)
foreach(l ${LibIberty_LIBRARIES})
get_filename_component(_dir ${l} DIRECTORY)
if(NOT "${_dir}" IN_LIST LibIberty_LIBRARY_DIRS)
list(APPEND LibIberty_LIBRARY_DIRS ${_dir})
endif()
endforeach()
add_library(LibIberty::LibIberty INTERFACE IMPORTED)
target_include_directories(LibIberty::LibIberty INTERFACE ${LibIberty_INCLUDE_DIRS})
target_link_libraries(LibIberty::LibIberty INTERFACE ${LibIberty_LIBRARIES})
# For backwards compatibility only
set(IBERTY_LIBRARIES ${LibIberty_LIBRARIES})
endif()
+268
Ver ficheiro
@@ -0,0 +1,268 @@
# ======================================================================================================
# FindTBB.cmake
#
# Find TBB include directories and libraries.
#
# ----------------------------------------
#
# Use this module by invoking find_package with the form::
#
# find_package(TBB [major[.minor]] [EXACT] [QUIET] # Minimum or EXACT version e.g.
# 2018.6 [REQUIRED] # Fail with error if TBB is not found
# [[COMPONENTS] [components...]] # Required components [OPTIONAL_COMPONENTS
# components...] # Optional components )
#
# This module reads hints about search locations from variables::
#
# TBB_ROOT_DIR - The base directory the of TBB installation. TBB_INCLUDE_DIR -
# The directory that contains the TBB headers files. TBB_LIBRARY - The directory
# that contains the TBB library files. TBB_<library>_LIBRARY - The path of the TBB the
# corresponding TBB library. These libraries override the corresponding library search
# results. TBB_USE_DEBUG_BUILD - Use the debug version of tbb libraries
#
# Environment variable aliases for TBB_ROOT_DIR:
#
# TBB_INSTALL_DIR TBBROOT LIBRARY_PATH
#
# This module will set the following variables:
#
# TBB_FOUND - If false, or undefined, TBB not found, or don’t want to
# use TBB. TBB_<component>_FOUND - If False, optional <component> part of TBB
# sytem is not available. TBB_VERSION - The full version string TBB_VERSION_MAJOR - The
# major version TBB_VERSION_MINOR - The minor version TBB_INTERFACE_VERSION - The
# interface version number defined in tbb/tbb_stddef.h. TBB_<library>_LIBRARY_RELEASE -
# The path of the TBB release version of <library>. TBB_<library>_LIBRARY_DEBUG - The
# path of the TBB debug version of <library>.
#
# The following varibles should be used to build and link with TBB:
#
# TBB_INCLUDE_DIRS - The include directory for TBB. TBB_LIBRARY_DIRS - The library
# directory for TBB. TBB_LIBRARIES - The libraries to link against to use TBB.
# TBB_LIBRARIES_RELEASE - The release libraries to link against to use TBB.
# TBB_LIBRARIES_DEBUG - The debug libraries to link against to use TBB.
# TBB_DEFINITIONS - Definitions to use when compiling code that uses TBB.
# TBB_DEFINITIONS_RELEASE - Definitions to use when compiling release code that uses TBB.
# TBB_DEFINITIONS_DEBUG - Definitions to use when compiling debug code that uses TBB.
#
# This module will also create the "TBB" target that may be used when building executables
# and libraries.
#
# Based on the version by Justus Calvin - Copyright (c) 2015
#
# ======================================================================================================
if(TBB_FOUND)
return()
endif()
include(FindPackageHandleStandardArgs)
#
# Check the build type
#
if(NOT DEFINED TBB_USE_DEBUG_BUILD)
if(CMAKE_BUILD_TYPE MATCHES "(Debug|DEBUG|debug)")
set(TBB_BUILD_TYPE DEBUG)
else()
set(TBB_BUILD_TYPE RELEASE)
endif()
elseif(TBB_USE_DEBUG_BUILD)
set(TBB_BUILD_TYPE DEBUG)
else()
set(TBB_BUILD_TYPE RELEASE)
endif()
#
# Set the TBB search directories
#
# Define search paths based on user input and environment variables
set(TBB_SEARCH_DIR ${TBB_ROOT_DIR} $ENV{TBB_INSTALL_DIR} $ENV{TBBROOT})
# Define the search directories based on the current platform
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(TBB_DEFAULT_SEARCH_DIR "C:/Program Files/Intel/TBB"
"C:/Program Files (x86)/Intel/TBB")
# Set the target architecture
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(TBB_ARCHITECTURE "intel64")
else()
set(TBB_ARCHITECTURE "ia32")
endif()
# Set the TBB search library path search suffix based on the version of VC
if(WINDOWS_STORE)
set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc11_ui")
elseif(MSVC14)
set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc14")
elseif(MSVC12)
set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc12")
elseif(MSVC11)
set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc11")
elseif(MSVC10)
set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc10")
endif()
# Add the library path search suffix for the VC independent version of TBB
list(APPEND TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc_mt")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# OS X
set(TBB_DEFAULT_SEARCH_DIR "/opt/intel/tbb")
# TODO: Check to see which C++ library is being used by the compiler.
if(NOT ${CMAKE_SYSTEM_VERSION} VERSION_LESS 13.0)
# The default C++ library on OS X 10.9 and later is libc++
set(TBB_LIB_PATH_SUFFIX "lib/libc++" "lib")
else()
set(TBB_LIB_PATH_SUFFIX "lib")
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# Linux
set(TBB_DEFAULT_SEARCH_DIR "/opt/intel/tbb")
# TODO: Check compiler version to see the suffix should be <arch>/gcc4.1 or
# <arch>/gcc4.1. For now, assume that the compiler is more recent than gcc 4.4.x or
# later.
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(TBB_LIB_PATH_SUFFIX "lib/intel64/gcc4.4")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
set(TBB_LIB_PATH_SUFFIX "lib/ia32/gcc4.4")
endif()
endif()
#
# Find the TBB include dir
#
find_path(
TBB_INCLUDE_DIRS tbb/tbb.h
HINTS ${TBB_INCLUDE_DIRS} ${TBB_SEARCH_DIR}
PATHS ${TBB_DEFAULT_SEARCH_DIR}
PATH_SUFFIXES include)
#
# Set version strings
#
if(TBB_INCLUDE_DIRS)
# Starting in 2020.1.1, tbb_stddef.h is replaced by version.h
set(_version_files "${TBB_INCLUDE_DIRS}/tbb/tbb_stddef.h"
"${TBB_INCLUDE_DIRS}/tbb/version.h")
foreach(f IN ITEMS ${_version_files})
if(EXISTS ${f})
set(_version_file ${f})
endif()
endforeach()
unset(_version_files)
file(READ ${_version_file} _tbb_version_file)
string(REGEX REPLACE ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1" TBB_VERSION_MAJOR
"${_tbb_version_file}")
string(REGEX REPLACE ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1" TBB_VERSION_MINOR
"${_tbb_version_file}")
string(REGEX REPLACE ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1"
TBB_INTERFACE_VERSION "${_tbb_version_file}")
# The TBB_VERSION_MINOR isn't necessarily changed for minor releases Hence, we need to
# read the engineering versioning in TBB_INTERFACE_VERSION to get the minor version
# correct
if("${TBB_VERSION_MINOR}" STREQUAL "0")
math(EXPR _tbb_iface_major_ver "${TBB_INTERFACE_VERSION} / 100")
math(EXPR TBB_VERSION_MINOR
"${TBB_INTERFACE_VERSION} - ${_tbb_iface_major_ver} * 100")
endif()
set(TBB_VERSION "${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR}")
endif()
#
# Find TBB components
#
if(TBB_VERSION VERSION_LESS 4.3)
set(TBB_SEARCH_COMPOMPONENTS tbb_preview tbbmalloc tbb)
else()
set(TBB_SEARCH_COMPOMPONENTS tbb_preview tbbmalloc_proxy tbbmalloc tbb)
endif()
set(TBB_LIBRARY_DIRS)
# Find each component
foreach(_comp ${TBB_SEARCH_COMPOMPONENTS})
# message(STATUS "Searching for ${_comp}...") message(STATUS "Hints: ${TBB_LIBRARY}
# ${TBB_SEARCH_DIR}")
if(";${TBB_FIND_COMPONENTS};tbb;" MATCHES ";${_comp};")
# Search for the libraries
find_library(
TBB_${_comp}_LIBRARY_RELEASE ${_comp}
HINTS ${TBB_LIBRARY} ${TBB_SEARCH_DIR}
PATHS ${TBB_DEFAULT_SEARCH_DIR} ENV LIBRARY_PATH
PATH_SUFFIXES ${TBB_LIB_PATH_SUFFIX} lib_release)
find_library(
TBB_${_comp}_LIBRARY_DEBUG ${_comp}_debug
HINTS ${TBB_LIBRARY} ${TBB_SEARCH_DIR}
PATHS ${TBB_DEFAULT_SEARCH_DIR} ENV LIBRARY_PATH
PATH_SUFFIXES ${TBB_LIB_PATH_SUFFIX} lib_debug)
if(TBB_${_comp}_LIBRARY_DEBUG)
list(APPEND TBB_LIBRARIES_DEBUG "${TBB_${_comp}_LIBRARY_DEBUG}")
# message(STATUS "Found ${TBB_${_comp}_LIBRARY_DEBUG}")
endif()
if(TBB_${_comp}_LIBRARY_RELEASE)
list(APPEND TBB_LIBRARIES_RELEASE "${TBB_${_comp}_LIBRARY_RELEASE}")
# message(STATUS "Found ${TBB_${_comp}_LIBRARY_RELEASE}")
endif()
if(TBB_${_comp}_LIBRARY_${TBB_BUILD_TYPE} AND NOT TBB_${_comp}_LIBRARY)
set(TBB_${_comp}_LIBRARY "${TBB_${_comp}_LIBRARY_${TBB_BUILD_TYPE}}")
endif()
if(TBB_${_comp}_LIBRARY AND EXISTS "${TBB_${_comp}_LIBRARY}")
set(TBB_${_comp}_FOUND TRUE)
else()
set(TBB_${_comp}_FOUND FALSE)
endif()
# Mark internal variables as advanced
mark_as_advanced(TBB_${_comp}_LIBRARY_RELEASE)
mark_as_advanced(TBB_${_comp}_LIBRARY_DEBUG)
mark_as_advanced(TBB_${_comp}_LIBRARY)
# Save the directory names for each library component
if(TBB_USE_DEBUG_BUILD)
get_filename_component(_dir ${TBB_${_comp}_LIBRARY_DEBUG} DIRECTORY)
else()
get_filename_component(_dir ${TBB_${_comp}_LIBRARY_RELEASE} DIRECTORY)
endif()
list(APPEND TBB_LIBRARY_DIRS ${_dir})
endif()
endforeach()
#
# Set compile flags and libraries
#
set(TBB_DEFINITIONS_RELEASE "")
set(TBB_DEFINITIONS_DEBUG "-DTBB_USE_DEBUG=1")
if(TBB_LIBRARIES_${TBB_BUILD_TYPE})
set(TBB_DEFINITIONS "${TBB_DEFINITIONS_${TBB_BUILD_TYPE}}")
set(TBB_LIBRARIES "${TBB_LIBRARIES_${TBB_BUILD_TYPE}}")
elseif(TBB_LIBRARIES_RELEASE)
set(TBB_DEFINITIONS "${TBB_DEFINITIONS_RELEASE}")
set(TBB_LIBRARIES "${TBB_LIBRARIES_RELEASE}")
elseif(TBB_LIBRARIES_DEBUG)
set(TBB_DEFINITIONS "${TBB_DEFINITIONS_DEBUG}")
set(TBB_LIBRARIES "${TBB_LIBRARIES_DEBUG}")
endif()
find_package_handle_standard_args(
TBB
REQUIRED_VARS TBB_INCLUDE_DIRS TBB_LIBRARIES
HANDLE_COMPONENTS
VERSION_VAR TBB_VERSION)
mark_as_advanced(TBB_INCLUDE_DIRS TBB_LIBRARIES TBB_LIBRARY_DIRS)
unset(TBB_ARCHITECTURE)
unset(TBB_BUILD_TYPE)
unset(TBB_LIB_PATH_SUFFIX)
unset(TBB_DEFAULT_SEARCH_DIR)