2
0
Ficheiros
rocm-systems/samples/common/CMakeLists.txt
T
Jonathan R. Madsen 3eaa678054 CTest Environment Update (#756)
* Update test/tools/json-tool.cpp

- push/pop ppid as external correlation id instead of pid

* Update environment variables for tests and samples

* Revert to old CDash dashboard in run-ci.py

* Revert to new CDash dashboard in run-ci.py
2024-04-12 08:40:00 -05:00

87 linhas
3.2 KiB
CMake

#
# common utilities for samples
#
# default FAIL_REGULAR_EXPRESSION for tests
set(ROCPROFILER_DEFAULT_FAIL_REGEX
"threw an exception|Permission denied|Could not create logging file"
CACHE STRING "Default FAIL_REGULAR_EXPRESSION for tests")
# build flags
add_library(rocprofiler-samples-build-flags INTERFACE)
add_library(rocprofiler::samples-build-flags ALIAS rocprofiler-samples-build-flags)
target_compile_options(rocprofiler-samples-build-flags INTERFACE -W -Wall -Wextra
-Wshadow)
target_compile_features(rocprofiler-samples-build-flags INTERFACE cxx_std_17)
if(ROCPROFILER_BUILD_CI OR ROCPROFILER_BUILD_WERROR)
target_compile_options(rocprofiler-samples-build-flags INTERFACE -Werror)
endif()
# common utilities
cmake_path(GET CMAKE_CURRENT_SOURCE_DIR PARENT_PATH COMMON_LIBRARY_INCLUDE_DIR)
add_library(rocprofiler-samples-common-library INTERFACE)
add_library(rocprofiler::samples-common-library ALIAS rocprofiler-samples-common-library)
target_link_libraries(rocprofiler-samples-common-library
INTERFACE rocprofiler::samples-build-flags)
target_compile_features(rocprofiler-samples-common-library INTERFACE cxx_std_17)
target_include_directories(rocprofiler-samples-common-library
INTERFACE ${COMMON_LIBRARY_INCLUDE_DIR})
set(EXTERNAL_SUBMODULE_DIR "${PROJECT_SOURCE_DIR}/../external")
cmake_path(ABSOLUTE_PATH EXTERNAL_SUBMODULE_DIR NORMALIZE)
if(EXISTS ${EXTERNAL_SUBMODULE_DIR}/filesystem/include/ghc/filesystem.hpp)
target_compile_definitions(
rocprofiler-samples-common-library
INTERFACE $<BUILD_INTERFACE:ROCPROFILER_SAMPLES_HAS_GHC_LIB_FILESYSTEM=1>)
target_include_directories(
rocprofiler-samples-common-library SYSTEM
INTERFACE $<BUILD_INTERFACE:${EXTERNAL_SUBMODULE_DIR}/filesystem/include>)
endif()
# function for getting the LD_PRELOAD environment variable
function(rocprofiler_samples_get_preload_env _VAR)
set(_PRELOAD_ENV_LIBS ${ROCPROFILER_MEMCHECK_PRELOAD_ENV_VALUE} $ENV{LD_PRELOAD})
foreach(_TARG ${ARGN})
if(NOT TARGET ${_TARG})
message(
FATAL_ERROR
"rocprofiler_samples_get_preload_env: '${_TARG}' is not a valid target"
)
endif()
list(APPEND _PRELOAD_ENV_LIBS $<TARGET_FILE:${_TARG}>)
endforeach()
if(_PRELOAD_ENV_LIBS)
string(REPLACE ";" ":" _PRELOAD_ENV "LD_PRELOAD=${_PRELOAD_ENV_LIBS}")
endif()
set(${_VAR}
"${_PRELOAD_ENV}"
PARENT_SCOPE)
endfunction()
# function for getting the LD_LIBRARY_PATH environment variable
function(rocprofiler_samples_get_ld_library_path_env _VAR)
set(_LDLIB_PATH "LD_LIBRARY_PATH=")
foreach(_TARG ${ARGN})
if(NOT TARGET ${_TARG})
message(
FATAL_ERROR
"rocprofiler_samples_get_ld_library_path_env: '${_TARG}' is not a valid target"
)
endif()
string(APPEND _LDLIB_PATH "$<TARGET_FILE_DIR:${_TARG}>:")
endforeach()
# append the environments current LD_LIBRARY_PATH
string(APPEND _LDLIB_PATH "$ENV{LD_LIBRARY_PATH}")
set(${_VAR}
"${_LDLIB_PATH}"
PARENT_SCOPE)
endfunction()