Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DFT][CMake] Fix inclusion of public include directories when linking against a DFT backend library #523

Merged
merged 2 commits into from
Jul 17, 2024
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
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
mkrainiuk marked this conversation as resolved.
Show resolved Hide resolved
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}
)
hjabird marked this conversation as resolved.
Show resolved Hide resolved
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