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
7 changes: 5 additions & 2 deletions libclc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ if( LIBCLC_STANDALONE_BUILD OR CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DI

# Setup the paths where libclc runtimes should be stored.
set( LIBCLC_OUTPUT_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
set( LIBCLC_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/clc )
else()
# In-tree configuration
set( LIBCLC_STANDALONE_BUILD FALSE )
Expand All @@ -100,10 +101,12 @@ else()
# Setup the paths where libclc runtimes should be stored. By default, in an
# in-tree build we place the libraries in clang's resource driectory.
include(GetClangResourceDir)
get_clang_resource_dir( LIBCLC_OUTPUT_DIR PREFIX ${LLVM_LIBRARY_OUTPUT_INTDIR}/.. )
get_clang_resource_dir( LIBCLC_INSTALL_DIR )
cmake_path( APPEND LIBCLC_INSTALL_DIR "lib" "libclc" )

# Note we do not adhere to LLVM_ENABLE_PER_TARGET_RUNTIME_DIR.
set( LIBCLC_OUTPUT_LIBRARY_DIR ${LIBCLC_OUTPUT_DIR}/lib/libclc )
cmake_path( GET LLVM_LIBRARY_OUTPUT_INTDIR PARENT_PATH LIBCLC_OUTPUT_LIBRARY_DIR )
cmake_path( APPEND LIBCLC_OUTPUT_LIBRARY_DIR ${LIBCLC_INSTALL_DIR} )
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appending an (likely) absolute path ${LIBCLC_INSTALL_DIR} (after line 107) to LIBCLC_OUTPUT_LIBRARY_DIR (line 109) can discard the earlier parent path per cmake_path APPEND semantics when an absolute component is used, resulting in LIBCLC_OUTPUT_LIBRARY_DIR incorrectly mirroring the install directory. If the intent is to place build artifacts under the build tree while installing to the resource dir, compute a separate resource path (e.g., get_clang_resource_dir with PREFIX for build output) or append only relative components (lib, libclc) instead of the full absolute path.

Suggested change
cmake_path( APPEND LIBCLC_OUTPUT_LIBRARY_DIR ${LIBCLC_INSTALL_DIR} )
cmake_path( APPEND LIBCLC_OUTPUT_LIBRARY_DIR "lib" "libclc" )

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appending an (likely) absolute path ${LIBCLC_INSTALL_DIR}

not true, get_clang_resource_dir always returns a relative path

file( MAKE_DIRECTORY ${LIBCLC_OUTPUT_LIBRARY_DIR} )
endif()

Expand Down
2 changes: 1 addition & 1 deletion libclc/cmake/modules/AddLibclc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function(libclc_install)

install(
FILES ${files}
DESTINATION "${CMAKE_INSTALL_DATADIR}/clc"
DESTINATION ${LIBCLC_INSTALL_DIR}
)
endfunction()

Expand Down
Loading