Skip to content

Commit

Permalink
Define optional targets as components
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadioleau committed Nov 4, 2024
1 parent 583a0f2 commit 202f347
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions cmake/DDCConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
include(CMakeFindDependencyMacro)

set(DDC_BUILD_DOUBLE_PRECISION @DDC_BUILD_DOUBLE_PRECISION@)
set(DDC_BUILD_KERNELS_FFT @DDC_BUILD_KERNELS_FFT@)
set(DDC_BUILD_KERNELS_SPLINES @DDC_BUILD_KERNELS_SPLINES@)
set(DDC_BUILD_PDI_WRAPPER @DDC_BUILD_PDI_WRAPPER@)

find_package(Kokkos 4.4...4.5)

Expand All @@ -34,9 +31,11 @@ endif()

include(${CMAKE_CURRENT_LIST_DIR}/DDCTargets.cmake)

foreach(target fft;pdi;splines)
if(TARGET DDC::ddc_${target})
add_library(DDC::${target} ALIAS DDC::ddc_${target})
# Check components
foreach(target_comp fft;pdi;splines)
if(TARGET DDC::ddc_${target_comp})
set(DDC_${target_comp}_FOUND TRUE)
add_library(DDC::${target_comp} ALIAS DDC::ddc_${target_comp})
endif()
endforeach()

Expand Down
8 changes: 4 additions & 4 deletions install_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
cmake_minimum_required(VERSION 3.22)
project(test-installed-ddc LANGUAGES CXX)

find_package(DDC REQUIRED)
find_package(DDC REQUIRED COMPONENTS fft pdi splines)

message("DDC options:")
message("DDC_BUILD_DOUBLE_PRECISION=${DDC_BUILD_DOUBLE_PRECISION}")
message("DDC_BUILD_KERNELS_FFT=${DDC_BUILD_KERNELS_FFT}")
message("DDC_BUILD_KERNELS_SPLINES=${DDC_BUILD_KERNELS_SPLINES}")
message("DDC_BUILD_PDI_WRAPPER=${DDC_BUILD_PDI_WRAPPER}")
message("DDC_fft_FOUND=${DDC_fft_FOUND}")
message("DDC_splines_FOUND=${DDC_splines_FOUND}")
message("DDC_pdi_FOUND=${DDC_pdi_FOUND}")

add_executable(main main.cpp)
target_link_libraries(main PRIVATE DDC::ddc DDC::fft DDC::pdi DDC::splines)

0 comments on commit 202f347

Please sign in to comment.