2026-01-26 23:10:01 -05:00
# Copyright (c) Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
2025-08-21 15:56:47 -04:00
cmake_minimum_required ( VERSION 3.21 FATAL_ERROR )
2021-08-06 13:08:57 -05:00
2025-06-22 10:44:33 -04:00
if (
CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR
AND CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR
)
2021-08-06 13:08:57 -05:00
set ( MSG "" )
message ( STATUS "Warning! Building from the source directory is not recommended" )
message ( STATUS "If unintented, please remove 'CMakeCache.txt' and 'CMakeFiles'" )
message ( STATUS "and build from a separate directory" )
message ( AUTHOR_WARNING "In-source build" )
endif ()
2025-06-06 22:52:23 -04:00
# find_package() uses upper-case <PACKAGENAME>_ROOT variables.
if ( POLICY CMP0144 )
cmake_policy ( SET CMP0144 NEW )
endif ()
2021-10-01 16:46:03 -05:00
if ( NOT UNIX OR APPLE )
message (
AUTHOR_WARNING
2025-06-22 10:44:33 -04:00
"rocprofiler-systems only supports Linux. Configure and/or build is likely to fail"
)
2021-10-01 16:46:03 -05:00
endif ()
2021-11-24 04:59:59 -06:00
file ( READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" FULL_VERSION_STRING LIMIT_COUNT 1 )
string ( REGEX REPLACE "(\n|\r)" "" FULL_VERSION_STRING "${FULL_VERSION_STRING}" )
2025-06-22 10:44:33 -04:00
string (
REGEX REPLACE
"([0-9]+)\.([0-9]+)\.([0-9]+)(.*)"
"\\1.\\2.\\3"
ROCPROFSYS_VERSION
"${FULL_VERSION_STRING}"
)
2021-11-24 04:59:59 -06:00
2021-08-06 13:08:57 -05:00
project (
2024-10-15 11:20:40 -04:00
rocprofiler-systems
2021-08-17 17:34:34 -05:00
LANGUAGES C CXX
2024-10-15 11:20:40 -04:00
VERSION ${ ROCPROFSYS_VERSION }
2021-11-24 04:59:59 -06:00
DESCRIPTION "CPU/GPU Application tracing with static/dynamic binary instrumentation"
2025-06-22 10:44:33 -04:00
HOMEPAGE_URL "https://github.com/ROCm/rocprofiler-systems"
)
2024-10-15 11:20:40 -04:00
set ( PROJECT_NAME_UNDERSCORED "rocprofiler_systems" )
set ( BINARY_NAME_PREFIX "rocprof-sys" )
2021-08-06 13:08:57 -05:00
2022-07-17 21:52:09 -05:00
find_package ( Git )
if ( Git_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git" )
execute_process (
COMMAND ${ GIT_EXECUTABLE } describe --tags
2024-10-15 11:20:40 -04:00
OUTPUT_VARIABLE ROCPROFSYS_GIT_DESCRIBE
2022-11-01 17:28:12 -05:00
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE _GIT_DESCRIBE_RESULT
2025-06-22 10:44:33 -04:00
ERROR_QUIET
)
2022-11-01 17:28:12 -05:00
if ( NOT _GIT_DESCRIBE_RESULT EQUAL 0 )
execute_process (
COMMAND ${ GIT_EXECUTABLE } describe
2024-10-15 11:20:40 -04:00
OUTPUT_VARIABLE ROCPROFSYS_GIT_DESCRIBE
2022-11-01 17:28:12 -05:00
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE _GIT_DESCRIBE_RESULT
2025-06-22 10:44:33 -04:00
ERROR_QUIET
)
2022-11-01 17:28:12 -05:00
endif ()
2022-07-17 21:52:09 -05:00
execute_process (
COMMAND ${ GIT_EXECUTABLE } rev-parse HEAD
2024-10-15 11:20:40 -04:00
OUTPUT_VARIABLE ROCPROFSYS_GIT_REVISION
2025-06-22 10:44:33 -04:00
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
2022-07-17 21:52:09 -05:00
else ()
2024-10-15 11:20:40 -04:00
set ( ROCPROFSYS_GIT_DESCRIBE "v${ROCPROFSYS_VERSION}" )
set ( ROCPROFSYS_GIT_REVISION "" )
2022-07-17 21:52:09 -05:00
endif ()
2021-09-20 11:12:06 -05:00
message (
STATUS
2025-06-22 10:44:33 -04:00
"[${PROJECT_NAME}] version ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} (${FULL_VERSION_STRING})"
)
2024-10-15 11:20:40 -04:00
message ( STATUS "[${PROJECT_NAME}] git revision: ${ROCPROFSYS_GIT_REVISION}" )
message ( STATUS "[${PROJECT_NAME}] git describe: ${ROCPROFSYS_GIT_DESCRIBE}" )
2025-06-22 10:44:33 -04:00
set ( CMAKE_MODULE_PATH
${ PROJECT_SOURCE_DIR } /cmake
${ PROJECT_SOURCE_DIR } /cmake/Modules
${ PROJECT_SOURCE_DIR } /source/python/cmake
${ CMAKE_MODULE_PATH }
)
set ( BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries" )
set ( BUILD_STATIC_LIBS OFF CACHE BOOL "Build static libraries" )
set ( CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Build position independent code" )
2021-08-06 13:08:57 -05:00
2024-01-10 05:02:22 -06:00
if ( CMAKE_VERSION VERSION_GREATER_EQUAL 3.24 )
cmake_policy ( SET CMP0135 NEW )
endif ()
2021-08-06 13:08:57 -05:00
if ( "${CMAKE_BUILD_TYPE}" STREQUAL "" )
2025-06-22 10:44:33 -04:00
set ( CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE )
2022-04-05 00:24:34 -05:00
else ()
set ( VALID_BUILD_TYPES "Release" "RelWithDebInfo" "Debug" "MinSizeRel" )
if ( NOT "${CMAKE_BUILD_TYPE}" IN_LIST VALID_BUILD_TYPES )
string ( REPLACE ";" ", " _VALID_BUILD_TYPES "${VALID_BUILD_TYPES}" )
message (
FATAL_ERROR
2025-06-22 10:44:33 -04:00
"Invalid CMAKE_BUILD_TYPE :: ${CMAKE_BUILD_TYPE}. Valid build types are: ${_VALID_BUILD_TYPES}"
)
2022-04-05 00:24:34 -05:00
endif ()
endif ()
set ( _STRIP_LIBRARIES_DEFAULT OFF )
if ( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" )
set ( _STRIP_LIBRARIES_DEFAULT ON )
2021-08-06 13:08:57 -05:00
endif ()
2022-04-21 20:33:51 -05:00
if ( DEFINED CMAKE_INSTALL_LIBDIR AND NOT DEFINED CMAKE_DEFAULT_INSTALL_LIBDIR )
# always have a fresh install
unset ( CMAKE_INSTALL_LIBDIR CACHE )
include ( GNUInstallDirs ) # install directories
# force this because dyninst always installs to lib
set ( CMAKE_DEFAULT_INSTALL_LIBDIR
"${CMAKE_INSTALL_LIBDIR}"
2025-06-22 10:44:33 -04:00
CACHE STRING
"Object code libraries"
FORCE
)
2022-04-21 20:33:51 -05:00
endif ()
2024-10-15 11:20:40 -04:00
if ( NOT "$ENV{ROCPROFSYS_CI}" STREQUAL "" )
set ( CI_BUILD $ENV{ ROCPROFSYS_CI } )
2022-09-30 10:47:07 -05:00
else ()
set ( CI_BUILD OFF )
endif ()
2021-09-20 11:12:06 -05:00
include ( GNUInstallDirs ) # install directories
include ( MacroUtilities ) # various functions and macros
2022-09-30 10:47:07 -05:00
if ( CI_BUILD )
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_CI "Enable internal asserts, etc." ON
2025-06-22 10:44:33 -04:00
ADVANCED NO_FEATURE
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_TESTING
2025-06-22 10:44:33 -04:00
"Enable building the testing suite" ON ADVANCED
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option (
ROCPROFSYS_BUILD_DEBUG "Enable building with extensive debug symbols" OFF
2025-06-22 10:44:33 -04:00
ADVANCED
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option (
ROCPROFSYS_BUILD_HIDDEN_VISIBILITY
2025-06-22 10:44:33 -04:00
"Build with hidden visibility (disable for Debug builds)" OFF ADVANCED
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option ( ROCPROFSYS_STRIP_LIBRARIES "Strip the libraries" OFF
2025-06-22 10:44:33 -04:00
ADVANCED
)
2022-09-30 10:47:07 -05:00
else ()
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_CI "Enable internal asserts, etc."
2026-01-26 23:10:01 -05:00
OFF ADVANCED NO_FEATURE
2025-06-22 10:44:33 -04:00
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_EXAMPLES
2026-01-26 23:10:01 -05:00
"Enable building the examples" OFF ADVANCED
)
rocprofiler_systems_add_option ( ROCPROFSYS_INSTALL_EXAMPLES
"Install the examples" OFF
2025-06-22 10:44:33 -04:00
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_TESTING
2026-01-26 23:10:01 -05:00
"Enable building the testing suite" OFF ADVANCED
)
rocprofiler_systems_add_option ( ROCPROFSYS_INSTALL_TESTING
"Install the test suite" OFF
2025-06-22 10:44:33 -04:00
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option (
2026-01-26 23:10:01 -05:00
ROCPROFSYS_BUILD_DEBUG "Enable building with extensive debug symbols" OFF
ADVANCED
2025-06-22 10:44:33 -04:00
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option (
2026-01-26 23:10:01 -05:00
ROCPROFSYS_BUILD_HIDDEN_VISIBILITY
"Build with hidden visibility (disable for Debug builds)" ON ADVANCED
2025-06-22 10:44:33 -04:00
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option ( ROCPROFSYS_STRIP_LIBRARIES "Strip the libraries"
2026-01-26 23:10:01 -05:00
${ _STRIP_LIBRARIES_DEFAULT } ADVANCED
2025-06-22 10:44:33 -04:00
)
2022-09-30 10:47:07 -05:00
endif ()
2026-01-26 23:10:01 -05:00
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_FOR_THEROCK "Build rocprofiler-systems for use with TheRock" OFF
ADVANCED NO_FEATURE
)
if ( ROCPROFSYS_BUILD_FOR_THEROCK )
set ( ROCPROFSYS_INSTALL_TESTING
ON
CACHE BOOL
"Install testing scripts and pytest package"
FORCE
)
set ( ROCPROFSYS_USE_PYTESTS ON CACHE BOOL "Enable pytest suite" FORCE )
# Lulesh does not build with TheRock
if ( NOT DEFINED ROCPROFSYS_DISABLE_EXAMPLES )
set ( ROCPROFSYS_DISABLE_EXAMPLES
"lulesh"
CACHE STRING
"Disable building examples"
FORCE
)
else ()
if ( NOT "lulesh" IN_LIST ROCPROFSYS_DISABLE_EXAMPLES )
list ( APPEND ROCPROFSYS_DISABLE_EXAMPLES "lulesh" )
endif ()
endif ()
endif ()
2021-09-20 11:12:06 -05:00
include ( Compilers ) # compiler identification
include ( BuildSettings ) # compiler flags
2021-08-06 13:08:57 -05:00
2025-06-22 10:44:33 -04:00
set ( CMAKE_INSTALL_LIBDIR "lib" CACHE STRING "Object code libraries (lib)" FORCE )
set ( CMAKE_CXX_STANDARD 17 CACHE STRING "CXX language standard" )
2022-05-26 10:03:31 -05:00
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_feature ( CMAKE_BUILD_TYPE "Build optimization level" )
rocprofiler_systems_add_feature ( CMAKE_INSTALL_PREFIX "Installation prefix" )
rocprofiler_systems_add_feature ( CMAKE_CXX_COMPILER "C++ compiler" )
rocprofiler_systems_add_feature ( CMAKE_CXX_STANDARD "CXX language standard" )
rocprofiler_systems_add_option ( CMAKE_CXX_STANDARD_REQUIRED
2025-06-22 10:44:33 -04:00
"Require C++ language standard" ON
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option ( CMAKE_CXX_EXTENSIONS
2025-06-22 10:44:33 -04:00
"Compiler specific language extensions" OFF
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option ( CMAKE_INSTALL_RPATH_USE_LINK_PATH
2025-09-05 14:27:31 -04:00
"Enable rpath to linked libraries" OFF
2025-06-22 10:44:33 -04:00
)
set ( CMAKE_INSTALL_MESSAGE "LAZY" CACHE STRING "Installation message" )
2022-05-24 22:45:26 -05:00
mark_as_advanced ( CMAKE_INSTALL_MESSAGE )
2022-01-24 20:49:17 -06:00
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option ( ROCPROFSYS_USE_CLANG_TIDY "Enable clang-tidy" OFF )
rocprofiler_systems_add_option ( ROCPROFSYS_USE_BFD
2025-06-22 10:44:33 -04:00
"Enable BFD support (map call-stack samples to LOC)" ON
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option ( ROCPROFSYS_USE_MPI "Enable MPI support" OFF )
2024-12-13 18:48:39 -05:00
rocprofiler_systems_add_option ( ROCPROFSYS_USE_ROCM "Enable ROCm support" ON )
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option ( ROCPROFSYS_USE_PAPI "Enable HW counter support via PAPI"
2025-06-22 10:44:33 -04:00
ON
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option (
ROCPROFSYS_USE_MPI_HEADERS
2025-06-22 10:44:33 -04:00
"Enable wrapping MPI functions w/o enabling MPI dependency" ON
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option ( ROCPROFSYS_USE_OMPT "Enable OpenMP tools support" ON )
rocprofiler_systems_add_option ( ROCPROFSYS_USE_PYTHON "Enable Python support" OFF )
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_DYNINST "Build dyninst from submodule"
2025-06-22 10:44:33 -04:00
OFF
)
2025-11-10 14:38:51 -05:00
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_ELFUTILS "Build elfutils from submodule"
OFF
)
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_LIBIBERTY "Build libiberty from submodule"
OFF
)
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_BOOST "Build boost from submodule"
OFF
)
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_TBB "Build tbb from submodule"
OFF
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_LIBUNWIND
2025-06-22 10:44:33 -04:00
"Build libunwind from submodule" ON
)
2025-10-24 17:47:15 +02:00
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_NLOHMANN_JSON
"Build nlohmann/json from submodule" ON
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_CODECOV "Build for code coverage" OFF )
rocprofiler_systems_add_option ( ROCPROFSYS_INSTALL_PERFETTO_TOOLS
2025-06-22 10:44:33 -04:00
"Install perfetto tools (i.e. traced, perfetto, etc.)" OFF
)
2026-01-14 21:27:51 +01:00
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_SPDLOG
"Enable building spdlog library internally" ON
)
2025-12-03 13:11:15 +01:00
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_SQLITE3
"Enable building sqlite3 library internally" ON
2025-07-28 17:33:52 +02:00
)
2025-12-03 13:11:15 +01:00
2025-11-24 11:49:30 +01:00
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_GTEST
"Enable building googletest library internally" ON
)
2024-10-15 11:20:40 -04:00
if ( ROCPROFSYS_USE_PAPI )
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_PAPI "Build PAPI from submodule" ON )
2022-04-21 20:33:51 -05:00
endif ()
2024-10-15 11:20:40 -04:00
if ( ROCPROFSYS_USE_PYTHON )
rocprofiler_systems_add_option ( ROCPROFSYS_BUILD_PYTHON
2025-06-22 10:44:33 -04:00
"Build python bindings with internal pybind11" ON
)
2024-10-15 11:20:40 -04:00
elseif ( "$ENV{ROCPROFSYS_CI}" )
2022-11-01 17:28:12 -05:00
# quiet warnings in dashboard
2024-10-15 11:20:40 -04:00
if ( ROCPROFSYS_PYTHON_ENVS OR ROCPROFSYS_PYTHON_PREFIX )
rocprofiler_systems_message (
2022-11-01 17:28:12 -05:00
STATUS
2025-06-22 10:44:33 -04:00
"Ignoring values of ROCPROFSYS_PYTHON_ENVS and/or ROCPROFSYS_PYTHON_PREFIX"
)
2022-11-01 17:28:12 -05:00
endif ()
2022-04-05 00:24:34 -05:00
endif ()
2022-02-25 03:56:41 -06:00
2026-01-26 23:10:01 -05:00
if ( ROCPROFSYS_INSTALL_TESTING )
set ( ROCPROFSYS_INSTALL_EXAMPLES ON CACHE BOOL "Enable installing examples" FORCE )
set ( ROCPROFSYS_BUILD_TESTING ON CACHE BOOL "Enable building the testing suite" FORCE )
endif ()
if ( ROCPROFSYS_INSTALL_EXAMPLES )
set ( ROCPROFSYS_BUILD_EXAMPLES ON CACHE BOOL "Enable building the examples" FORCE )
endif ()
2024-10-15 11:20:40 -04:00
if ( ROCPROFSYS_BUILD_TESTING )
2025-06-22 10:44:33 -04:00
set ( ROCPROFSYS_BUILD_EXAMPLES ON CACHE BOOL "Enable building the examples" FORCE )
2022-03-07 20:40:48 -06:00
endif ()
2021-11-23 02:53:14 -06:00
include ( ProcessorCount )
2025-06-22 10:44:33 -04:00
ProcessorCount ( ROCPROFSYS_PROCESSOR_COUNT )
2023-02-09 09:47:48 -06:00
2024-10-15 11:20:40 -04:00
if ( ROCPROFSYS_PROCESSOR_COUNT LESS 8 )
set ( ROCPROFSYS_THREAD_COUNT 128 )
2023-02-09 09:47:48 -06:00
else ()
2024-10-15 11:20:40 -04:00
math ( EXPR ROCPROFSYS_THREAD_COUNT "16 * ${ROCPROFSYS_PROCESSOR_COUNT}" )
compute_pow2_ceil ( ROCPROFSYS_THREAD_COUNT "16 * ${ROCPROFSYS_PROCESSOR_COUNT}" )
2023-02-09 09:47:48 -06:00
2026-01-08 00:33:37 +05:30
# Fatal error if pow2 calculation failed (e.g., Python3 not found)
2024-10-15 11:20:40 -04:00
if ( ROCPROFSYS_THREAD_COUNT LESS 2 )
2026-01-08 00:33:37 +05:30
rocprofiler_systems_message (
FATAL_ERROR
"Failed to compute power of 2 ceiling for ROCPROFSYS_THREAD_COUNT. "
"Ensure dependency is available. Processor count: ${ROCPROFSYS_PROCESSOR_COUNT}"
)
2023-02-09 09:47:48 -06:00
endif ()
2022-01-24 20:49:17 -06:00
endif ()
2023-02-09 09:47:48 -06:00
2024-10-15 11:20:40 -04:00
set ( ROCPROFSYS_MAX_THREADS
"${ROCPROFSYS_THREAD_COUNT}"
2025-06-22 10:44:33 -04:00
CACHE STRING
"Maximum number of threads in the host application. Likely only needs to be increased if host app does not use thread-pool but creates many threads"
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_feature (
ROCPROFSYS_MAX_THREADS
2022-01-24 20:49:17 -06:00
"Maximum number of total threads supported in the host application (default: max of 128 or 16 * nproc)"
2025-06-22 10:44:33 -04:00
)
2023-02-09 09:47:48 -06:00
2024-10-15 11:20:40 -04:00
compute_pow2_ceil ( _MAX_THREADS "${ROCPROFSYS_MAX_THREADS}" )
2023-02-09 09:47:48 -06:00
2024-10-15 11:20:40 -04:00
if ( _MAX_THREADS GREATER 0 AND NOT ROCPROFSYS_MAX_THREADS EQUAL _MAX_THREADS )
rocprofiler_systems_message (
2023-02-09 09:47:48 -06:00
FATAL_ERROR
2024-10-15 11:20:40 -04:00
"Error! ROCPROFSYS_MAX_THREADS must be a power of 2. Recommendation: ${_MAX_THREADS}"
2025-06-22 10:44:33 -04:00
)
2024-10-15 11:20:40 -04:00
elseif ( NOT ROCPROFSYS_MAX_THREADS EQUAL _MAX_THREADS )
rocprofiler_systems_message (
2023-02-09 09:47:48 -06:00
AUTHOR_WARNING
2024-10-15 11:20:40 -04:00
"ROCPROFSYS_MAX_THREADS (=${ROCPROFSYS_MAX_THREADS}) must be a power of 2. We were unable to verify it so we are emitting this warning instead. Estimate resulted in: ${_MAX_THREADS}"
2025-06-22 10:44:33 -04:00
)
2023-02-09 09:47:48 -06:00
endif ()
2024-10-15 11:20:40 -04:00
set ( ROCPROFSYS_MAX_UNWIND_DEPTH
2022-08-31 01:24:31 -05:00
"64"
2025-06-22 10:44:33 -04:00
CACHE STRING
"Maximum call-stack depth to search during call-stack unwinding. Decreasing this value will result in sampling consuming less memory"
)
2024-10-15 11:20:40 -04:00
rocprofiler_systems_add_feature (
ROCPROFSYS_MAX_UNWIND_DEPTH
2022-08-31 01:24:31 -05:00
"Maximum call-stack depth to search during call-stack unwinding. Decreasing this value will result in sampling consuming less memory"
2025-06-22 10:44:33 -04:00
)
2021-09-02 13:14:58 -05:00
2021-11-23 02:53:14 -06:00
# default visibility settings
2022-01-24 20:49:17 -06:00
set ( CMAKE_C_VISIBILITY_PRESET
"default"
2025-06-22 10:44:33 -04:00
CACHE STRING
"Visibility preset for non-inline C functions"
)
2022-01-24 20:49:17 -06:00
set ( CMAKE_CXX_VISIBILITY_PRESET
"default"
2025-06-22 10:44:33 -04:00
CACHE STRING
"Visibility preset for non-inline C++ functions/objects"
)
2022-01-24 20:49:17 -06:00
set ( CMAKE_VISIBILITY_INLINES_HIDDEN
OFF
2025-06-22 10:44:33 -04:00
CACHE BOOL
"Visibility preset for inline functions"
)
2021-11-23 02:53:14 -06:00
set ( CMAKE_EXPORT_COMPILE_COMMANDS ON )
include ( Formatting ) # format target
2021-09-20 11:12:06 -05:00
include ( Packages ) # finds third-party libraries
2021-08-06 13:08:57 -05:00
2024-10-15 11:20:40 -04:00
rocprofiler_systems_activate_clang_tidy ()
2021-08-06 13:08:57 -05:00
2021-11-23 02:53:14 -06:00
# custom visibility settings
2024-10-15 11:20:40 -04:00
if ( ROCPROFSYS_BUILD_HIDDEN_VISIBILITY )
2022-02-19 02:00:59 -06:00
set ( CMAKE_C_VISIBILITY_PRESET "internal" )
set ( CMAKE_CXX_VISIBILITY_PRESET "internal" )
2022-01-24 20:49:17 -06:00
set ( CMAKE_VISIBILITY_INLINES_HIDDEN ON )
endif ()
2021-09-15 16:45:49 -05:00
2024-10-15 11:20:40 -04:00
if ( ROCPROFSYS_BUILD_TESTING OR "$ENV{ROCPROFSYS_CI}" MATCHES "[1-9]+|ON|on|y|yes" )
2022-03-07 20:40:48 -06:00
enable_testing ()
2022-10-31 15:39:45 -05:00
include ( CTest )
2022-03-07 20:40:48 -06:00
endif ()
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-08-06 13:08:57 -05:00
#
2022-02-19 02:00:59 -06:00
# library and executables
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-07-23 03:02:31 -05:00
set ( CMAKE_INSTALL_DEFAULT_COMPONENT_NAME core )
2024-10-15 11:20:40 -04:00
if ( ROCPROFSYS_BUILD_CODECOV )
rocprofiler_systems_save_variables ( CODECOV_FLAGS VARIABLES CMAKE_C_FLAGS
2025-06-22 10:44:33 -04:00
CMAKE_CXX_FLAGS
)
2022-10-31 15:39:45 -05:00
foreach ( _BUILD_TYPE DEBUG MINSIZEREL RELWITHDEBINFO RELEASE )
2024-10-15 11:20:40 -04:00
rocprofiler_systems_save_variables (
CODECOV_FLAGS VARIABLES CMAKE_C_FLAGS_ ${ _BUILD_TYPE }
2025-06-22 10:44:33 -04:00
CMAKE_CXX_FLAGS_ ${ _BUILD_TYPE }
)
2022-10-31 15:39:45 -05:00
endforeach ()
foreach ( _BUILD_TYPE DEBUG MINSIZEREL RELWITHDEBINFO RELEASE )
set ( CMAKE_C_FLAGS_ ${ _BUILD_TYPE }
"-Og -g3 -fno-omit-frame-pointer -fprofile-abs-path -fprofile-arcs -ftest-coverage"
2025-06-22 10:44:33 -04:00
)
2022-10-31 15:39:45 -05:00
set ( CMAKE_CXX_FLAGS_ ${ _BUILD_TYPE }
"-Og -g3 -fno-omit-frame-pointer -fprofile-abs-path -fprofile-arcs -ftest-coverage"
2025-06-22 10:44:33 -04:00
)
2022-10-31 15:39:45 -05:00
endforeach ()
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" )
endif ()
2022-02-19 02:00:59 -06:00
add_subdirectory ( source )
2021-08-06 13:08:57 -05:00
2024-10-15 11:20:40 -04:00
if ( ROCPROFSYS_BUILD_CODECOV )
rocprofiler_systems_restore_variables ( CODECOV_FLAGS VARIABLES CMAKE_C_FLAGS
2025-06-22 10:44:33 -04:00
CMAKE_CXX_FLAGS
)
2022-10-31 15:39:45 -05:00
foreach ( _BUILD_TYPE DEBUG MINSIZEREL RELWITHDEBINFO RELEASE )
2024-10-15 11:20:40 -04:00
rocprofiler_systems_restore_variables (
2022-10-31 15:39:45 -05:00
CODECOV_FLAGS VARIABLES CMAKE_C_FLAGS_ ${ _BUILD_TYPE }
2025-06-22 10:44:33 -04:00
CMAKE_CXX_FLAGS_ ${ _BUILD_TYPE }
)
2022-10-31 15:39:45 -05:00
endforeach ()
endif ()
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-09-02 13:14:58 -05:00
#
2021-09-20 11:12:06 -05:00
# miscellaneous installs
2021-09-02 13:14:58 -05:00
#
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-09-02 13:14:58 -05:00
2024-10-15 11:20:40 -04:00
configure_file (
2025-09-10 14:46:39 -05:00
${ PROJECT_SOURCE_DIR } /LICENSE.md
${ PROJECT_BINARY_DIR } / ${ CMAKE_INSTALL_DATAROOTDIR } /doc/ ${ PROJECT_NAME } /LICENSE.md
2025-06-22 10:44:33 -04:00
COPYONLY
)
2024-10-15 11:20:40 -04:00
2022-08-08 08:38:38 -05:00
configure_file (
2024-01-10 05:02:22 -06:00
${ PROJECT_SOURCE_DIR } /perfetto.cfg
${ PROJECT_BINARY_DIR } / ${ CMAKE_INSTALL_DATAROOTDIR } / ${ PROJECT_NAME } /perfetto.cfg
2025-06-22 10:44:33 -04:00
COPYONLY
)
2022-08-08 08:38:38 -05:00
configure_file (
${ PROJECT_SOURCE_DIR } /cmake/Templates/setup-env.sh.in
2025-06-22 10:44:33 -04:00
${ PROJECT_BINARY_DIR } / ${ CMAKE_INSTALL_DATAROOTDIR } / ${ PROJECT_NAME } /setup-env.sh
@ONLY
)
2022-04-04 15:27:38 -05:00
configure_file (
${ PROJECT_SOURCE_DIR } /cmake/Templates/modulefile.in
2024-10-15 11:20:40 -04:00
${ PROJECT_BINARY_DIR } / ${ CMAKE_INSTALL_DATAROOTDIR } /modulefiles/ ${ PROJECT_NAME } / ${ ROCPROFSYS_VERSION }
2025-06-22 10:44:33 -04:00
@ONLY
)
2021-10-01 16:46:03 -05:00
2024-12-18 17:34:02 -05:00
configure_file (
${ PROJECT_SOURCE_DIR } /scripts/merge-multiprocess-output.sh
2025-05-02 16:52:54 -04:00
${ PROJECT_BINARY_DIR } / ${ CMAKE_INSTALL_LIBEXECDIR } / ${ PROJECT_NAME } /rocprof-sys-merge-output.sh
2025-06-22 10:44:33 -04:00
COPYONLY
)
2024-12-18 17:34:02 -05:00
2021-09-02 13:14:58 -05:00
install (
2025-06-22 10:44:33 -04:00
FILES
${ PROJECT_BINARY_DIR } / ${ CMAKE_INSTALL_DATAROOTDIR } / ${ PROJECT_NAME } /setup-env.sh
${ PROJECT_BINARY_DIR } / ${ CMAKE_INSTALL_DATAROOTDIR } / ${ PROJECT_NAME } /perfetto.cfg
2021-10-01 16:46:03 -05:00
DESTINATION ${ CMAKE_INSTALL_DATAROOTDIR } / ${ PROJECT_NAME }
2025-06-22 10:44:33 -04:00
COMPONENT setup
)
2021-09-02 13:14:58 -05:00
2022-04-04 15:27:38 -05:00
install (
FILES
2024-10-15 11:20:40 -04:00
${ PROJECT_BINARY_DIR } / ${ CMAKE_INSTALL_DATAROOTDIR } /modulefiles/ ${ PROJECT_NAME } / ${ ROCPROFSYS_VERSION }
2022-04-04 15:27:38 -05:00
DESTINATION ${ CMAKE_INSTALL_DATAROOTDIR } /modulefiles/ ${ PROJECT_NAME }
2025-06-22 10:44:33 -04:00
COMPONENT setup
)
2022-04-04 15:27:38 -05:00
2024-09-05 15:47:16 -04:00
install (
2025-09-10 14:46:39 -05:00
FILES
${ PROJECT_BINARY_DIR } / ${ CMAKE_INSTALL_DATAROOTDIR } /doc/ ${ PROJECT_NAME } /LICENSE.md
2024-10-15 11:20:40 -04:00
DESTINATION ${ CMAKE_INSTALL_DATAROOTDIR } /doc/ ${ PROJECT_NAME }
2025-06-22 10:44:33 -04:00
COMPONENT setup
)
2024-09-05 15:47:16 -04:00
2024-12-18 17:34:02 -05:00
install (
PROGRAMS
2025-05-02 16:52:54 -04:00
${ PROJECT_BINARY_DIR } / ${ CMAKE_INSTALL_LIBEXECDIR } / ${ PROJECT_NAME } /rocprof-sys-merge-output.sh
DESTINATION ${ CMAKE_INSTALL_LIBEXECDIR } / ${ PROJECT_NAME }
2025-06-22 10:44:33 -04:00
COMPONENT setup
)
2024-12-18 17:34:02 -05:00
2023-02-27 12:09:03 -06:00
# ------------------------------------------------------------------------------#
#
# install
#
# ------------------------------------------------------------------------------#
set ( CMAKE_INSTALL_DEFAULT_COMPONENT_NAME core )
include ( ConfigInstall )
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-08-06 13:08:57 -05:00
#
2021-09-20 11:12:06 -05:00
# examples
2021-08-06 13:08:57 -05:00
#
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-08-06 13:08:57 -05:00
2024-10-15 11:20:40 -04:00
if ( ROCPROFSYS_BUILD_EXAMPLES )
2023-02-27 12:09:03 -06:00
set ( CMAKE_INSTALL_DEFAULT_COMPONENT_NAME examples )
2022-01-24 20:49:17 -06:00
add_subdirectory ( examples )
endif ()
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-09-20 11:12:06 -05:00
# tests
2021-08-06 13:08:57 -05:00
#
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-08-06 13:08:57 -05:00
2024-10-15 11:20:40 -04:00
if ( ROCPROFSYS_BUILD_TESTING )
2023-02-27 12:09:03 -06:00
set ( CMAKE_INSTALL_DEFAULT_COMPONENT_NAME testing )
2022-01-24 20:49:17 -06:00
add_subdirectory ( tests )
endif ()
2021-08-06 13:29:09 -05:00
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-08-06 13:29:09 -05:00
#
2021-09-20 11:12:06 -05:00
# packaging
2021-08-06 13:29:09 -05:00
#
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-08-06 13:29:09 -05:00
2022-07-23 03:02:31 -05:00
set ( CMAKE_INSTALL_DEFAULT_COMPONENT_NAME core )
2021-08-06 13:29:09 -05:00
include ( ConfigCPack )
2021-11-23 02:53:14 -06:00
# ------------------------------------------------------------------------------#
#
# config info
#
# ------------------------------------------------------------------------------#
2024-10-15 11:20:40 -04:00
rocprofiler_systems_print_features ()