Skip to content

Commit

Permalink
[DFT][CMake] Fix inclusion of public include directories when linking…
Browse files Browse the repository at this point in the history
… against a DFT backend library (#523)

* Using the DFT backend targets should include the public include directories.
  • Loading branch information
hjabird authored Jul 17, 2024
1 parent 60bd6d1 commit 30aedaf
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 22 deletions.
16 changes: 7 additions & 9 deletions examples/dft/compile_time_dispatching/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,17 @@ foreach(dft_ct_source ${DFT_CT_SOURCES})
add_executable(${EXAMPLE_NAME} ${dft_ct_source}.cpp)
target_include_directories(${EXAMPLE_NAME}
PUBLIC ${PROJECT_SOURCE_DIR}/examples/include
PUBLIC ${PROJECT_SOURCE_DIR}/include
PUBLIC ${CMAKE_BINARY_DIR}/bin
)

if(domain STREQUAL "dft" AND ENABLE_MKLCPU_BACKEND AND ENABLE_CUFFT_BACKEND)
add_dependencies(${EXAMPLE_NAME} onemkl_${domain}_mklcpu onemkl_${domain}_cufft)
list(APPEND ONEMKL_LIBRARIES_${domain} onemkl_${domain}_mklcpu onemkl_${domain}_cufft)
endif()
if(domain STREQUAL "dft" AND ENABLE_MKLCPU_BACKEND AND ENABLE_CUFFT_BACKEND)
add_dependencies(${EXAMPLE_NAME} onemkl_${domain}_mklcpu onemkl_${domain}_cufft)
list(APPEND ONEMKL_LIBRARIES_${domain} onemkl_${domain}_mklcpu onemkl_${domain}_cufft)
endif()

target_link_libraries(${EXAMPLE_NAME} PUBLIC
${ONEMKL_LIBRARIES_${domain}}
ONEMKL::SYCL::SYCL
onemkl_warnings
target_link_libraries(${EXAMPLE_NAME} PUBLIC
${ONEMKL_LIBRARIES_${domain}}
onemkl_warnings
)

# Register example as ctest
Expand Down
11 changes: 8 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ set(ENABLE_PORTBLAS_BACKEND_NVIDIA_GPU OFF CACHE INTERNAL "")
# store path to CMAKE_CURRENT_BINARY_DIR to use it later (makes FetchContent_Declare workable)
set(ONEMKL_GENERATED_INCLUDE_PATH ${CMAKE_CURRENT_BINARY_DIR})


set(ONEMKL_INTERFACE_INCLUDE_DIRS
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
)

# Build loader and backends for each domain
add_custom_target(onemkl_backend_libs)
foreach(domain ${TARGET_DOMAINS})
Expand Down Expand Up @@ -60,9 +67,7 @@ if(BUILD_SHARED_LIBS)
add_dependencies(onemkl onemkl_backend_libs)

target_include_directories(onemkl
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
PUBLIC ${ONEMKL_INTERFACE_INCLUDE_DIRS}
)
set_target_properties(onemkl PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
Expand Down
9 changes: 7 additions & 2 deletions src/dft/backends/cufft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ add_library(${LIB_OBJ} OBJECT
add_dependencies(onemkl_backend_libs_dft ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
PUBLIC ${ONEMKL_INTERFACE_INCLUDE_DIRS}
)
target_include_directories(${LIB_NAME}
PUBLIC ${ONEMKL_INTERFACE_INCLUDE_DIRS}
)
target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/bin
${ONEMKL_GENERATED_INCLUDE_PATH}
)
Expand Down
10 changes: 8 additions & 2 deletions src/dft/backends/mklcpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ add_library(${LIB_OBJ} OBJECT
add_dependencies(onemkl_backend_libs_dft ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
PUBLIC ${ONEMKL_INTERFACE_INCLUDE_DIRS}
)
target_include_directories(${LIB_NAME}
PUBLIC ${ONEMKL_INTERFACE_INCLUDE_DIRS}
)

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/bin
${ONEMKL_GENERATED_INCLUDE_PATH}
)
Expand Down
9 changes: 7 additions & 2 deletions src/dft/backends/mklgpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ add_library(${LIB_OBJ} OBJECT
add_dependencies(onemkl_backend_libs_dft ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
PUBLIC ${ONEMKL_INTERFACE_INCLUDE_DIRS}
)
target_include_directories(${LIB_NAME}
PUBLIC ${ONEMKL_INTERFACE_INCLUDE_DIRS}
)
target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/bin
${ONEMKL_GENERATED_INCLUDE_PATH}
)
Expand Down
9 changes: 7 additions & 2 deletions src/dft/backends/portfft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,13 @@ endif()
target_link_libraries(${LIB_OBJ} PRIVATE onemkl_warnings)

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
PUBLIC ${ONEMKL_INTERFACE_INCLUDE_DIRS}
)
target_include_directories(${LIB_NAME}
PUBLIC ${ONEMKL_INTERFACE_INCLUDE_DIRS}
)
target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/bin
)

Expand Down
9 changes: 7 additions & 2 deletions src/dft/backends/rocfft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ add_library(${LIB_OBJ} OBJECT
add_dependencies(onemkl_backend_libs_dft ${LIB_NAME})

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
PUBLIC ${ONEMKL_INTERFACE_INCLUDE_DIRS}
)
target_include_directories(${LIB_NAME}
PUBLIC ${ONEMKL_INTERFACE_INCLUDE_DIRS}
)
target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/bin
${ONEMKL_GENERATED_INCLUDE_PATH}
)
Expand Down

0 comments on commit 30aedaf

Please sign in to comment.