diff --git a/projects/rocprofiler-sdk/cmake/rocprofiler_config_install.cmake b/projects/rocprofiler-sdk/cmake/rocprofiler_config_install.cmake index 15fbc12f96..ee39022c39 100644 --- a/projects/rocprofiler-sdk/cmake/rocprofiler_config_install.cmake +++ b/projects/rocprofiler-sdk/cmake/rocprofiler_config_install.cmake @@ -17,7 +17,7 @@ install( set(PROJECT_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}) set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) -set(PROJECT_BUILD_TARGETS user) +set(PROJECT_BUILD_TARGETS headers shared-library) configure_package_config_file( ${PROJECT_SOURCE_DIR}/cmake/Templates/${PROJECT_NAME}-config.cmake.in diff --git a/projects/rocprofiler-sdk/cmake/rocprofiler_config_packaging.cmake b/projects/rocprofiler-sdk/cmake/rocprofiler_config_packaging.cmake index 4b10a8972a..00982fd06b 100644 --- a/projects/rocprofiler-sdk/cmake/rocprofiler_config_packaging.cmake +++ b/projects/rocprofiler-sdk/cmake/rocprofiler_config_packaging.cmake @@ -1,37 +1,6 @@ -# configure packaging - -function(rocprofiler_parse_release) - if(EXISTS /etc/lsb-release AND NOT IS_DIRECTORY /etc/lsb-release) - file(READ /etc/lsb-release _LSB_RELEASE) - if(_LSB_RELEASE) - string(REGEX - REPLACE "DISTRIB_ID=(.*)\nDISTRIB_RELEASE=(.*)\nDISTRIB_CODENAME=.*" - "\\1-\\2" _SYSTEM_NAME "${_LSB_RELEASE}") - endif() - elseif(EXISTS /etc/os-release AND NOT IS_DIRECTORY /etc/os-release) - file(READ /etc/os-release _OS_RELEASE) - if(_OS_RELEASE) - string(REPLACE "\"" "" _OS_RELEASE "${_OS_RELEASE}") - string(REPLACE "-" " " _OS_RELEASE "${_OS_RELEASE}") - string(REGEX REPLACE "NAME=.*\nVERSION=([0-9\.]+).*\nID=([a-z]+).*" "\\2-\\1" - _SYSTEM_NAME "${_OS_RELEASE}") - endif() - endif() - string(TOLOWER "${_SYSTEM_NAME}" _SYSTEM_NAME) - if(NOT _SYSTEM_NAME) - set(_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}") - endif() - set(_SYSTEM_NAME - "${_SYSTEM_NAME}" - PARENT_SCOPE) -endfunction() - -# parse either /etc/lsb-release or /etc/os-release -rocprofiler_parse_release() - -if(NOT _SYSTEM_NAME) - set(_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}") -endif() +# +# configure packaging settings +# # Add packaging directives set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) @@ -44,7 +13,7 @@ set(CPACK_PACKAGE_CONTACT "jonathan.madsen@amd.com") set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) set(ROCPROFILER_CPACK_SYSTEM_NAME - "${_SYSTEM_NAME}" + "${CMAKE_SYSTEM_NAME}" CACHE STRING "System name, e.g. Linux or Ubuntu-18.04") set(ROCPROFILER_CPACK_PACKAGE_SUFFIX "") diff --git a/projects/rocprofiler-sdk/cmake/rocprofiler_options.cmake b/projects/rocprofiler-sdk/cmake/rocprofiler_options.cmake index 6fd42db1d5..36ebf863a0 100644 --- a/projects/rocprofiler-sdk/cmake/rocprofiler_options.cmake +++ b/projects/rocprofiler-sdk/cmake/rocprofiler_options.cmake @@ -38,6 +38,8 @@ rocprofiler_add_option(ROCPROFILER_BUILD_TESTS "Enable building the tests" ${ROCPROFILER_BUILD_CI}) rocprofiler_add_option(ROCPROFILER_BUILD_SAMPLES "Enable building the code samples" ${ROCPROFILER_BUILD_CI}) +rocprofiler_add_option(ROCPROFILER_BUILD_CODECOV + "Enable building for code coverage analysis" OFF) # CLI and FILE plugins are always built foreach(_PLUGIN "ATT" "CTF" "PERFETTO") diff --git a/projects/rocprofiler-sdk/samples/api_buffered_tracing/CMakeLists.txt b/projects/rocprofiler-sdk/samples/api_buffered_tracing/CMakeLists.txt index dc0f38d3d1..03f3a0dde9 100644 --- a/projects/rocprofiler-sdk/samples/api_buffered_tracing/CMakeLists.txt +++ b/projects/rocprofiler-sdk/samples/api_buffered_tracing/CMakeLists.txt @@ -25,7 +25,7 @@ foreach(_TYPE DEBUG MINSIZEREL RELEASE RELWITHDEBINFO) endif() endforeach() -if(NOT TARGET rocprofiler::rocprofiler-library) +if(NOT TARGET rocprofiler::rocprofiler) find_package(rocprofiler REQUIRED) endif() @@ -33,7 +33,7 @@ add_library(buffered-api-tracing-client SHARED) target_sources(buffered-api-tracing-client PRIVATE client.cpp client.hpp) target_link_libraries( buffered-api-tracing-client - PRIVATE rocprofiler::rocprofiler-library + PRIVATE rocprofiler::rocprofiler $) set_source_files_properties(main.cpp PROPERTIES LANGUAGE HIP) @@ -56,5 +56,5 @@ set_tests_properties( LABELS "samples" ENVIRONMENT - "${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$" + "${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$" ) diff --git a/projects/rocprofiler-sdk/samples/api_callback_tracing/CMakeLists.txt b/projects/rocprofiler-sdk/samples/api_callback_tracing/CMakeLists.txt index c1ebcf102c..6aae451d7d 100644 --- a/projects/rocprofiler-sdk/samples/api_callback_tracing/CMakeLists.txt +++ b/projects/rocprofiler-sdk/samples/api_callback_tracing/CMakeLists.txt @@ -25,7 +25,7 @@ foreach(_TYPE DEBUG MINSIZEREL RELEASE RELWITHDEBINFO) endif() endforeach() -if(NOT TARGET rocprofiler::rocprofiler-library) +if(NOT TARGET rocprofiler::rocprofiler) find_package(rocprofiler REQUIRED) endif() @@ -33,7 +33,7 @@ add_library(callback-api-tracing-client SHARED) target_sources(callback-api-tracing-client PRIVATE client.cpp client.hpp) target_link_libraries( callback-api-tracing-client - PRIVATE rocprofiler::rocprofiler-library + PRIVATE rocprofiler::rocprofiler $) set_source_files_properties(main.cpp PROPERTIES LANGUAGE HIP) @@ -56,5 +56,5 @@ set_tests_properties( LABELS "samples" ENVIRONMENT - "${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$" + "${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$" ) diff --git a/projects/rocprofiler-sdk/samples/pc_sampling/CMakeLists.txt b/projects/rocprofiler-sdk/samples/pc_sampling/CMakeLists.txt index 091f9d9957..0ce25c5a56 100644 --- a/projects/rocprofiler-sdk/samples/pc_sampling/CMakeLists.txt +++ b/projects/rocprofiler-sdk/samples/pc_sampling/CMakeLists.txt @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.21.0 FATAL_ERROR) project(rocprofiler-samples-pc-sampling LANGUAGES C CXX) -if(NOT TARGET rocprofiler::rocprofiler-library) +if(NOT TARGET rocprofiler::rocprofiler) find_package(rocprofiler REQUIRED) endif() @@ -14,7 +14,7 @@ target_sources(pc_sampling_single-user-host-trap PRIVATE common.h single-user-host-trap.cpp) target_link_libraries( pc_sampling_single-user-host-trap - PRIVATE rocprofiler::rocprofiler-library + PRIVATE rocprofiler::rocprofiler $) add_executable(pc_sampling_single-user-host-trap-retry) @@ -22,7 +22,7 @@ target_sources(pc_sampling_single-user-host-trap-retry PRIVATE common.h single-user-host-trap-retries-service-instantiation.cpp) target_link_libraries( pc_sampling_single-user-host-trap-retry - PRIVATE rocprofiler::rocprofiler-library + PRIVATE rocprofiler::rocprofiler $) add_executable(pc_sampling_single-user-multiple-agents) @@ -30,5 +30,5 @@ target_sources(pc_sampling_single-user-multiple-agents PRIVATE common.h single-user-multiple-agents.cpp) target_link_libraries( pc_sampling_single-user-multiple-agents - PRIVATE rocprofiler::rocprofiler-library + PRIVATE rocprofiler::rocprofiler $) diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler/CMakeLists.txt b/projects/rocprofiler-sdk/source/lib/rocprofiler/CMakeLists.txt index 5af94b0ef9..ddcef22188 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler/CMakeLists.txt +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler/CMakeLists.txt @@ -8,17 +8,85 @@ set(ROCPROFILER_LIB_SOURCES buffer.cpp buffer_tracing.cpp callback_tracing.cpp context.cpp internal_threading.cpp rocprofiler.cpp registration.cpp) -add_library(rocprofiler-library SHARED) -add_library(rocprofiler::rocprofiler-library ALIAS rocprofiler-library) +# ----------------------------------------------------------------------------------------# +# +# object library allows us to compile rocprofiler code once and generate both a shared and +# static library +# +# ----------------------------------------------------------------------------------------# -target_sources(rocprofiler-library PRIVATE ${ROCPROFILER_LIB_SOURCES} - ${ROCPROFILER_LIB_HEADERS}) +add_library(rocprofiler-object-library OBJECT) +add_library(rocprofiler::rocprofiler-object-library ALIAS rocprofiler-object-library) + +target_sources(rocprofiler-object-library PRIVATE ${ROCPROFILER_LIB_SOURCES} + ${ROCPROFILER_LIB_HEADERS}) add_subdirectory(hsa) add_subdirectory(context) target_link_libraries( - rocprofiler-library + rocprofiler-object-library + PUBLIC rocprofiler::rocprofiler-headers rocprofiler::rocprofiler-hsa-runtime + rocprofiler::rocprofiler-hip + PRIVATE rocprofiler::rocprofiler-build-flags rocprofiler::rocprofiler-memcheck + rocprofiler::rocprofiler-common-library rocprofiler::rocprofiler-stdcxxfs + rocprofiler::rocprofiler-dl rocprofiler::rocprofiler-amd-comgr) + +target_compile_definitions(rocprofiler-object-library PRIVATE rocprofiler_EXPORTS=1) + +set_target_properties(rocprofiler-object-library PROPERTIES POSITION_INDEPENDENT_CODE ON) + +# ----------------------------------------------------------------------------------------# +# +# shared library +# +# ----------------------------------------------------------------------------------------# + +add_library(rocprofiler-shared-library SHARED) +add_library(rocprofiler::rocprofiler-shared-library ALIAS rocprofiler-shared-library) + +target_sources(rocprofiler-shared-library + PRIVATE $) +target_link_libraries( + rocprofiler-shared-library + INTERFACE rocprofiler::rocprofiler-headers rocprofiler::rocprofiler-hsa-runtime + rocprofiler::rocprofiler-hip + PRIVATE rocprofiler::rocprofiler-build-flags rocprofiler::rocprofiler-memcheck + rocprofiler::rocprofiler-common-library rocprofiler::rocprofiler-stdcxxfs + rocprofiler::rocprofiler-dl rocprofiler::rocprofiler-amd-comgr) + +set_target_properties( + rocprofiler-shared-library + PROPERTIES OUTPUT_NAME rocprofiler64 + SOVERSION ${PROJECT_VERSION_MAJOR} + VERSION ${PROJECT_VERSION} + SKIP_BUILD_RPATH OFF + BUILD_RPATH "\$ORIGIN" + INSTALL_RPATH "\$ORIGIN" + DEFINE_SYMBOL rocprofiler_EXPORTS) + +add_library(rocprofiler::rocprofiler-library ALIAS rocprofiler-shared-library) +add_library(rocprofiler::rocprofiler ALIAS rocprofiler-shared-library) + +install( + TARGETS rocprofiler-shared-library + DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT core + EXPORT ${PROJECT_NAME}-library-targets) + +# ----------------------------------------------------------------------------------------# +# +# static library (only built if another target links to it) +# +# ----------------------------------------------------------------------------------------# + +add_library(rocprofiler-static-library EXCLUDE_FROM_ALL STATIC) +add_library(rocprofiler::rocprofiler-static-library ALIAS rocprofiler-static-library) + +target_sources(rocprofiler-static-library + PRIVATE $) +target_link_libraries( + rocprofiler-static-library PUBLIC rocprofiler::rocprofiler-headers rocprofiler::rocprofiler-hsa-runtime rocprofiler::rocprofiler-hip PRIVATE rocprofiler::rocprofiler-build-flags rocprofiler::rocprofiler-memcheck @@ -26,15 +94,5 @@ target_link_libraries( rocprofiler::rocprofiler-dl rocprofiler::rocprofiler-amd-comgr) set_target_properties( - rocprofiler-library - PROPERTIES OUTPUT_NAME rocprofiler64 - SOVERSION ${PROJECT_VERSION_MAJOR} - VERSION ${PROJECT_VERSION} - INSTALL_RPATH "\$ORIGIN" - DEFINE_SYMBOL rocprofiler_EXPORTS) - -install( - TARGETS rocprofiler-library - DESTINATION ${CMAKE_INSTALL_LIBDIR} - COMPONENT core - EXPORT ${PROJECT_NAME}-library-targets) + rocprofiler-static-library PROPERTIES OUTPUT_NAME rocprofiler64 DEFINE_SYMBOL + rocprofiler_EXPORTS) diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler/context/CMakeLists.txt b/projects/rocprofiler-sdk/source/lib/rocprofiler/context/CMakeLists.txt index b81bfc2795..c808795820 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler/context/CMakeLists.txt +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler/context/CMakeLists.txt @@ -4,11 +4,5 @@ set(ROCPROFILER_LIB_CONFIG_SOURCES context.cpp domain.cpp) set(ROCPROFILER_LIB_CONFIG_HEADERS context.hpp domain.hpp allocator.hpp) -target_sources(rocprofiler-library PRIVATE ${ROCPROFILER_LIB_CONFIG_SOURCES} - ${ROCPROFILER_LIB_CONFIG_HEADERS}) - -# add_executable(rocr-example hsa.cpp rocr.hpp) target_link_libraries(rocr-example PRIVATE -# rocprofiler-v2) target_include_directories( rocr-example PRIVATE ${PROJECT_SOURCE_DIR} -# ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src) -# target_compile_definitions( rocr-example PRIVATE AMD_INTERNAL_BUILD PROF_API_IMPL -# HIP_PROF_HIP_API_STRING=1 __HIP_PLATFORM_AMD__=1) +target_sources(rocprofiler-object-library PRIVATE ${ROCPROFILER_LIB_CONFIG_SOURCES} + ${ROCPROFILER_LIB_CONFIG_HEADERS}) diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler/hsa/CMakeLists.txt b/projects/rocprofiler-sdk/source/lib/rocprofiler/hsa/CMakeLists.txt index 29d29b5eb5..9ac68ecac2 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler/hsa/CMakeLists.txt +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler/hsa/CMakeLists.txt @@ -4,7 +4,7 @@ set(ROCPROFILER_LIB_HSA_SOURCES hsa.cpp) set(ROCPROFILER_LIB_HSA_HEADERS hsa.hpp defines.hpp types.hpp utils.hpp) -target_sources(rocprofiler-library PRIVATE ${ROCPROFILER_LIB_HSA_SOURCES} - ${ROCPROFILER_LIB_HSA_HEADERS}) +target_sources(rocprofiler-object-library PRIVATE ${ROCPROFILER_LIB_HSA_SOURCES} + ${ROCPROFILER_LIB_HSA_HEADERS}) add_subdirectory(details) diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler/hsa/details/CMakeLists.txt b/projects/rocprofiler-sdk/source/lib/rocprofiler/hsa/details/CMakeLists.txt index 44db613fb6..a5be818157 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler/hsa/details/CMakeLists.txt +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler/hsa/details/CMakeLists.txt @@ -4,5 +4,5 @@ set(ROCPROFILER_LIB_HSA_DETAILS_SOURCES) set(ROCPROFILER_LIB_HSA_DETAILS_HEADERS ostream.hpp) -target_sources(rocprofiler-library PRIVATE ${ROCPROFILER_LIB_HSA_DETAILS_SOURCES} - ${ROCPROFILER_LIB_HSA_DETAILS_HEADERS}) +target_sources(rocprofiler-object-library PRIVATE ${ROCPROFILER_LIB_HSA_DETAILS_SOURCES} + ${ROCPROFILER_LIB_HSA_DETAILS_HEADERS}) diff --git a/projects/rocprofiler-sdk/tests/CMakeLists.txt b/projects/rocprofiler-sdk/tests/CMakeLists.txt index a898e23cd3..93f0a7e6f2 100644 --- a/projects/rocprofiler-sdk/tests/CMakeLists.txt +++ b/projects/rocprofiler-sdk/tests/CMakeLists.txt @@ -1,9 +1,3 @@ # # Integration tests # - -# placeholder test -add_test( - NAME cmake-version - COMMAND ${CMAKE_COMMAND} --version - WORKING_DIRECTORY ${PROJECT_BINARY_DIR})