diff --git a/CMakeLists.txt b/CMakeLists.txt index 12a463b122..9b3d385870 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,6 +146,11 @@ set(THEROCM_ROCM_SYSTEMS_SOURCE_DIR_DEFAULT "${THEROCK_SOURCE_DIR}/rocm-systems" set(THEROCK_ROCM_SYSTEMS_SOURCE_DIR "${THEROCM_ROCM_SYSTEMS_SOURCE_DIR_DEFAULT}" CACHE STRING "Path to rocm-systems superrepo") cmake_path(ABSOLUTE_PATH THEROCK_ROCM_SYSTEMS_SOURCE_DIR NORMALIZE) +# Source configuration for ROCgdb. +set(THEROCK_ROCGDB_SOURCE_DIR_DEFAULT "${THEROCK_SOURCE_DIR}/debug-tools/rocgdb/source") +set(THEROCK_ROCGDB_SOURCE_DIR "${THEROCK_ROCGDB_SOURCE_DIR_DEFAULT}" CACHE STRING "Path to rocgdb's sources") +cmake_path(ABSOLUTE_PATH THEROCK_ROCGDB_SOURCE_DIR NORMALIZE) + # Allow to specify alternative source locations instead of using # repositories tracked in TheRock's `.gitmodules`. therock_enable_external_source("composable-kernel" "${THEROCK_SOURCE_DIR}/ml-libs/composable_kernel" OFF) diff --git a/debug-tools/CMakeLists.txt b/debug-tools/CMakeLists.txt index 4059c860e8..cb1c6a3aae 100644 --- a/debug-tools/CMakeLists.txt +++ b/debug-tools/CMakeLists.txt @@ -196,6 +196,10 @@ if(THEROCK_ENABLE_ROCGDB) message(WARNING "No Python with shared libpython found. rocgdb will be built without Python support.") endif() + if(NOT ${THEROCK_ROCGDB_SOURCE_DIR} STREQUAL ${THEROCK_ROCGDB_SOURCE_DIR_DEFAULT}) + message(WARNING "Configuring ROCgdb with modified source directory: ${THEROCK_ROCGDB_SOURCE_DIR}") + endif() + therock_cmake_subproject_declare(rocgdb USE_DIST_AMDGPU_TARGETS EXTERNAL_SOURCE_DIR "rocgdb" @@ -206,6 +210,7 @@ if(THEROCK_ENABLE_ROCGDB) "-DROCM_VERSION=${ROCM_MAJOR_VERSION}.${ROCM_MINOR_VERSION}.${ROCM_PATCH_VERSION}" "-DSHARED_PYTHON_EXECUTABLES=${_rocgdb_python_executables_escaped}" "-DTHEROCK_BUNDLE_SYSDEPS=${THEROCK_BUNDLE_SYSDEPS}" + "-DROCGDB_SOURCE_DIR=${THEROCK_ROCGDB_SOURCE_DIR}" COMPILER_TOOLCHAIN amd-llvm RUNTIME_DEPS diff --git a/debug-tools/rocgdb/CMakeLists.txt b/debug-tools/rocgdb/CMakeLists.txt index 723242861c..896d493b5e 100644 --- a/debug-tools/rocgdb/CMakeLists.txt +++ b/debug-tools/rocgdb/CMakeLists.txt @@ -50,6 +50,12 @@ project(rocgdb C CXX) include(ExternalProject) include(ProcessorCount) +# Allow external rocgdb source directory. +if(NOT ROCGDB_SOURCE_DIR) + set(ROCGDB_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/source") +endif() +message(STATUS "ROCgdb source directory: ${ROCGDB_SOURCE_DIR}") + # Function to extract a single path that matches a given regex pattern # from a list of paths. # @@ -229,7 +235,7 @@ macro(add_python_variant minor_version configure_flags libpython_dir) "LDFLAGS=${ALL_LDFLAGS}" -- # The actual configure command. - ${CMAKE_CURRENT_SOURCE_DIR}/source/configure + ${ROCGDB_SOURCE_DIR}/configure "--prefix=${ROCGDB_INTERMEDIATE_INSTALL_DIR}" --program-prefix=roc "--program-transform-name=${ROCGDB_PROGRAM_TRANSFORM_STR}" @@ -290,7 +296,7 @@ macro(add_python_variant minor_version configure_flags libpython_dir) COMMAND ${CMAKE_COMMAND} -E make_directory ${ROCGDB_INTERMEDIATE_INSTALL_DIR}/share/doc COMMAND - ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/source/gdb/NOTICES.txt ${ROCGDB_INTERMEDIATE_INSTALL_DIR}/share/doc/ + ${CMAKE_COMMAND} -E copy ${ROCGDB_SOURCE_DIR}/gdb/NOTICES.txt ${ROCGDB_INTERMEDIATE_INSTALL_DIR}/share/doc/ # Rename rocgcore to rocgcore-py. COMMAND ${CMAKE_COMMAND} -E rename ${ROCGDB_INTERMEDIATE_INSTALL_DIR}/bin/rocgcore ${ROCGDB_INTERMEDIATE_INSTALL_DIR}/bin/rocgcore-py${minor_version} @@ -604,7 +610,7 @@ if(BUILD_TESTING) # Get the directory part of the file. get_filename_component(file_dir ${rocgdb_file} DIRECTORY) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/source/${rocgdb_file} + install(FILES ${ROCGDB_SOURCE_DIR}/${rocgdb_file} DESTINATION tests/rocgdb/${file_dir} COMPONENT tests) endforeach() @@ -613,7 +619,7 @@ if(BUILD_TESTING) # Get the directory part of the file. get_filename_component(file_dir ${rocgdb_file} DIRECTORY) - install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/source/${rocgdb_file} + install(PROGRAMS ${ROCGDB_SOURCE_DIR}/${rocgdb_file} DESTINATION tests/rocgdb/${file_dir} COMPONENT tests) endforeach() @@ -626,7 +632,7 @@ if(BUILD_TESTING) ) foreach(rocgdb_testsuite_dir ${ROCGDB_TESTSUITE_DIRS}) - install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/source/${rocgdb_testsuite_dir} + install(DIRECTORY ${ROCGDB_SOURCE_DIR}/${rocgdb_testsuite_dir} DESTINATION tests/rocgdb/gdb COMPONENT tests USE_SOURCE_PERMISSIONS)