Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

1210 rivejä
38 KiB
CMake

2026-01-07 20:07:37 +01:00
# Copyright (c) Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
2021-08-06 13:08:57 -05:00
# include guard
include_guard(DIRECTORY)
2021-09-20 11:12:06 -05:00
# ########################################################################################
2021-08-06 13:08:57 -05:00
#
2021-09-20 11:12:06 -05:00
# External Packages are found here
2021-08-06 13:08:57 -05:00
#
2021-09-20 11:12:06 -05:00
# ########################################################################################
2021-08-06 13:08:57 -05:00
rocprofiler_systems_add_interface_library(
rocprofiler-systems-headers
2025-06-22 10:44:33 -04:00
"Provides minimal set of include flags to compile with rocprofiler-systems"
)
rocprofiler_systems_add_interface_library(rocprofiler-systems-threading
"Enables multithreading support"
2025-06-22 10:44:33 -04:00
)
rocprofiler_systems_add_interface_library(
rocprofiler-systems-dyninst
2025-06-22 10:44:33 -04:00
"Provides flags and libraries for Dyninst (dynamic instrumentation)"
)
rocprofiler_systems_add_interface_library(rocprofiler-systems-boost
"Boost interface library (for Dyninst)"
2025-06-22 10:44:33 -04:00
)
rocprofiler_systems_add_interface_library(rocprofiler-systems-elfutils
"ElfUtils interface library (for Dyninst)"
2025-06-22 10:44:33 -04:00
)
rocprofiler_systems_add_interface_library(rocprofiler-systems-libiberty
"LibIberty interface library (for Dyninst)"
2025-06-22 10:44:33 -04:00
)
rocprofiler_systems_add_interface_library(
2025-06-22 10:44:33 -04:00
rocprofiler-systems-tbb "Threading Building Blocks interface library (for Dyninst)"
)
2024-12-13 18:48:39 -05:00
rocprofiler_systems_add_interface_library(rocprofiler-systems-rocm
"Provides flags and libraries for ROCm"
2025-06-22 10:44:33 -04:00
)
rocprofiler_systems_add_interface_library(rocprofiler-systems-mpi
"Provides MPI or MPI headers"
2025-06-22 10:44:33 -04:00
)
rocprofiler_systems_add_interface_library(rocprofiler-systems-libva
"Provides VA-API headers"
2025-06-22 10:44:33 -04:00
)
rocprofiler_systems_add_interface_library(rocprofiler-systems-ucx
"Provides UCX headers"
)
rocprofiler_systems_add_interface_library(rocprofiler-systems-bfd
"Provides Binary File Descriptor (BFD)"
2025-06-22 10:44:33 -04:00
)
rocprofiler_systems_add_interface_library(rocprofiler-systems-ptl
"Enables PTL support (tasking)"
2025-06-22 10:44:33 -04:00
)
rocprofiler_systems_add_interface_library(rocprofiler-systems-papi "Enable PAPI support")
rocprofiler_systems_add_interface_library(rocprofiler-systems-ompt "Enable OMPT support")
rocprofiler_systems_add_interface_library(rocprofiler-systems-python
"Enables Python support"
2025-06-22 10:44:33 -04:00
)
rocprofiler_systems_add_interface_library(rocprofiler-systems-perfetto
"Enables Perfetto support"
2025-06-22 10:44:33 -04:00
)
2025-07-28 17:33:52 +02:00
rocprofiler_systems_add_interface_library(rocprofiler-systems-sqlite3
"Use SQLite3 for rocpd data storage"
2025-07-28 17:33:52 +02:00
)
rocprofiler_systems_add_interface_library(rocprofiler-systems-json
"Use nlohmann/json for json data handling"
)
rocprofiler_systems_add_interface_library(rocprofiler-systems-spdlog
"Provides spdlog library"
)
rocprofiler_systems_add_interface_library(rocprofiler-systems-timemory
"Provides timemory libraries"
2025-06-22 10:44:33 -04:00
)
rocprofiler_systems_add_interface_library(
rocprofiler-systems-timemory-config
2025-06-22 10:44:33 -04:00
"CMake interface library applied to all timemory targets"
)
rocprofiler_systems_add_interface_library(rocprofiler-systems-compile-definitions
"Compile definitions"
2025-06-22 10:44:33 -04:00
)
# libraries with relevant compile definitions
set(ROCPROFSYS_EXTENSION_LIBRARIES
2024-12-13 18:48:39 -05:00
rocprofiler-systems::rocprofiler-systems-rocm
rocprofiler-systems::rocprofiler-systems-bfd
rocprofiler-systems::rocprofiler-systems-mpi
rocprofiler-systems::rocprofiler-systems-ptl
rocprofiler-systems::rocprofiler-systems-ompt
rocprofiler-systems::rocprofiler-systems-papi
2025-06-22 10:44:33 -04:00
rocprofiler-systems::rocprofiler-systems-perfetto
)
2022-04-26 22:08:51 -05:00
target_include_directories(
rocprofiler-systems-headers
2025-06-22 10:44:33 -04:00
INTERFACE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/source/lib>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/source/lib/core>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/source/lib>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/source/lib/rocprof-sys>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/source/lib/rocprof-sys-dl>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/source/lib/rocprof-sys-user>
)
2021-08-06 13:08:57 -05:00
# include threading because of rooflines
2025-06-22 10:44:33 -04:00
target_link_libraries(
rocprofiler-systems-headers
INTERFACE rocprofiler-systems::rocprofiler-systems-threading
)
2021-08-06 13:08:57 -05:00
# ensure the env overrides the appending /opt/rocm later
string(REPLACE ":" ";" CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH};${CMAKE_PREFIX_PATH}")
2025-06-22 10:44:33 -04:00
set(ROCPROFSYS_DEFAULT_ROCM_PATH /opt/rocm CACHE PATH "Default search path for ROCM")
if(EXISTS ${ROCPROFSYS_DEFAULT_ROCM_PATH})
2025-06-22 10:44:33 -04:00
get_filename_component(
_ROCPROFSYS_DEFAULT_ROCM_PATH
"${ROCPROFSYS_DEFAULT_ROCM_PATH}"
REALPATH
)
2022-07-21 01:15:41 -05:00
if(NOT "${_ROCPROFSYS_DEFAULT_ROCM_PATH}" STREQUAL "${ROCPROFSYS_DEFAULT_ROCM_PATH}")
set(ROCPROFSYS_DEFAULT_ROCM_PATH
"${_ROCPROFSYS_DEFAULT_ROCM_PATH}"
2025-06-22 10:44:33 -04:00
CACHE PATH
"Default search path for ROCM"
FORCE
)
2022-07-21 01:15:41 -05:00
endif()
2022-07-17 21:52:09 -05:00
endif()
2021-09-20 11:12:06 -05:00
# ----------------------------------------------------------------------------------------#
2021-08-06 13:08:57 -05:00
#
2021-09-20 11:12:06 -05:00
# Threading
2021-08-06 13:08:57 -05:00
#
2021-09-20 11:12:06 -05:00
# ----------------------------------------------------------------------------------------#
2021-08-06 13:08:57 -05:00
2022-05-11 15:05:09 -05:00
set(CMAKE_THREAD_PREFER_PTHREAD ON)
set(THREADS_PREFER_PTHREAD_FLAG OFF)
2021-08-06 13:08:57 -05:00
find_library(pthread_LIBRARY NAMES pthread pthreads)
find_package_handle_standard_args(pthread-library REQUIRED_VARS pthread_LIBRARY)
2022-05-11 15:05:09 -05:00
if(pthread_LIBRARY)
target_link_libraries(rocprofiler-systems-threading INTERFACE ${pthread_LIBRARY})
2022-05-11 15:05:09 -05:00
else()
2025-06-22 10:44:33 -04:00
find_package(
Threads
${rocprofiler_systems_FIND_QUIETLY}
${rocprofiler_systems_FIND_REQUIREMENT}
)
2022-05-11 15:05:09 -05:00
if(Threads_FOUND)
target_link_libraries(rocprofiler-systems-threading INTERFACE Threads::Threads)
2022-05-11 15:05:09 -05:00
endif()
2021-08-06 13:08:57 -05:00
endif()
2022-05-11 15:05:09 -05:00
foreach(_LIB dl rt)
find_library(${_LIB}_LIBRARY NAMES ${_LIB})
find_package_handle_standard_args(${_LIB}-library REQUIRED_VARS ${_LIB}_LIBRARY)
if(${_LIB}_LIBRARY)
target_link_libraries(rocprofiler-systems-threading INTERFACE ${${_LIB}_LIBRARY})
2022-05-11 15:05:09 -05:00
endif()
endforeach()
2022-07-21 01:15:41 -05:00
# ----------------------------------------------------------------------------------------#
#
2024-12-13 18:48:39 -05:00
# ROCm Version
2022-07-21 01:15:41 -05:00
#
# ----------------------------------------------------------------------------------------#
2024-12-13 18:48:39 -05:00
if(ROCPROFSYS_USE_ROCM)
2022-07-21 01:15:41 -05:00
find_package(ROCmVersion)
if(NOT ROCmVersion_FOUND)
find_package(
2025-06-22 10:44:33 -04:00
hip
${rocprofiler_systems_FIND_QUIETLY}
REQUIRED
HINTS ${ROCPROFSYS_DEFAULT_ROCM_PATH}
PATHS ${ROCPROFSYS_DEFAULT_ROCM_PATH}
)
2025-11-10 14:38:51 -05:00
find_package(ROCmVersion HINTS ${ROCM_PATH} PATHS ${ROCM_PATH})
2022-07-21 01:15:41 -05:00
endif()
if(NOT ROCmVersion_FOUND)
rocm_version_compute("${hip_VERSION}" _local)
foreach(_V ${ROCmVersion_VARIABLES})
set(_CACHE_VAR ROCmVersion_${_V}_VERSION)
set(_LOCAL_VAR _local_${_V}_VERSION)
set(ROCmVersion_${_V}_VERSION
"${${_LOCAL_VAR}}"
2025-06-22 10:44:33 -04:00
CACHE STRING
"ROCm ${_V} version"
)
rocm_version_watch_for_change(${_CACHE_VAR})
endforeach()
else()
list(APPEND CMAKE_PREFIX_PATH ${ROCmVersion_DIR})
endif()
2022-07-21 01:15:41 -05:00
2025-11-10 14:38:51 -05:00
set(ROCPROFSYS_ROCM_VERSION_FULL ${ROCmVersion_FULL_VERSION})
2024-12-13 18:48:39 -05:00
set(ROCPROFSYS_ROCM_VERSION_MAJOR ${ROCmVersion_MAJOR_VERSION})
set(ROCPROFSYS_ROCM_VERSION_MINOR ${ROCmVersion_MINOR_VERSION})
set(ROCPROFSYS_ROCM_VERSION_PATCH ${ROCmVersion_PATCH_VERSION})
set(ROCPROFSYS_ROCM_VERSION ${ROCmVersion_TRIPLE_VERSION})
2022-07-21 01:15:41 -05:00
rocprofiler_systems_add_feature(ROCPROFSYS_ROCM_VERSION
"ROCm version used by rocprofiler-systems"
2025-06-22 10:44:33 -04:00
)
2022-07-21 01:15:41 -05:00
else()
2024-12-13 18:48:39 -05:00
set(ROCPROFSYS_ROCM_VERSION "0.0.0")
set(ROCPROFSYS_ROCM_VERSION_MAJOR 0)
set(ROCPROFSYS_ROCM_VERSION_MINOR 0)
set(ROCPROFSYS_ROCM_VERSION_PATCH 0)
2022-07-21 01:15:41 -05:00
endif()
# ----------------------------------------------------------------------------------------#
#
2024-12-13 18:48:39 -05:00
# ROCm
#
# ----------------------------------------------------------------------------------------#
2024-12-13 18:48:39 -05:00
if(ROCPROFSYS_USE_ROCM)
2025-11-10 14:38:51 -05:00
# ROCProfiler SDK
2024-12-13 18:48:39 -05:00
find_package(rocprofiler-sdk ${rocprofiler_systems_FIND_QUIETLY} REQUIRED)
rocprofiler_systems_target_compile_definitions(rocprofiler-systems-rocm
INTERFACE ROCPROFSYS_USE_ROCM
2025-06-22 10:44:33 -04:00
)
target_link_libraries(
rocprofiler-systems-rocm
INTERFACE rocprofiler-sdk::rocprofiler-sdk
)
2022-02-08 17:42:17 -06:00
2025-11-10 14:38:51 -05:00
# AMD SMI
find_package(
amd_smi
${rocprofiler_systems_FIND_QUIETLY}
HINTS ${ROCMVersion_DIR} ${ROCM_PATH} /opt/amdgpu
PATHS ${ROCMVersion_DIR} ${ROCM_PATH} /opt/amdgpu
REQUIRED
)
# amd_smi in ROCm 6.4 requires both drm and drm_amdgpu libraries to be explicitly linked.
# This is no longer the case in ROCm 7.0.
if(ROCPROFSYS_ROCM_VERSION_MAJOR EQUAL 6 AND ROCPROFSYS_ROCM_VERSION_MINOR EQUAL 4)
# Find drm library
find_library(
drm_LIBRARY
NAMES drm
HINTS ${ROCMVersion_DIR} ${ROCM_PATH} /opt/amdgpu
PATHS ${ROCMVersion_DIR} ${ROCM_PATH} /opt/amdgpu
PATH_SUFFIXES lib lib64
REQUIRED
)
# Find drm_amdgpu library
find_library(
drm_amdgpu_LIBRARY
NAMES drm_amdgpu
HINTS ${ROCMVersion_DIR} ${ROCM_PATH} /opt/amdgpu
PATHS ${ROCMVersion_DIR} ${ROCM_PATH} /opt/amdgpu
PATH_SUFFIXES lib lib64
REQUIRED
)
get_filename_component(_drm_LIBRARY_DIR "${drm_LIBRARY}" DIRECTORY)
get_filename_component(_drm_amdgpu_LIBRARY_DIR "${drm_amdgpu_LIBRARY}" DIRECTORY)
set(_drm_LIBRARY_DIRS "${_drm_LIBRARY_DIR};${_drm_amdgpu_LIBRARY_DIR}")
list(REMOVE_DUPLICATES _drm_LIBRARY_DIRS)
target_link_directories(amd_smi INTERFACE ${_drm_LIBRARY_DIRS})
endif()
target_link_libraries(rocprofiler-systems-rocm INTERFACE amd_smi)
2022-02-08 17:42:17 -06:00
endif()
# ----------------------------------------------------------------------------------------#
#
# ROCpd
#
# ----------------------------------------------------------------------------------------#
function(ROCPROFSYS_CONFIGURE_ROCPD_SCHEMA_FILES)
rocprofiler_systems_target_compile_definitions(
rocprofiler-systems-rocm INTERFACE ROCPROFSYS_USE_ROCPD_LIBRARY=0
)
set(SCHEMA_FILES
"rocpd_tables.sql"
"rocpd_views.sql"
"data_views.sql"
"marker_views.sql"
"summary_views.sql"
)
set(SCHEMA_SOURCE_DIR
"${PROJECT_SOURCE_DIR}/source/lib/core/rocpd/data_storage/schema"
)
set(SCHEMA_BINARY_DIR
"${PROJECT_BINARY_DIR}/source/lib/core/rocpd/data_storage/schema"
)
set(TEMPLATE_FILE "${PROJECT_SOURCE_DIR}/cmake/Templates/rocpd_schema.in")
file(MAKE_DIRECTORY ${SCHEMA_BINARY_DIR})
foreach(SCHEMA_FILE ${SCHEMA_FILES})
file(READ "${SCHEMA_SOURCE_DIR}/${SCHEMA_FILE}" SQL_CONTENT)
string(REPLACE "\\" "\\\\" SQL_CONTENT "${SQL_CONTENT}")
string(REPLACE "\"" "\\\"" SQL_CONTENT "${SQL_CONTENT}")
string(REPLACE "\n" "\\n\"\n\"" SQL_CONTENT "${SQL_CONTENT}")
get_filename_component(SCHEMA_NAME ${SCHEMA_FILE} NAME_WE)
string(TOUPPER ${SCHEMA_NAME} SCHEMA_NAME_UPPER)
configure_file("${TEMPLATE_FILE}" "${SCHEMA_BINARY_DIR}/${SCHEMA_NAME}.hpp" @ONLY)
endforeach()
target_include_directories(
rocprofiler-systems-headers
INTERFACE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/source/lib/core/rocpd/data_storage>
)
endfunction()
set(ROCPROFSYS_USE_ROCPD_LIBRARY OFF CACHE BOOL "Use rocpd library" FORCE)
find_package(rocprofiler-sdk-rocpd ${rocprofiler_systems_FIND_QUIETLY})
if(rocprofiler-sdk-rocpd_FOUND)
set(ROCPROFSYS_ROCPD_HAS_SQL_H FALSE)
if(rocprofiler-sdk-rocpd_INCLUDE_DIR)
set(_INCLUDE_PATH "${rocprofiler-sdk-rocpd_INCLUDE_DIR}/rocprofiler-sdk-rocpd")
message(STATUS "${_INCLUDE_PATH}/sql.h")
if(EXISTS "${_INCLUDE_PATH}/sql.h")
set(ROCPROFSYS_ROCPD_HAS_SQL_H TRUE)
endif()
endif()
if(ROCPROFSYS_ROCPD_HAS_SQL_H)
set(ROCPROFSYS_USE_ROCPD_LIBRARY ON CACHE BOOL "Use rocpd library" FORCE)
rocprofiler_systems_target_compile_definitions(
rocprofiler-systems-rocm INTERFACE ROCPROFSYS_USE_ROCPD_LIBRARY=1
)
target_link_libraries(
rocprofiler-systems-rocm
INTERFACE rocprofiler-sdk-rocpd::rocprofiler-sdk-rocpd
)
message(
STATUS
"rocprofiler-sdk-rocpd found with sql.h - using latest schema files"
)
else()
message(
STATUS
"rocprofiler-sdk-rocpd found but sql.h missing - using local schema files"
)
endif()
else()
message(STATUS "rocprofiler-sdk-rocpd not found - using local schema files")
endif()
if(NOT ROCPROFSYS_USE_ROCPD_LIBRARY)
rocprofsys_configure_rocpd_schema_files()
endif()
# ----------------------------------------------------------------------------------------#
#
# MPI
#
# ----------------------------------------------------------------------------------------#
2022-11-13 10:42:14 -06:00
# suppress warning during CI that MPI_HEADERS_ALLOW_MPICH was unused
set(_ROCPROFSYS_MPI_HEADERS_ALLOW_MPICH ${MPI_HEADERS_ALLOW_MPICH})
if(ROCPROFSYS_USE_MPI)
find_package(MPI ${rocprofiler_systems_FIND_QUIETLY} REQUIRED)
target_link_libraries(rocprofiler-systems-mpi INTERFACE MPI::MPI_C MPI::MPI_CXX)
2025-06-04 18:06:18 -04:00
rocprofiler_systems_target_compile_definitions(rocprofiler-systems-mpi
INTERFACE ROCPROFSYS_USE_MPI
2025-06-22 10:44:33 -04:00
)
elseif(ROCPROFSYS_USE_MPI_HEADERS)
find_package(MPI-Headers ${rocprofiler_systems_FIND_QUIETLY} REQUIRED)
2025-06-04 18:06:18 -04:00
rocprofiler_systems_target_compile_definitions(rocprofiler-systems-mpi
INTERFACE ROCPROFSYS_USE_MPI_HEADERS
2025-06-22 10:44:33 -04:00
)
target_link_libraries(rocprofiler-systems-mpi INTERFACE MPI::MPI_HEADERS)
endif()
# ----------------------------------------------------------------------------------------#
#
# OMPT
#
# ----------------------------------------------------------------------------------------#
rocprofiler_systems_target_compile_definitions(
2025-06-22 10:44:33 -04:00
rocprofiler-systems-ompt INTERFACE ROCPROFSYS_USE_OMPT=$<BOOL:${ROCPROFSYS_USE_OMPT}>
)
2021-09-20 11:12:06 -05:00
# ----------------------------------------------------------------------------------------#
2021-08-06 13:08:57 -05:00
#
2021-09-20 11:12:06 -05:00
# Dyninst
2021-08-06 13:08:57 -05:00
#
2021-09-20 11:12:06 -05:00
# ----------------------------------------------------------------------------------------#
2025-06-06 22:52:23 -04:00
include(DyninstExternals)
if(ROCPROFSYS_BUILD_DYNINST)
rocprofiler_systems_checkout_git_submodule(
2021-09-20 11:12:06 -05:00
RELATIVE_PATH external/dyninst
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
2025-06-06 22:52:23 -04:00
REPO_URL https://github.com/ROCm/dyninst.git
2025-06-22 10:44:33 -04:00
REPO_BRANCH dyninst_13
)
2021-09-20 11:12:06 -05:00
set(DYNINST_OPTION_PREFIX ON)
set(DYNINST_BUILD_DOCS OFF)
2024-06-27 16:51:43 -05:00
set(DYNINST_BUILD_RTLIB OFF)
2025-06-22 10:44:33 -04:00
set(DYNINST_QUIET_CONFIG ON CACHE BOOL "Suppress dyninst cmake messages")
set(DYNINST_BUILD_PARSE_THAT OFF CACHE BOOL "Build dyninst parseThat executable")
set(DYNINST_BUILD_SHARED_LIBS ON CACHE BOOL "Build shared dyninst libraries")
set(DYNINST_BUILD_STATIC_LIBS OFF CACHE BOOL "Build static dyninst libraries")
set(DYNINST_ENABLE_LTO OFF CACHE BOOL "Enable LTO for dyninst libraries")
2021-09-20 11:12:06 -05:00
2022-08-31 01:24:31 -05:00
if(NOT DEFINED CMAKE_INSTALL_RPATH)
set(CMAKE_INSTALL_RPATH "")
endif()
if(NOT DEFINED CMAKE_BUILD_RPATH)
set(CMAKE_BUILD_RPATH "")
endif()
rocprofiler_systems_save_variables(
2022-08-31 01:24:31 -05:00
PIC VARIABLES CMAKE_POSITION_INDEPENDENT_CODE CMAKE_INSTALL_RPATH
CMAKE_BUILD_RPATH CMAKE_INSTALL_RPATH_USE_LINK_PATH
2025-06-22 10:44:33 -04:00
)
2021-09-15 16:45:49 -05:00
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2022-08-31 01:24:31 -05:00
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH OFF)
set(CMAKE_BUILD_RPATH "\$ORIGIN:\$ORIGIN/${PROJECT_NAME}")
set(CMAKE_INSTALL_RPATH "\$ORIGIN:\$ORIGIN/${PROJECT_NAME}")
2022-06-28 16:32:07 -05:00
set(DYNINST_TPL_INSTALL_PREFIX
"${PROJECT_NAME}"
2025-06-22 10:44:33 -04:00
CACHE PATH
"Third-party library install-tree install prefix"
FORCE
)
2022-06-28 16:32:07 -05:00
set(DYNINST_TPL_INSTALL_LIB_DIR
"${PROJECT_NAME}"
2025-06-22 10:44:33 -04:00
CACHE PATH
"Third-party library install-tree install library prefix"
FORCE
)
2025-06-06 22:52:23 -04:00
2022-06-28 16:32:07 -05:00
add_subdirectory(external/dyninst EXCLUDE_FROM_ALL)
rocprofiler_systems_restore_variables(
2022-08-31 01:24:31 -05:00
PIC VARIABLES CMAKE_POSITION_INDEPENDENT_CODE CMAKE_INSTALL_RPATH
CMAKE_BUILD_RPATH CMAKE_INSTALL_RPATH_USE_LINK_PATH
2025-06-22 10:44:33 -04:00
)
2021-09-09 15:51:07 -05:00
2021-09-15 16:45:49 -05:00
add_library(Dyninst::Dyninst INTERFACE IMPORTED)
2025-06-22 10:44:33 -04:00
foreach(
_LIB
common
dyninstAPI
parseAPI
instructionAPI
symtabAPI
stackwalk
)
2021-09-15 16:45:49 -05:00
target_link_libraries(Dyninst::Dyninst INTERFACE Dyninst::${_LIB})
2021-09-09 15:51:07 -05:00
endforeach()
2021-08-06 13:08:57 -05:00
2022-06-28 16:32:07 -05:00
foreach(
_LIB
common
dynDwarf
dynElf
dyninstAPI
instructionAPI
parseAPI
patchAPI
pcontrol
stackwalk
2025-06-22 10:44:33 -04:00
symtabAPI
)
2022-06-28 16:32:07 -05:00
if(TARGET ${_LIB})
install(
TARGETS ${_LIB}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
2022-07-23 03:02:31 -05:00
COMPONENT dyninst
PUBLIC_HEADER
2025-06-22 10:44:33 -04:00
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/dyninst
)
2022-06-28 16:32:07 -05:00
endif()
endforeach()
2025-06-06 22:52:23 -04:00
foreach(
_LIB
common
dynDwarf
dynElf
dyninstAPI
instructionAPI
parseAPI
patchAPI
pcontrol
stackwalk
2025-06-22 10:44:33 -04:00
symtabAPI
)
2025-06-06 22:52:23 -04:00
if(TARGET ${_LIB})
add_dependencies(${_LIB} external-prebuild)
if(NOT TARGET Dyninst::${_LIB})
add_library(Dyninst::${_LIB} ALIAS ${_LIB})
endif()
endif()
endforeach()
2022-06-28 16:32:07 -05:00
target_link_libraries(rocprofiler-systems-dyninst INTERFACE Dyninst::Dyninst)
2021-09-15 16:45:49 -05:00
else()
2025-06-06 22:52:23 -04:00
# Find Boost before finding Dyninst
find_package(Boost)
if(NOT TARGET Dyninst::Boost_headers)
add_library(Dyninst::Boost_headers INTERFACE IMPORTED)
2025-06-22 10:44:33 -04:00
target_include_directories(
Dyninst::Boost_headers
SYSTEM
INTERFACE ${Boost_INCLUDE_DIRS}
)
2025-06-06 22:52:23 -04:00
endif()
2025-06-22 10:44:33 -04:00
find_package(
Dyninst
${rocprofiler_systems_FIND_QUIETLY}
REQUIRED
COMPONENTS dyninstAPI parseAPI instructionAPI symtabAPI
)
2021-09-15 16:45:49 -05:00
2021-09-20 11:12:06 -05:00
if(TARGET Dyninst::Dyninst) # updated Dyninst CMake system was found
target_link_libraries(rocprofiler-systems-dyninst INTERFACE Dyninst::Dyninst)
2021-09-20 11:12:06 -05:00
else() # updated Dyninst CMake system was not found
2021-09-15 16:45:49 -05:00
set(_BOOST_COMPONENTS atomic system thread date_time)
set(rocprofiler_systems_BOOST_COMPONENTS
2021-09-20 11:12:06 -05:00
"${_BOOST_COMPONENTS}"
2025-06-22 10:44:33 -04:00
CACHE STRING
"Boost components used by Dyninst in rocprofiler-systems"
)
2021-09-15 16:45:49 -05:00
set(Boost_NO_BOOST_CMAKE ON)
2025-06-22 10:44:33 -04:00
find_package(
Boost
QUIET
REQUIRED
COMPONENTS ${rocprofiler_systems_BOOST_COMPONENTS}
)
2021-09-15 16:45:49 -05:00
# some installs of dyninst don't set this properly
if(EXISTS "${DYNINST_INCLUDE_DIR}" AND NOT DYNINST_HEADER_DIR)
2025-06-22 10:44:33 -04:00
get_filename_component(
DYNINST_HEADER_DIR
"${DYNINST_INCLUDE_DIR}"
REALPATH
CACHE
)
2021-09-15 16:45:49 -05:00
else()
2021-09-20 11:12:06 -05:00
find_path(
DYNINST_HEADER_DIR
2021-09-15 16:45:49 -05:00
NAMES BPatch.h dyninstAPI_RT.h
HINTS ${Dyninst_ROOT_DIR} ${Dyninst_DIR} ${Dyninst_DIR}/../../..
PATHS ${Dyninst_ROOT_DIR} ${Dyninst_DIR} ${Dyninst_DIR}/../../..
2025-06-22 10:44:33 -04:00
PATH_SUFFIXES include
)
2021-09-15 16:45:49 -05:00
endif()
2021-09-09 14:10:42 -05:00
2021-09-15 16:45:49 -05:00
# try to find TBB
2021-09-09 15:51:07 -05:00
find_package(TBB QUIET)
2021-09-09 14:10:42 -05:00
2021-09-15 16:45:49 -05:00
# if fail try to use the Dyninst installed FindTBB.cmake
if(NOT TBB_FOUND)
list(APPEND CMAKE_MODULE_PATH ${Dyninst_DIR}/Modules)
find_package(TBB QUIET)
endif()
2021-08-06 13:08:57 -05:00
2021-09-15 16:45:49 -05:00
if(NOT TBB_FOUND)
2025-06-22 10:44:33 -04:00
find_path(TBB_INCLUDE_DIR NAMES tbb/tbb.h PATH_SUFFIXES include)
2021-09-15 16:45:49 -05:00
endif()
2021-08-06 13:08:57 -05:00
2025-06-22 10:44:33 -04:00
target_link_libraries(
rocprofiler-systems-dyninst
INTERFACE ${DYNINST_LIBRARIES} ${Boost_LIBRARIES}
)
2021-09-20 11:12:06 -05:00
foreach(
_TARG
dyninst
dyninstAPI
instructionAPI
symtabAPI
parseAPI
headers
atomic
system
thread
date_time
2025-06-22 10:44:33 -04:00
TBB
)
2021-09-15 16:45:49 -05:00
if(TARGET Dyninst::${_TARG})
2025-06-22 10:44:33 -04:00
target_link_libraries(
rocprofiler-systems-dyninst
INTERFACE Dyninst::${_TARG}
)
2021-09-15 16:45:49 -05:00
elseif(TARGET Boost::${_TARG})
2025-06-22 10:44:33 -04:00
target_link_libraries(
rocprofiler-systems-dyninst
INTERFACE Boost::${_TARG}
)
2021-09-15 16:45:49 -05:00
elseif(TARGET ${_TARG})
target_link_libraries(rocprofiler-systems-dyninst INTERFACE ${_TARG})
2021-09-15 16:45:49 -05:00
endif()
endforeach()
2021-09-20 11:12:06 -05:00
target_include_directories(
2025-06-22 10:44:33 -04:00
rocprofiler-systems-dyninst
SYSTEM
INTERFACE ${TBB_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${DYNINST_HEADER_DIR}
)
rocprofiler_systems_target_compile_definitions(rocprofiler-systems-dyninst
INTERFACE ROCPROFSYS_USE_DYNINST
2025-06-22 10:44:33 -04:00
)
2021-08-06 13:08:57 -05:00
endif()
endif()
2022-04-05 00:24:34 -05:00
# ----------------------------------------------------------------------------------------#
#
# Modify CMAKE_C_FLAGS and CMAKE_CXX_FLAGS with -static-libgcc and -static-libstdc++
#
# ----------------------------------------------------------------------------------------#
if(ROCPROFSYS_BUILD_STATIC_LIBGCC)
2022-04-05 00:24:34 -05:00
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
rocprofiler_systems_save_variables(STATIC_LIBGCC_C VARIABLES CMAKE_C_FLAGS)
2022-04-05 00:24:34 -05:00
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
rocprofiler_systems_save_variables(STATIC_LIBGCC_CXX VARIABLES CMAKE_CXX_FLAGS)
2022-04-05 00:24:34 -05:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc")
else()
set(ROCPROFSYS_BUILD_STATIC_LIBGCC OFF)
2022-04-05 00:24:34 -05:00
endif()
endif()
if(ROCPROFSYS_BUILD_STATIC_LIBSTDCXX)
2022-04-05 00:24:34 -05:00
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
rocprofiler_systems_save_variables(STATIC_LIBSTDCXX_CXX VARIABLES CMAKE_CXX_FLAGS)
2022-04-05 00:24:34 -05:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++")
else()
set(ROCPROFSYS_BUILD_STATIC_LIBSTDCXX OFF)
2022-04-05 00:24:34 -05:00
endif()
endif()
2021-09-20 11:12:06 -05:00
# ----------------------------------------------------------------------------------------#
2021-08-06 13:08:57 -05:00
#
2021-09-20 11:12:06 -05:00
# Perfetto
2021-08-06 13:08:57 -05:00
#
2021-09-20 11:12:06 -05:00
# ----------------------------------------------------------------------------------------#
2021-08-06 13:08:57 -05:00
2021-08-17 17:34:34 -05:00
set(perfetto_DIR ${PROJECT_SOURCE_DIR}/external/perfetto)
rocprofiler_systems_checkout_git_submodule(
2021-09-20 11:12:06 -05:00
RELATIVE_PATH external/perfetto
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
2024-09-13 15:59:27 -04:00
REPO_URL https://github.com/google/perfetto.git
2024-09-13 13:43:26 -04:00
REPO_BRANCH v46.0
2025-06-22 10:44:33 -04:00
TEST_FILE sdk/perfetto.cc
)
2021-08-06 13:08:57 -05:00
2022-05-11 15:05:09 -05:00
include(Perfetto)
2025-07-28 17:33:52 +02:00
# ----------------------------------------------------------------------------------------#
#
# SQLite3
#
# ----------------------------------------------------------------------------------------#
include(SQLite3)
# ----------------------------------------------------------------------------------------#
#
# Spdlog
#
# ----------------------------------------------------------------------------------------#
include(Spdlog)
# ----------------------------------------------------------------------------------------#
#
# NlohmannJson
#
# ----------------------------------------------------------------------------------------#
include(NlohmannJson)
# ----------------------------------------------------------------------------------------#
#
# GTest
#
# ----------------------------------------------------------------------------------------#
if(ROCPROFSYS_BUILD_TESTING)
include(GTest)
include(GhcFilesystem)
endif()
2021-09-20 11:12:06 -05:00
# ----------------------------------------------------------------------------------------#
2021-09-06 22:23:24 -05:00
#
2021-09-20 11:12:06 -05:00
# ELFIO
2021-09-06 22:23:24 -05:00
#
2021-09-20 11:12:06 -05:00
# ----------------------------------------------------------------------------------------#
2021-09-06 22:23:24 -05:00
if(ROCPROFSYS_BUILD_DEVICETRACE)
rocprofiler_systems_checkout_git_submodule(
2021-09-20 11:12:06 -05:00
RELATIVE_PATH external/elfio
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
REPO_URL https://github.com/jrmadsen/ELFIO.git
2025-06-22 10:44:33 -04:00
REPO_BRANCH set-offset-support
)
2021-09-06 22:23:24 -05:00
add_subdirectory(external/elfio)
endif()
# ----------------------------------------------------------------------------------------#
#
# papi submodule
#
# ----------------------------------------------------------------------------------------#
if(ROCPROFSYS_USE_PAPI AND ROCPROFSYS_BUILD_PAPI)
include(PAPI)
endif()
2021-09-20 11:12:06 -05:00
# ----------------------------------------------------------------------------------------#
2021-08-06 13:08:57 -05:00
#
# timemory submodule
2021-08-17 17:34:34 -05:00
#
2021-09-20 11:12:06 -05:00
# ----------------------------------------------------------------------------------------#
2022-11-01 17:28:12 -05:00
target_compile_definitions(
rocprofiler-systems-timemory-config
2025-06-22 10:44:33 -04:00
INTERFACE
TIMEMORY_PAPI_ARRAY_SIZE=12
TIMEMORY_USE_ROOFLINE=0
TIMEMORY_USE_ERT=0
TIMEMORY_USE_CONTAINERS=0
TIMEMORY_USE_ERT_EXTERN=0
TIMEMORY_USE_CONTAINERS_EXTERN=0
)
if(ROCPROFSYS_BUILD_STACK_PROTECTOR)
add_target_flag_if_avail(rocprofiler-systems-timemory-config
"-fstack-protector-strong" "-Wstack-protector"
2025-06-22 10:44:33 -04:00
)
2022-08-28 03:56:13 -05:00
endif()
if(ROCPROFSYS_BUILD_DEBUG)
add_target_flag_if_avail(rocprofiler-systems-timemory-config
"-fno-omit-frame-pointer" "-g3"
2025-06-22 10:44:33 -04:00
)
2022-08-31 01:24:31 -05:00
endif()
set(TIMEMORY_EXTERNAL_INTERFACE_LIBRARY
rocprofiler-systems-timemory-config
2025-06-22 10:44:33 -04:00
CACHE STRING
"timemory configuration interface library"
)
set(TIMEMORY_INSTALL_HEADERS OFF CACHE BOOL "Disable timemory header install")
set(TIMEMORY_INSTALL_CONFIG OFF CACHE BOOL "Disable timemory cmake configuration install")
2022-03-22 12:30:07 -05:00
set(TIMEMORY_INSTALL_LIBRARIES
OFF
2025-06-22 10:44:33 -04:00
CACHE BOOL
"Disable timemory installation of libraries not needed at runtime"
)
set(TIMEMORY_INSTALL_ALL OFF CACHE BOOL "Disable install target depending on all target")
set(TIMEMORY_BUILD_C OFF CACHE BOOL "Disable timemory C library")
set(TIMEMORY_BUILD_FORTRAN OFF CACHE BOOL "Disable timemory Fortran library")
set(TIMEMORY_BUILD_TOOLS OFF CACHE BOOL "Ensure timem executable is built")
2021-09-20 11:12:06 -05:00
set(TIMEMORY_BUILD_EXCLUDE_FROM_ALL
ON
2025-06-22 10:44:33 -04:00
CACHE BOOL
"Set timemory to only build dependencies"
)
set(TIMEMORY_BUILD_HIDDEN_VISIBILITY
ON
2025-06-22 10:44:33 -04:00
CACHE BOOL
"Build timemory with hidden visibility"
)
set(TIMEMORY_QUIET_CONFIG ON CACHE BOOL "Make timemory configuration quieter")
2021-08-17 17:34:34 -05:00
# timemory feature settings
2025-06-22 10:44:33 -04:00
set(TIMEMORY_USE_GOTCHA ON CACHE BOOL "Enable GOTCHA support in timemory")
set(TIMEMORY_USE_PERFETTO OFF CACHE BOOL "Disable perfetto support in timemory")
2025-08-26 16:54:01 -04:00
set(TIMEMORY_USE_OMPT OFF CACHE BOOL "Enable OMPT support in timemory" FORCE)
2022-03-23 00:28:25 -05:00
set(TIMEMORY_USE_PAPI
${ROCPROFSYS_USE_PAPI}
2025-06-22 10:44:33 -04:00
CACHE BOOL
"Enable PAPI support in timemory"
FORCE
)
set(TIMEMORY_USE_BFD
${ROCPROFSYS_USE_BFD}
2025-06-22 10:44:33 -04:00
CACHE BOOL
"Enable BFD support in timemory"
FORCE
)
set(TIMEMORY_USE_LIBUNWIND ON CACHE BOOL "Enable libunwind support in timemory")
set(TIMEMORY_USE_VISIBILITY OFF CACHE BOOL "Enable/disable using visibility decorations")
2023-02-27 12:09:03 -06:00
set(TIMEMORY_USE_SANITIZER
${ROCPROFSYS_USE_SANITIZER}
2025-06-22 10:44:33 -04:00
CACHE BOOL
"Build with -fsanitze=\${ROCPROFSYS_SANITIZER_TYPE}"
FORCE
)
2023-02-27 12:09:03 -06:00
set(TIMEMORY_SANITIZER_TYPE
${ROCPROFSYS_SANITIZER_TYPE}
2025-06-22 10:44:33 -04:00
CACHE STRING
"Sanitizer type, e.g. leak, thread, address, memory, etc."
FORCE
)
if(DEFINED TIMEMORY_BUILD_GOTCHA AND NOT TIMEMORY_BUILD_GOTCHA)
rocprofiler_systems_message(
FATAL_ERROR
"Using an external gotcha is not allowed due to known bug that has not been accepted upstream"
2025-06-22 10:44:33 -04:00
)
endif()
2021-08-17 17:34:34 -05:00
# timemory feature build settings
2021-09-20 11:12:06 -05:00
set(TIMEMORY_BUILD_GOTCHA
ON
2025-06-22 10:44:33 -04:00
CACHE BOOL
"Enable building GOTCHA library from submodule"
FORCE
)
set(TIMEMORY_BUILD_LIBUNWIND
${ROCPROFSYS_BUILD_LIBUNWIND}
2025-06-22 10:44:33 -04:00
CACHE BOOL
"Enable building libunwind library from submodule"
FORCE
)
set(TIMEMORY_BUILD_EXTRA_OPTIMIZATIONS
${ROCPROFSYS_BUILD_EXTRA_OPTIMIZATIONS}
2025-06-22 10:44:33 -04:00
CACHE BOOL
"Enable building GOTCHA library from submodule"
FORCE
)
set(TIMEMORY_BUILD_ERT OFF CACHE BOOL "Disable building ERT support" FORCE)
2022-11-01 17:28:12 -05:00
set(TIMEMORY_BUILD_CONTAINERS
OFF
2025-06-22 10:44:33 -04:00
CACHE BOOL
"Disable building container extern templates (unused)"
FORCE
)
# timemory build settings
2025-06-22 10:44:33 -04:00
set(TIMEMORY_TLS_MODEL "global-dynamic" CACHE STRING "Thread-local static model" FORCE)
2022-03-07 20:40:48 -06:00
set(TIMEMORY_MAX_THREADS
"${ROCPROFSYS_MAX_THREADS}"
2025-06-22 10:44:33 -04:00
CACHE STRING
"Max statically-allocated threads"
FORCE
)
set(TIMEMORY_SETTINGS_PREFIX
"ROCPROFSYS_"
2025-06-22 10:44:33 -04:00
CACHE STRING
"Prefix used for settings and environment variables"
)
set(TIMEMORY_PROJECT_NAME "rocprofiler-systems" CACHE STRING "Name for configuration")
2022-08-31 01:24:31 -05:00
set(TIMEMORY_CXX_LIBRARY_EXCLUDE
"kokkosp.cpp;pthread.cpp;timemory_c.cpp;trace.cpp;weak.cpp;library.cpp"
2025-06-22 10:44:33 -04:00
CACHE STRING
"Timemory C++ library implementation files to exclude from compiling"
)
2022-08-31 01:24:31 -05:00
mark_as_advanced(TIMEMORY_SETTINGS_PREFIX)
2022-02-23 06:59:32 -06:00
mark_as_advanced(TIMEMORY_PROJECT_NAME)
rocprofiler_systems_checkout_git_submodule(
2021-09-20 11:12:06 -05:00
RELATIVE_PATH external/timemory
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
2024-11-07 16:49:32 -05:00
REPO_URL https://github.com/ROCm/timemory.git
2025-06-22 10:44:33 -04:00
REPO_BRANCH omnitrace
)
2021-08-17 17:34:34 -05:00
rocprofiler_systems_save_variables(
BUILD_CONFIG VARIABLES BUILD_SHARED_LIBS BUILD_STATIC_LIBS
CMAKE_POSITION_INDEPENDENT_CODE CMAKE_PREFIX_PATH
2025-06-22 10:44:33 -04:00
)
2021-09-20 11:12:06 -05:00
# ensure timemory builds PIC static libs so that we don't have to install timemory shared
# lib
2022-02-23 06:59:32 -06:00
set(BUILD_SHARED_LIBS OFF)
set(BUILD_STATIC_LIBS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(TIMEMORY_CTP_OPTIONS GLOBAL)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# results in undefined symbols to component::base<T>::load()
2025-06-22 10:44:33 -04:00
set(TIMEMORY_BUILD_HIDDEN_VISIBILITY OFF CACHE BOOL "" FORCE)
endif()
2022-06-28 16:32:07 -05:00
add_subdirectory(external/timemory EXCLUDE_FROM_ALL)
2022-07-23 03:02:31 -05:00
install(
TARGETS gotcha
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
2025-06-22 10:44:33 -04:00
COMPONENT gotcha
)
if(ROCPROFSYS_BUILD_LIBUNWIND)
2022-06-28 16:32:07 -05:00
install(
DIRECTORY ${PROJECT_BINARY_DIR}/external/timemory/external/libunwind/install/lib/
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
2022-07-23 03:02:31 -05:00
COMPONENT libunwind
2022-06-28 16:32:07 -05:00
FILES_MATCHING
2025-06-22 10:44:33 -04:00
PATTERN "*${CMAKE_SHARED_LIBRARY_SUFFIX}*"
)
2022-06-28 16:32:07 -05:00
endif()
rocprofiler_systems_restore_variables(
BUILD_CONFIG VARIABLES BUILD_SHARED_LIBS BUILD_STATIC_LIBS
CMAKE_POSITION_INDEPENDENT_CODE CMAKE_PREFIX_PATH
2025-06-22 10:44:33 -04:00
)
if(TARGET rocprofiler-systems-papi-build)
2025-06-22 10:44:33 -04:00
foreach(
_TARGET
PAPI::papi
timemory-core
timemory-common
timemory-papi-component
timemory-cxx
)
if(TARGET "${_TARGET}")
add_dependencies(${_TARGET} rocprofiler-systems-papi-build)
endif()
foreach(_LINK shared static)
if(TARGET "${_TARGET}-${_LINK}")
add_dependencies(${_TARGET}-${_LINK} rocprofiler-systems-papi-build)
endif()
endforeach()
endforeach()
endif()
2022-04-25 17:00:52 -05:00
target_link_libraries(
rocprofiler-systems-timemory
2025-06-22 10:44:33 -04:00
INTERFACE
$<BUILD_INTERFACE:timemory::timemory-headers>
$<BUILD_INTERFACE:timemory::timemory-gotcha>
$<BUILD_INTERFACE:timemory::timemory-cxx-static>
)
2022-04-25 17:00:52 -05:00
2025-06-22 10:44:33 -04:00
target_link_libraries(
rocprofiler-systems-bfd
INTERFACE $<BUILD_INTERFACE:timemory::timemory-bfd>
)
if(ROCPROFSYS_USE_BFD)
rocprofiler_systems_target_compile_definitions(rocprofiler-systems-bfd
INTERFACE ROCPROFSYS_USE_BFD
2025-06-22 10:44:33 -04:00
)
endif()
find_package(Libva-headers ${rocprofiler_systems_FIND_QUIETLY} REQUIRED)
2025-06-22 10:44:33 -04:00
target_include_directories(
rocprofiler-systems-libva
INTERFACE ${LIBVA_HEADERS_INCLUDE_DIR}
)
find_package(UCX ${rocprofiler_systems_FIND_QUIETLY} REQUIRED)
target_include_directories(rocprofiler-systems-ucx INTERFACE ${UCX_HEADERS_INCLUDE_DIR})
# ----------------------------------------------------------------------------------------#
#
# PTL (Parallel Tasking Library) submodule
#
# ----------------------------------------------------------------------------------------#
# timemory might provide PTL::ptl-shared
if(NOT TARGET PTL::ptl-shared)
rocprofiler_systems_checkout_git_submodule(
RELATIVE_PATH external/PTL
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
REPO_URL https://github.com/jrmadsen/PTL.git
2025-06-22 10:44:33 -04:00
REPO_BRANCH omnitrace
)
set(PTL_BUILD_EXAMPLES OFF)
set(PTL_USE_TBB OFF)
set(PTL_USE_GPU OFF)
set(PTL_DEVELOPER_INSTALL OFF)
2022-04-04 15:27:38 -05:00
if(NOT DEFINED BUILD_OBJECT_LIBS)
set(BUILD_OBJECT_LIBS OFF)
endif()
rocprofiler_systems_save_variables(
BUILD_CONFIG
2022-03-07 20:40:48 -06:00
VARIABLES BUILD_SHARED_LIBS BUILD_STATIC_LIBS BUILD_OBJECT_LIBS
CMAKE_POSITION_INDEPENDENT_CODE CMAKE_CXX_VISIBILITY_PRESET
CMAKE_VISIBILITY_INLINES_HIDDEN
2025-06-22 10:44:33 -04:00
)
2022-03-07 20:40:48 -06:00
set(BUILD_SHARED_LIBS OFF)
set(BUILD_STATIC_LIBS OFF)
2022-03-07 20:40:48 -06:00
set(BUILD_OBJECT_LIBS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2022-03-07 20:40:48 -06:00
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
2022-06-28 16:32:07 -05:00
add_subdirectory(external/PTL EXCLUDE_FROM_ALL)
rocprofiler_systems_restore_variables(
BUILD_CONFIG
2022-03-07 20:40:48 -06:00
VARIABLES BUILD_SHARED_LIBS BUILD_STATIC_LIBS BUILD_OBJECT_LIBS
CMAKE_POSITION_INDEPENDENT_CODE CMAKE_CXX_VISIBILITY_PRESET
CMAKE_VISIBILITY_INLINES_HIDDEN
2025-06-22 10:44:33 -04:00
)
endif()
2025-06-22 10:44:33 -04:00
target_sources(
rocprofiler-systems-ptl
INTERFACE $<BUILD_INTERFACE:$<TARGET_OBJECTS:PTL::ptl-object>>
)
2023-02-27 12:09:03 -06:00
target_include_directories(
rocprofiler-systems-ptl
2025-06-22 10:44:33 -04:00
INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/external/PTL/source>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/external/PTL/source>
)
2022-04-05 00:24:34 -05:00
# ----------------------------------------------------------------------------------------#
#
# Restore the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS in the inverse order
#
# ----------------------------------------------------------------------------------------#
2022-05-24 22:45:26 -05:00
# override compiler macros
include(Compilers)
if(ROCPROFSYS_BUILD_STATIC_LIBSTDCXX)
2022-04-05 00:24:34 -05:00
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
rocprofiler_systems_restore_variables(STATIC_LIBSTDCXX_CXX
VARIABLES CMAKE_CXX_FLAGS
2025-06-22 10:44:33 -04:00
)
2022-04-05 00:24:34 -05:00
endif()
endif()
if(ROCPROFSYS_BUILD_STATIC_LIBGCC)
2022-04-05 00:24:34 -05:00
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
rocprofiler_systems_restore_variables(STATIC_LIBGCC_C VARIABLES CMAKE_C_FLAGS)
2022-04-05 00:24:34 -05:00
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
rocprofiler_systems_restore_variables(STATIC_LIBGCC_CXX VARIABLES CMAKE_CXX_FLAGS)
2022-04-05 00:24:34 -05:00
endif()
endif()
rocprofiler_systems_add_feature(CMAKE_C_FLAGS "C compiler flags")
rocprofiler_systems_add_feature(CMAKE_CXX_FLAGS "C++ compiler flags")
2022-04-05 00:24:34 -05:00
# ----------------------------------------------------------------------------------------#
#
# Python
#
# ----------------------------------------------------------------------------------------#
if(ROCPROFSYS_USE_PYTHON)
if(ROCPROFSYS_USE_PYTHON AND NOT ROCPROFSYS_BUILD_PYTHON)
2022-04-05 00:24:34 -05:00
find_package(pybind11 REQUIRED)
endif()
include(ConfigPython)
include(PyBind11Tools)
rocprofiler_systems_watch_for_change(ROCPROFSYS_PYTHON_ROOT_DIRS _PYTHON_DIRS_CHANGED)
if(_PYTHON_DIRS_CHANGED)
unset(ROCPROFSYS_PYTHON_VERSION CACHE)
unset(ROCPROFSYS_PYTHON_VERSIONS CACHE)
unset(ROCPROFSYS_INSTALL_PYTHONDIR CACHE)
else()
foreach(_VAR PREFIX ENVS)
rocprofiler_systems_watch_for_change(ROCPROFSYS_PYTHON_${_VAR} _CHANGED)
if(_CHANGED)
unset(ROCPROFSYS_PYTHON_ROOT_DIRS CACHE)
unset(ROCPROFSYS_PYTHON_VERSIONS CACHE)
unset(ROCPROFSYS_INSTALL_PYTHONDIR CACHE)
break()
endif()
endforeach()
endif()
if(ROCPROFSYS_PYTHON_PREFIX AND ROCPROFSYS_PYTHON_ENVS)
rocprofiler_systems_directory(
FAIL
PREFIX ${ROCPROFSYS_PYTHON_PREFIX}
PATHS ${ROCPROFSYS_PYTHON_ENVS}
2025-06-22 10:44:33 -04:00
OUTPUT_VARIABLE _PYTHON_ROOT_DIRS
)
set(ROCPROFSYS_PYTHON_ROOT_DIRS
"${_PYTHON_ROOT_DIRS}"
2025-06-22 10:44:33 -04:00
CACHE INTERNAL
"Root directories for python"
)
endif()
if(NOT ROCPROFSYS_PYTHON_VERSIONS AND ROCPROFSYS_PYTHON_VERSION)
set(ROCPROFSYS_PYTHON_VERSIONS "${ROCPROFSYS_PYTHON_VERSION}")
if(NOT ROCPROFSYS_PYTHON_ROOT_DIRS)
rocprofiler_systems_find_python(_PY VERSION ${ROCPROFSYS_PYTHON_VERSION})
2025-06-22 10:44:33 -04:00
set(ROCPROFSYS_PYTHON_ROOT_DIRS "${_PY_ROOT_DIR}" CACHE INTERNAL "" FORCE)
endif()
unset(ROCPROFSYS_PYTHON_VERSION CACHE)
unset(ROCPROFSYS_INSTALL_PYTHONDIR CACHE)
elseif(
NOT ROCPROFSYS_PYTHON_VERSIONS
AND NOT ROCPROFSYS_PYTHON_VERSION
2025-06-22 10:44:33 -04:00
AND ROCPROFSYS_PYTHON_ROOT_DIRS
)
set(_PY_VERSIONS)
foreach(_DIR ${ROCPROFSYS_PYTHON_ROOT_DIRS})
rocprofiler_systems_find_python(_PY ROOT_DIR ${_DIR})
if(NOT _PY_FOUND)
continue()
endif()
if(NOT "${_PY_VERSION}" IN_LIST _PY_VERSIONS)
list(APPEND _PY_VERSIONS "${_PY_VERSION}")
endif()
endforeach()
2025-06-22 10:44:33 -04:00
set(ROCPROFSYS_PYTHON_VERSIONS "${_PY_VERSIONS}" CACHE INTERNAL "" FORCE)
elseif(
NOT ROCPROFSYS_PYTHON_VERSIONS
AND NOT ROCPROFSYS_PYTHON_VERSION
2025-06-22 10:44:33 -04:00
AND NOT ROCPROFSYS_PYTHON_ROOT_DIRS
)
rocprofiler_systems_find_python(_PY REQUIRED)
2025-06-22 10:44:33 -04:00
set(ROCPROFSYS_PYTHON_ROOT_DIRS "${_PY_ROOT_DIR}" CACHE INTERNAL "" FORCE)
set(ROCPROFSYS_PYTHON_VERSIONS "${_PY_VERSION}" CACHE INTERNAL "" FORCE)
endif()
rocprofiler_systems_watch_for_change(ROCPROFSYS_PYTHON_ROOT_DIRS)
rocprofiler_systems_watch_for_change(ROCPROFSYS_PYTHON_VERSIONS)
rocprofiler_systems_check_python_dirs_and_versions(FAIL)
list(LENGTH ROCPROFSYS_PYTHON_VERSIONS _NUM_PYTHON_VERSIONS)
if(_NUM_PYTHON_VERSIONS GREATER 1)
set(ROCPROFSYS_INSTALL_PYTHONDIR
"${CMAKE_INSTALL_LIBDIR}/python/site-packages"
2025-06-22 10:44:33 -04:00
CACHE STRING
"Installation prefix for python"
)
else()
set(ROCPROFSYS_INSTALL_PYTHONDIR
"${CMAKE_INSTALL_LIBDIR}/python${ROCPROFSYS_PYTHON_VERSIONS}/site-packages"
2025-06-22 10:44:33 -04:00
CACHE STRING
"Installation prefix for python"
)
endif()
else()
set(ROCPROFSYS_INSTALL_PYTHONDIR
"${CMAKE_INSTALL_LIBDIR}/python/site-packages"
2025-06-22 10:44:33 -04:00
CACHE STRING
"Installation prefix for python"
)
2022-04-05 00:24:34 -05:00
endif()
rocprofiler_systems_watch_for_change(ROCPROFSYS_INSTALL_PYTHONDIR)
set(CMAKE_INSTALL_PYTHONDIR ${ROCPROFSYS_INSTALL_PYTHONDIR})
# ----------------------------------------------------------------------------------------#
#
# Compile definitions
#
# ----------------------------------------------------------------------------------------#
if("${CMAKE_BUILD_TYPE}" MATCHES "Release" AND NOT ROCPROFSYS_BUILD_DEBUG)
add_target_flag_if_avail(rocprofiler-systems-compile-options "-g1")
endif()
2025-06-22 10:44:33 -04:00
target_compile_definitions(
rocprofiler-systems-compile-definitions
INTERFACE ROCPROFSYS_MAX_THREADS=${ROCPROFSYS_MAX_THREADS}
)
2023-02-08 11:54:45 -06:00
foreach(_LIB ${ROCPROFSYS_EXTENSION_LIBRARIES})
get_target_property(_COMPILE_DEFS ${_LIB} INTERFACE_COMPILE_DEFINITIONS)
if(_COMPILE_DEFS)
foreach(_DEF ${_COMPILE_DEFS})
if("${_DEF}" MATCHES "ROCPROFSYS_")
2025-06-22 10:44:33 -04:00
target_compile_definitions(
rocprofiler-systems-compile-definitions
INTERFACE ${_DEF}
)
endif()
endforeach()
endif()
endforeach()