Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ jobs:
cmake-version:
- 3.31.0
- 3.22.1
- 3.16.3
- 3.16.3
# There are problems with nmake and ninja with this version of cmake
# on windows
exclude:
- platform: windows-2019
cmake-version: 3.10.2
- platform: windows-2022
cmake-version: 3.16.3

steps:
- uses: actions/checkout@v1
Expand All @@ -61,12 +63,22 @@ jobs:
uses: ssciwr/doxygen-install@v1
with:
version: "1.10.0"
- name: Run tests
- name: Setup git
run: |
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
cmake --version
cget build --test
cget build -T doc
cget build -Cy --test -DROCM_CMAKE_GENERATOR=Ninja
cget build -T doc

- name: Cmake version
run: cmake --version

- name: Run tests (default generator)
run: cget build --test

- name: Build docs (default generator)
run: cget build -T doc

- name: Run tests (Ninja generator)
run: cget build -Cy --test -DROCM_CMAKE_GENERATOR=Ninja

- name: Build docs (Ninja generator)
run: cget build -T doc
38 changes: 21 additions & 17 deletions share/rocmcmakebuildtools/cmake/ROCMClangTidy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -192,24 +192,26 @@ function(rocm_clang_tidy_check TARGET)
add_custom_target(tidy-target-${TARGET})
foreach(SOURCE ${SOURCES})
if(NOT "${SOURCE}" MATCHES "(h|hpp|hxx)$")
string(MAKE_C_IDENTIFIER "${SOURCE}" tidy_file)
get_filename_component(SRC_ABS ${SOURCE} ABSOLUTE)
string(FIND ${SRC_ABS} ${CMAKE_CURRENT_BINARY_DIR} BINARY_IDX)
if(BINARY_IDX EQUAL -1)
set(tidy_file_prefix "s")
set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
else()
set(tidy_file_prefix "b")
set(ROOT_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
get_filename_component(SRC_PATH ${SRC_ABS} DIRECTORY)
file(RELATIVE_PATH REL_PATH ${ROOT_DIR} ${SRC_PATH})
get_filename_component(BASE_SOURCE_NAME ${SOURCE} NAME_WE)
if(REL_PATH)
set(BASE_SOURCE ${REL_PATH}/${BASE_SOURCE_NAME})
else()
set(BASE_SOURCE ${BASE_SOURCE_NAME})
endif()
string(MAKE_C_IDENTIFIER "${tidy_file_prefix}/${BASE_SOURCE}" tidy_file)
set(tidy_target tidy-target-${TARGET}-${tidy_file})
if(CLANG_TIDY_CACHE_SIZE GREATER 0)
get_filename_component(SRC_ABS ${SOURCE} ABSOLUTE)
string(FIND ${SRC_ABS} ${CMAKE_CURRENT_BINARY_DIR} BINARY_IDX)
if(BINARY_IDX EQUAL -1)
set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
else()
set(ROOT_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
get_filename_component(SRC_PATH ${SRC_ABS} DIRECTORY)
file(RELATIVE_PATH REL_PATH ${ROOT_DIR} ${SRC_PATH})
get_filename_component(BASE_SOURCE_NAME ${SOURCE} NAME_WE)
if(REL_PATH)
set(BASE_SOURCE ${REL_PATH}/${BASE_SOURCE_NAME})
else()
set(BASE_SOURCE ${BASE_SOURCE_NAME})
endif()
file(
WRITE ${CMAKE_CURRENT_BINARY_DIR}/${tidy_target}.cmake
"
Expand All @@ -236,7 +238,9 @@ function(rocm_clang_tidy_check TARGET)
endif()
return()
endif()
string(REPLACE \"Preprocessing CXX source to \" \"\" PP_FILE \"\${PP_OUT}\")
# Filter out the message so it can handle verbose output
string(REGEX MATCH \"Preprocessing CXX source to [^\\n]*\\\\.i\\n\" PP_SELECT_OUT \"\${PP_OUT}\")
string(REPLACE \"Preprocessing CXX source to \" \"\" PP_FILE \"\${PP_SELECT_OUT}\")
string(STRIP \"\${PP_FILE}\" PP_FILE)
file(MD5 ${CMAKE_CURRENT_BINARY_DIR}/\${PP_FILE} PP_HASH)
execute_process(
Expand Down
2 changes: 1 addition & 1 deletion share/rocmcmakebuildtools/cmake/ROCMCppCheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ macro(rocm_enable_cppcheck)
# cmake-lint: disable=C0301
set(CPPCHECK_TEMPLATE_ARG
"--template=::warning file={file},line={line},col={column}::{severity}: {inconclusive:inconclusive: }{message} [{id}]"
"--template-location={file}:{line}:{column}: note: {info}\\\n{code}")
"--template-location={file}:{line}:{column}: note: {info}\\n{code}")
endif()

set(CPPCHECK_COMMAND
Expand Down
12 changes: 12 additions & 0 deletions share/rocmcmakebuildtools/cmake/ROCMCreatePackage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,18 @@ macro(rocm_create_package)
# Lintian Warning Fix: Enable post/pre scripts only if non empty
rocm_check_and_configure_script_files("${PROJECT_BINARY_DIR}/debian/prerm" "${PROJECT_BINARY_DIR}/debian/postinst")

# Create a CPack project config file for generator-specific settings
set(_cpack_project_config "${PROJECT_BINARY_DIR}/CPackProjectConfig.cmake")
file(WRITE "${_cpack_project_config}" "
# Generator-specific configuration for consistent archive paths
if(CPACK_GENERATOR MATCHES \"TGZ|ZIP\")
# Use relative paths for archive generators (consistent across platforms)
set(CPACK_SET_DESTDIR OFF)
set(CPACK_PACKAGING_INSTALL_PREFIX \"/\")
endif()
")
set(CPACK_PROJECT_CONFIG_FILE "${_cpack_project_config}")

include(CPack)
set(ROCM_PACKAGE_CREATED TRUE CACHE INTERNAL "Track whether rocm_create_package has been called.")
endmacro()
Expand Down
2 changes: 1 addition & 1 deletion share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ function(rocm_export_targets)
set(CONFIG_NAME ${PACKAGE_NAME_LOWER}-config)
set(TARGET_VERSION ${PROJECT_VERSION})

if(PARSE_PREFIX)
if(PARSE_PREFIX AND NOT WIN32)
set(PREFIX_DIR ${PARSE_PREFIX})
set(PREFIX_ARG PREFIX ${PREFIX_DIR})
set(BIN_INSTALL_DIR ${PREFIX_DIR}/${CMAKE_INSTALL_BINDIR})
Expand Down
27 changes: 19 additions & 8 deletions share/rocmcmakebuildtools/cmake/ROCMTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -j ${
add_custom_target(tests COMMENT "Build all tests.")
add_dependencies(check tests)

add_custom_target(install-tests COMMAND ${CMAKE_COMMAND} -DCOMPONENT=tests -P ${CMAKE_BINARY_DIR}/cmake_install.cmake)
add_custom_target(install-tests COMMAND ${CMAKE_COMMAND} -DCOMPONENT=tests -DCMAKE_INSTALL_CONFIG_NAME=$<CONFIG> -P
${CMAKE_BINARY_DIR}/cmake_install.cmake)
add_dependencies(install-tests tests)

rocm_define_property(TARGET "ROCM_TEST_INSTALLDIR" "Install dir for tests")
macro(rocm_enable_test_package NAME)
message(STATUS "Enable test package ${NAME}")
set_target_properties(tests PROPERTIES ROCM_TEST_INSTALLDIR ${CMAKE_INSTALL_PREFIX}/libexec/installed-tests/${NAME})
set_target_properties(tests PROPERTIES ROCM_TEST_INSTALLDIR ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/${NAME})
rocm_package_setup_component(tests DEPENDS COMPONENT runtime)
rocm_defer(rocm_test_install_ctest)
endmacro()
Expand Down Expand Up @@ -89,9 +90,9 @@ function(rocm_save_test)
set(COMMAND "")
foreach(ARG ${PARSE_COMMAND})
if(TARGET ${ARG})
set(INSTALL_PREFIX "$<${_rocm_test_genex_eval}:$<TARGET_PROPERTY:${ARG},ROCM_INSTALL_DIR>>")
string(APPEND COMMAND
" \"${INSTALL_PREFIX}/$<TARGET_FILE_NAME:${ARG}>\"")
set(INSTALL_PREFIX
"${CMAKE_INSTALL_PREFIX}/$<${_rocm_test_genex_eval}:$<TARGET_PROPERTY:${ARG},ROCM_INSTALL_DIR>>")
string(APPEND COMMAND " \"${INSTALL_PREFIX}/$<TARGET_FILE_NAME:${ARG}>\"")
else()
string(APPEND COMMAND " \"${ARG}\"")
endif()
Expand Down Expand Up @@ -159,7 +160,11 @@ function(rocm_add_test)
set(COMMAND_ARGS ${COMMAND})
list(REMOVE_AT COMMAND_ARGS 0)

if(ROCM_TEST_GDB AND TARGET ${COMMAND_EXE})
get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)

if(NOT IS_MULTI_CONFIG
AND ROCM_TEST_GDB
AND TARGET ${COMMAND_EXE})
set(TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/gdb/test_${PARSE_NAME})
file(MAKE_DIRECTORY ${TEST_DIR})
if(NOT EXISTS ${TEST_DIR})
Expand Down Expand Up @@ -221,9 +226,15 @@ function(rocm_install_test)
set(INSTALL_PREFIX "$<TARGET_PROPERTY:tests,ROCM_TEST_INSTALLDIR>")
if(PARSE_TARGETS)
foreach(TARGET ${PARSE_TARGETS})
set_property(TARGET ${TARGET} APPEND PROPERTY INSTALL_RPATH "$ORIGIN/../../../../lib")
set_property(
TARGET ${TARGET}
APPEND
PROPERTY INSTALL_RPATH "$ORIGIN/../../../../lib")
# Adding RPATH to public tests to point to private libraries.
set_property(TARGET ${TARGET} APPEND PROPERTY INSTALL_RPATH "$ORIGIN/../../../../lib/${PROJECT_NAME}/lib")
set_property(
TARGET ${TARGET}
APPEND
PROPERTY INSTALL_RPATH "$ORIGIN/../../../../lib/${PROJECT_NAME}/lib")
endforeach()
install(
TARGETS ${PARSE_TARGETS}
Expand Down
10 changes: 6 additions & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ macro(rocm_cmake_add_test_argument CMAKE_VAR VAR_TYPE DOC_STRING)
endif()
endmacro()

rocm_cmake_add_test_argument(CMAKE_MAKE_PROGRAM FILEPATH "Make program to relay to test projects")
rocm_cmake_add_test_argument(CMAKE_GENERATOR STRING "Generator to relay to test projects")
rocm_cmake_add_test_argument(CMAKE_GENERATOR_INSTANCE STRING "Generator instance to relay to test projects")
rocm_cmake_add_test_argument(CMAKE_GENERATOR_PLATFORM STRING "Generator platform to relay to test projects")
rocm_cmake_add_test_argument(CMAKE_GENERATOR_TOOLSET STRING "Generator toolset to relay to test projects")
rocm_cmake_add_test_argument(CMAKE_PREFIX_PATH PATH "Prefix path to relay to test projects")
rocm_cmake_add_test_argument(CMAKE_PROGRAM_PATH PATH "Program path to relay to test projects")
if(ROCM_CMAKE_GENERATOR STREQUAL "${CMAKE_GENERATOR}")
rocm_cmake_add_test_argument(CMAKE_GENERATOR_INSTANCE STRING "Generator instance to relay to test projects")
rocm_cmake_add_test_argument(CMAKE_GENERATOR_PLATFORM STRING "Generator platform to relay to test projects")
rocm_cmake_add_test_argument(CMAKE_GENERATOR_TOOLSET STRING "Generator toolset to relay to test projects")
rocm_cmake_add_test_argument(CMAKE_MAKE_PROGRAM FILEPATH "Make program to relay to test projects")
endif()

function(rocm_cmake_create_test NAME TEST)
add_custom_target(${NAME} COMMAND ${CMAKE_COMMAND} ${TEST_ARGUMENTS} -P ${CMAKE_CURRENT_SOURCE_DIR}/test.cmake ${TEST} ${CMAKE_CURRENT_BINARY_DIR}/tmp/${NAME})
Expand Down
10 changes: 8 additions & 2 deletions test/analyze/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ rocm_enable_cppcheck(
threadsafety
)

# Workaround clangTooling issue: https://github.com/llvm/llvm-project/issues/100909
if(NOT MSVC)
add_compile_options(-Wno-unused-command-line-argument)
endif()

rocm_setup_version(VERSION 1.0.0)

configure_file(simple2.cpp.in simple2.cpp)
configure_file(simple2.cpp.in simple.cpp)
configure_file(simple_with_a_ridiculously_long_filename_in_order_to_test_long_filenames_in_clang_tidy_cmake.cpp.in simple_with_a_ridiculously_long_filename_in_order_to_test_long_filenames_in_clang_tidy_cmake.cpp)

add_library(simple simple.cpp ${CMAKE_CURRENT_BINARY_DIR}/simple2.cpp)
add_library(simple simple.cpp ${CMAKE_CURRENT_BINARY_DIR}/simple_with_a_ridiculously_long_filename_in_order_to_test_long_filenames_in_clang_tidy_cmake.cpp ${CMAKE_CURRENT_BINARY_DIR}/simple.cpp)
rocm_install_targets(TARGETS simple INCLUDE include)


Expand Down
2 changes: 2 additions & 0 deletions test/analyze/include/simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#define GUARD_SIMPLE_H

void simple();
void simple2();
void simple_long();


#endif
1 change: 1 addition & 0 deletions test/analyze/simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright (C) 2017 Advanced Micro Devices, Inc.
******************************************************************************/

#include <simple.h>

void simple()
{}
1 change: 1 addition & 0 deletions test/analyze/simple2.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright (C) 2020 Advanced Micro Devices, Inc.
******************************************************************************/

#include <simple.h>

void simple2()
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*******************************************************************************
* Copyright (C) 2017 Advanced Micro Devices, Inc.
******************************************************************************/

#include <simple.h>

void simple_long()
{}
2 changes: 1 addition & 1 deletion test/fail/wrapper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (C) 2022 Advanced Micro Devices, Inc.
# ######################################################################################################################

if(NOT MSVC)
if(NOT WIN32)
install_dir(${TEST_DIR}/libwrapper
CMAKE_ARGS -DBUILD_SHARED_LIBS=On -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=On -DERR_ON_WARN=ON)
test_check_package(
Expand Down
15 changes: 12 additions & 3 deletions test/pass/analyze-gh.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@
# Copyright (C) 2020 Advanced Micro Devices, Inc.
# ######################################################################################################################

install_dir(${TEST_DIR}/analyze TARGETS analyze analyze)
if(WIN32)
install_dir(${TEST_DIR}/analyze)

install_dir(
${TEST_DIR}/analyze
CMAKE_ARGS -DCLANG_TIDY_CACHE_SIZE=0 -DROCM_ENABLE_GH_ANNOTATIONS=On
TARGETS analyze analyze)
CMAKE_ARGS -DCLANG_TIDY_CACHE_SIZE=0 -DROCM_ENABLE_GH_ANNOTATIONS=On)

else()
install_dir(${TEST_DIR}/analyze TARGETS analyze analyze)

install_dir(
${TEST_DIR}/analyze
CMAKE_ARGS -DCLANG_TIDY_CACHE_SIZE=0 -DROCM_ENABLE_GH_ANNOTATIONS=On
TARGETS analyze analyze)
endif()
18 changes: 13 additions & 5 deletions test/pass/analyze.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@
# Copyright (C) 2017 Advanced Micro Devices, Inc.
# ######################################################################################################################

install_dir(${TEST_DIR}/analyze TARGETS analyze analyze)
if(WIN32)
install_dir(${TEST_DIR}/analyze)

install_dir(
${TEST_DIR}/analyze
CMAKE_ARGS -DCLANG_TIDY_CACHE_SIZE=0
TARGETS analyze analyze)
install_dir(
${TEST_DIR}/analyze
CMAKE_ARGS -DCLANG_TIDY_CACHE_SIZE=0)
else()
install_dir(${TEST_DIR}/analyze TARGETS analyze analyze)

install_dir(
${TEST_DIR}/analyze
CMAKE_ARGS -DCLANG_TIDY_CACHE_SIZE=0
TARGETS analyze analyze)
endif()
9 changes: 7 additions & 2 deletions test/pass/libprivate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ install_dir(
${TEST_DIR}/libprivate
CMAKE_ARGS -DROCM_SYMLINK_LIBS=OFF -DROCM_PREFIX=rocm
TARGETS package)
test_expect_file(${PREFIX}/lib/libprivate/include/simpleprivate.h)
test_expect_file(${PREFIX}/lib/libprivate/lib/libsimple_private.a)
if(WIN32)
test_expect_file(${PREFIX}/include/simpleprivate.h)
test_expect_file(${PREFIX}/lib/simple_private.lib)
else()
test_expect_file(${PREFIX}/lib/libprivate/include/simpleprivate.h)
test_expect_file(${PREFIX}/lib/libprivate/lib/libsimple_private.a)
endif()
install_dir(${TEST_DIR}/libprivate)
4 changes: 3 additions & 1 deletion test/pass/simple-prefix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ install_dir(
CMAKE_ARGS -DROCM_PREFIX=simple
TARGETS package)
test_expect_file(${PREFIX}/include/simple.h)
test_expect_file(${PREFIX}/simple/include/simple.h)
if(NOT WIN32)
test_expect_file(${PREFIX}/simple/include/simple.h)
endif()
install_dir(${TEST_DIR}/libbasic)
2 changes: 1 addition & 1 deletion test/pass/simple-test-package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ file(GLOB TEST_PACKAGE ${BUILD_DIR}/*-tests.tar.gz)
list(LENGTH TEST_PACKAGE NTEST_PACKAGE)
test_expect_eq(${NTEST_PACKAGE} 1)
test_exec(COMMAND ${CMAKE_COMMAND} -E tar t ${TEST_PACKAGE})
test_exec(COMMAND ${CMAKE_COMMAND} -E tar x ${TEST_PACKAGE} WORKING_DIRECTORY /)
test_exec(COMMAND ${CMAKE_COMMAND} -E tar x ${TEST_PACKAGE} WORKING_DIRECTORY ${PREFIX})
test_expect_file(${PREFIX}/libexec/installed-tests/simple/CTestTestfile.cmake)
19 changes: 16 additions & 3 deletions test/test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ macro(test_exec)
string(REPLACE "|" "\;" REAL_EXEC_COMMAND "${ARGN}")
execute_process(${REAL_EXEC_COMMAND} RESULT_VARIABLE test_exec_RESULT)
if(NOT test_exec_RESULT EQUAL 0)
message(FATAL_ERROR "Process failed: ${EXEC_COMMAND}")
# Build a quoted command string that shows argument boundaries clearly
set(test_exec_quoted_cmd "")
foreach(test_exec_arg ${ARGN})
string(APPEND test_exec_quoted_cmd "\"${test_exec_arg}\" ")
endforeach()

message(FATAL_ERROR "Process failed with exit code: ${test_exec_RESULT}\n" "Command: ${test_exec_quoted_cmd}\n")
endif()
endmacro()

Expand All @@ -107,7 +113,12 @@ function(configure_dir DIR)
cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

string(RANDOM BUILD_RAND)
set(BUILD_DIR ${BUILDS_DIR}/${BUILD_RAND})
if(WIN32)
set(BUILD_DIR ${BUILDS_DIR}/${BUILD_RAND})
else()
set(LONG_PATH "longer_pathname_so_that_rpms_can_support_packaging_the_debug_info_for_all_os_profiles")
set(BUILD_DIR ${BUILDS_DIR}/${BUILD_RAND}/${LONG_PATH}/src/out/some-os-version/version/build/rocm-cmake/build)
endif()
if(NOT EXISTS ${BUILD_DIR})
file(MAKE_DIRECTORY ${BUILD_DIR})
endif()
Expand All @@ -123,7 +134,9 @@ function(configure_dir DIR)
endforeach()

if(PARSE_BUILD_DIR_VAR)
set(${PARSE_BUILD_DIR_VAR} ${BUILD_DIR} PARENT_SCOPE)
set(${PARSE_BUILD_DIR_VAR}
${BUILD_DIR}
PARENT_SCOPE)
else()
file(REMOVE_RECURSE ${BUILD_DIR})
endif()
Expand Down
Loading