Files
rocm-systems/projects/rocprofiler-systems/examples/causal-helpers.cmake
T

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

172 rader
5.2 KiB
CMake
Normal vy Historik

# Copyright (c) Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
2023-01-24 18:53:23 -06:00
#
# function for
#
include_guard(DIRECTORY)
if(NOT TARGET rocprofiler-systems::rocprofiler-systems-user-library)
find_package(rocprofiler-systems REQUIRED COMPONENTS user)
2023-01-24 18:53:23 -06:00
endif()
if(NOT coz-profiler_FOUND)
find_package(coz-profiler QUIET)
endif()
if(NOT TARGET rocprofsys-causal-examples)
add_custom_target(rocprofsys-causal-examples)
2023-01-24 18:53:23 -06:00
endif()
function(rocprofiler_systems_causal_example_executable _NAME)
2023-01-24 18:53:23 -06:00
cmake_parse_arguments(
2025-06-22 10:44:33 -04:00
CAUSAL
""
""
"SOURCES;DEFINITIONS;INCLUDE_DIRECTORIES;LINK_LIBRARIES"
${ARGN}
)
2023-01-24 18:53:23 -06:00
function(rocprofiler_systems_causal_example_interface _TARGET)
2023-01-24 18:53:23 -06:00
if(NOT TARGET ${_TARGET})
find_package(Threads REQUIRED)
add_library(${_TARGET} INTERFACE)
target_link_libraries(${_TARGET} INTERFACE Threads::Threads ${CMAKE_DL_LIBS})
endif()
endfunction()
rocprofiler_systems_causal_example_interface(rocprofsys-causal-example-lib-debug)
rocprofiler_systems_causal_example_interface(rocprofsys-causal-example-lib-no-debug)
2023-01-24 18:53:23 -06:00
2025-06-22 10:44:33 -04:00
target_compile_options(
rocprofsys-causal-example-lib-debug
INTERFACE -g3 -fno-omit-frame-pointer
)
target_compile_options(rocprofsys-causal-example-lib-no-debug INTERFACE -g0)
2023-01-24 18:53:23 -06:00
add_executable(${_NAME} ${CAUSAL_SOURCES})
2025-06-22 10:44:33 -04:00
target_compile_definitions(
${_NAME}
PRIVATE USE_COZ=0 USE_OMNI=0 ${CAUSAL_DEFINITIONS}
)
target_include_directories(
${_NAME}
PRIVATE ${ROCPROFSYS_EXAMPLE_ROOT_DIR}/causal ${CAUSAL_INCLUDE_DIRECTORIES}
)
2023-01-24 18:53:23 -06:00
target_link_libraries(
${_NAME}
2025-06-22 10:44:33 -04:00
PRIVATE
${CAUSAL_LINK_LIBRARIES}
rocprofiler-systems::rocprofiler-systems-user-library
rocprofsys-causal-example-lib-debug
)
2023-01-24 18:53:23 -06:00
add_executable(${_NAME}-rocprofsys ${CAUSAL_SOURCES})
2025-06-22 10:44:33 -04:00
target_compile_definitions(
${_NAME}-rocprofsys
PRIVATE USE_COZ=0 USE_OMNI=1 ${CAUSAL_DEFINITIONS}
)
target_include_directories(
2025-06-22 10:44:33 -04:00
${_NAME}-rocprofsys
PRIVATE ${ROCPROFSYS_EXAMPLE_ROOT_DIR}/causal ${CAUSAL_INCLUDE_DIRECTORIES}
)
2023-01-24 18:53:23 -06:00
target_link_libraries(
${_NAME}-rocprofsys
2025-06-22 10:44:33 -04:00
PRIVATE
${CAUSAL_LINK_LIBRARIES}
rocprofiler-systems::rocprofiler-systems-user-library
rocprofsys-causal-example-lib-debug
)
2023-01-24 18:53:23 -06:00
add_executable(${_NAME}-ndebug ${CAUSAL_SOURCES})
2025-06-22 10:44:33 -04:00
target_compile_definitions(
${_NAME}-ndebug
PRIVATE USE_COZ=0 USE_OMNI=0 ${CAUSAL_DEFINITIONS}
)
2023-01-24 18:53:23 -06:00
target_include_directories(
2025-06-22 10:44:33 -04:00
${_NAME}-ndebug
PRIVATE ${ROCPROFSYS_EXAMPLE_ROOT_DIR}/causal ${CAUSAL_INCLUDE_DIRECTORIES}
)
2023-01-24 18:53:23 -06:00
target_link_libraries(
${_NAME}-ndebug
2025-06-22 10:44:33 -04:00
PRIVATE
${CAUSAL_LINK_LIBRARIES}
rocprofiler-systems::rocprofiler-systems-user-library
rocprofsys-causal-example-lib-no-debug
)
2023-01-24 18:53:23 -06:00
add_executable(${_NAME}-rocprofsys-ndebug ${CAUSAL_SOURCES})
2025-06-22 10:44:33 -04:00
target_compile_definitions(
${_NAME}-rocprofsys-ndebug
PRIVATE USE_COZ=0 USE_OMNI=1 ${CAUSAL_DEFINITIONS}
)
2023-01-24 18:53:23 -06:00
target_include_directories(
2025-06-22 10:44:33 -04:00
${_NAME}-rocprofsys-ndebug
PRIVATE ${ROCPROFSYS_EXAMPLE_ROOT_DIR}/causal ${CAUSAL_INCLUDE_DIRECTORIES}
)
2023-01-24 18:53:23 -06:00
target_link_libraries(
${_NAME}-rocprofsys-ndebug
2025-06-22 10:44:33 -04:00
PRIVATE
${CAUSAL_LINK_LIBRARIES}
rocprofiler-systems::rocprofiler-systems-user-library
rocprofsys-causal-example-lib-no-debug
)
add_dependencies(
rocprofsys-causal-examples
${_NAME}
${_NAME}-rocprofsys
${_NAME}-ndebug
${_NAME}-rocprofsys-ndebug
)
2023-01-24 18:53:23 -06:00
if(coz-profiler_FOUND)
rocprofiler_systems_causal_example_interface(rocprofsys-causal-example-lib-coz)
2025-06-22 10:44:33 -04:00
target_compile_options(
rocprofsys-causal-example-lib-coz
INTERFACE -g3 -gdwarf-3 -fno-omit-frame-pointer
)
2023-01-24 18:53:23 -06:00
add_executable(${_NAME}-coz ${CAUSAL_SOURCES})
2025-06-22 10:44:33 -04:00
target_compile_definitions(
${_NAME}-coz
PRIVATE USE_COZ=1 USE_OMNI=0 ${CAUSAL_DEFINITIONS}
)
2023-01-24 18:53:23 -06:00
target_include_directories(
2025-06-22 10:44:33 -04:00
${_NAME}-coz
PRIVATE ${ROCPROFSYS_EXAMPLE_ROOT_DIR}/causal ${CAUSAL_INCLUDE_DIRECTORIES}
)
target_link_libraries(
2025-06-22 10:44:33 -04:00
${_NAME}-coz
PRIVATE ${CAUSAL_LINK_LIBRARIES} rocprofsys-causal-example-lib-coz coz::coz
)
2023-01-24 18:53:23 -06:00
add_dependencies(rocprofsys-causal-examples ${_NAME}-coz)
2023-01-24 18:53:23 -06:00
endif()
if(ROCPROFSYS_INSTALL_EXAMPLES)
set(_TARGETS
${_NAME}
${_NAME}-rocprofsys
${_NAME}-ndebug
${_NAME}-rocprofsys-ndebug
${_NAME}-coz
2025-06-22 10:44:33 -04:00
)
set(_EXISTING_TARGETS)
foreach(_TARGET IN LISTS _TARGETS)
if(TARGET ${_TARGET})
list(APPEND _EXISTING_TARGETS ${_TARGET})
endif()
endforeach()
if(_EXISTING_TARGETS)
install(
TARGETS ${_EXISTING_TARGETS}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/rocprofiler-systems/examples
COMPONENT rocprofiler-systems-examples
)
endif()
2023-01-24 18:53:23 -06:00
endif()
endfunction()