Skip to content

Commit

Permalink
Fix incorrect usage of CMAKE_{SOURCE,BINARY}_DIR (#90)
Browse files Browse the repository at this point in the history
When importing cudnn-frontend as a 3rd party library using FetchContent,
cmake incorrectly parse the file path. This is because we incorrectly using
CMAKE_SOURCE_DIR variable, which should be PROJECT_SOURCE_DIR (The former one
refers to the top-level source directory that contains a CMakeLists.txt, while
the latter refers to the source directory of the most recent project() command
  • Loading branch information
junaire authored Jul 31, 2024
1 parent 98ca4e1 commit 019bab6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ FetchContent_MakeAvailable(dlpack)
find_package(Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED)

# Find cudnn
include(${CMAKE_SOURCE_DIR}/cmake/cuDNN.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/cuDNN.cmake)

option(CUDNN_FRONTEND_FETCH_PYBINDS_IN_CMAKE "Whether cmake build system should fetch pybinds." ON)
if(CUDNN_FRONTEND_FETCH_PYBINDS_IN_CMAKE)
Expand Down Expand Up @@ -81,7 +81,7 @@ set_target_properties(
_compiled_module

PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/cudnn
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/cudnn
)
file(COPY ${CMAKE_SOURCE_DIR}/python/cudnn DESTINATION ${CMAKE_BINARY_DIR})
file(COPY ${PROJECT_SOURCE_DIR}/python/cudnn DESTINATION ${PROJECT_BINARY_DIR})
endif()
4 changes: 2 additions & 2 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if(NOT Catch2_FOUND)
endif()

# Find cudnn
include(${CMAKE_SOURCE_DIR}/cmake/cuDNN.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/cuDNN.cmake)

add_executable(
samples
Expand Down Expand Up @@ -107,7 +107,7 @@ set_target_properties(
samples
PROPERTIES
LINK_WHAT_YOU_USE TRUE
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
)

set_source_files_properties(
Expand Down
2 changes: 1 addition & 1 deletion test/unit_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ set_target_properties(
unit_tests
PROPERTIES
LINK_WHAT_YOU_USE TRUE
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
)

0 comments on commit 019bab6

Please sign in to comment.