Skip to content

Commit

Permalink
CMake: Redesign targets
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Dec 16, 2024
1 parent 64f9397 commit 33c57cb
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 80 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ target_compile_options(
$<$<CXX_COMPILER_ID:Clang,AppleClang,IntelLLVM>:-Wimplicit-float-conversion>
$<$<CXX_COMPILER_ID:Clang,AppleClang,IntelLLVM>:-Wunused-exception-parameter>
$<$<CXX_COMPILER_ID:Clang,AppleClang,IntelLLVM>:-Wmissing-variable-declarations>
$<$<AND:$<CXX_COMPILER_ID:Clang>,$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,11.0.0>>:-Wnon-c-typedef-for-linkage>
$<$<CXX_COMPILER_ID:Clang>:-Wnon-c-typedef-for-linkage>
$<$<NOT:$<CXX_COMPILER_ID:Intel>>:-Wdelete-non-virtual-dtor>
# disable warnings from -Wall and -Wextra
-Wno-sign-compare
Expand All @@ -494,9 +494,9 @@ target_compile_options(
-Wno-array-bounds
$<$<CXX_COMPILER_ID:GNU>:-Wno-restrict>
$<$<CXX_COMPILER_ID:GNU>:-Wno-clobbered>
$<$<CXX_COMPILER_ID:GNU>:-Wno-cast-function-type>
$<$<CXX_COMPILER_ID:Intel,IntelLLVM>:-diag-disable=592>
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Wno-gnu-zero-variadic-macro-arguments>
$<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,8.1.0>>:-Wno-cast-function-type>
$<$<NOT:$<CXX_COMPILER_ID:Intel,IntelLLVM>>:-Wno-implicit-fallthrough>
$<$<NOT:$<CXX_COMPILER_ID:Intel,IntelLLVM,GNU>>:-Wno-unused-private-field>
# warnings are errors
Expand Down Expand Up @@ -694,7 +694,8 @@ if(ESPRESSO_BUILD_WITH_CALIPER)
target_compile_options(
caliper-runtime
PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wno-maybe-uninitialized>
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Wno-volatile>)
$<$<CXX_COMPILER_ID:GNU>:-Wno-volatile>
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Wno-deprecated-volatile>)
endif()

#
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ add_subdirectory(utils)
add_subdirectory(shapes)
add_subdirectory(core)
add_subdirectory(config)
add_subdirectory(profiler)
add_subdirectory(instrumentation)

if(ESPRESSO_BUILD_WITH_SCAFACOS)
add_subdirectory(scafacos)
Expand Down
2 changes: 1 addition & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ target_link_libraries(
espresso_core PRIVATE espresso::config espresso::utils::mpi espresso::shapes
espresso::cpp_flags
PUBLIC espresso::utils MPI::MPI_CXX Random123 espresso::particle_observables
Boost::serialization Boost::mpi espresso::profiler)
Boost::serialization Boost::mpi espresso::instrumentation)

target_include_directories(espresso_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

Expand Down
19 changes: 7 additions & 12 deletions src/profiler/CMakeLists.txt → src/instrumentation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2019-2022 The ESPResSo project
# Copyright (C) 2019-2024 The ESPResSo project
#
# This file is part of ESPResSo.
#
Expand All @@ -17,22 +17,17 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

add_library(espresso_profiler INTERFACE)
add_library(espresso::profiler ALIAS espresso_profiler)
add_library(espresso_instrumentation INTERFACE)
add_library(espresso::instrumentation ALIAS espresso_instrumentation)

if(ESPRESSO_BUILD_WITH_VALGRIND)
target_include_directories(espresso_profiler
target_include_directories(espresso_instrumentation
INTERFACE "${VALGRIND_INCLUDE_DIRS}")
endif()

if(ESPRESSO_BUILD_WITH_CALIPER)
target_link_libraries(espresso_profiler INTERFACE caliper)
# workaround to handle the case where the build directory is outside `_deps`
cmake_path(GET CMAKE_BINARY_DIR FILENAME CMAKE_BINARY_DIR_BASENAME)
set(caliper_BINARY_DIR_ALTERNATIVE
"${CMAKE_BINARY_DIR}/${CMAKE_BINARY_DIR_BASENAME}/_deps/caliper-src")
target_link_libraries(espresso_instrumentation INTERFACE caliper)
target_include_directories(
espresso_profiler
INTERFACE "${caliper_SOURCE_DIR}/include" "${caliper_BINARY_DIR}/include"
"${caliper_BINARY_DIR_ALTERNATIVE}/include")
espresso_instrumentation
INTERFACE "${caliper_SOURCE_DIR}/include" "${caliper_BINARY_DIR}/include")
endif()
2 changes: 1 addition & 1 deletion src/script_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ install(TARGETS espresso_script_interface

target_link_libraries(
espresso_script_interface PRIVATE espresso::config espresso::core
espresso::profiler
espresso::instrumentation
PUBLIC espresso::utils MPI::MPI_CXX Boost::mpi espresso::shapes
PRIVATE espresso::cpp_flags)

Expand Down
43 changes: 28 additions & 15 deletions src/walberla_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

function(espresso_configure_walberla_target)
set(TARGET_NAME ${ARGV0})
set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "")
target_link_libraries(${TARGET_NAME} PRIVATE ${WALBERLA_LIBS})
target_include_directories(
${TARGET_NAME} PUBLIC include PRIVATE ${WALBERLA_INCLUDE_DIRS}
${walberla_BINARY_DIR}/src)
install(TARGETS ${TARGET_NAME}
LIBRARY DESTINATION ${ESPRESSO_INSTALL_PYTHON}/espressomd)
endfunction()

add_library(espresso_walberla_cpp_flags INTERFACE)
add_library(espresso::walberla::cpp_flags ALIAS espresso_walberla_cpp_flags)
target_link_libraries(
Expand All @@ -30,31 +41,33 @@ target_link_libraries(
INTERFACE espresso::cuda_flags
$<$<BOOL:${ESPRESSO_BUILD_WITH_WALBERLA_AVX}>:espresso::avx_flags>)

function(espresso_configure_walberla_target)
set(TARGET_NAME ${ARGV0})
set_target_properties(${TARGET_NAME} PROPERTIES CXX_CLANG_TIDY "")
target_link_libraries(${TARGET_NAME} PRIVATE ${WALBERLA_LIBS})
target_include_directories(
${TARGET_NAME} PUBLIC include PRIVATE ${WALBERLA_INCLUDE_DIRS}
${walberla_BINARY_DIR}/src)
install(TARGETS ${TARGET_NAME}
LIBRARY DESTINATION ${ESPRESSO_INSTALL_PYTHON}/espressomd)
endfunction()

add_library(espresso_walberla SHARED)
add_library(espresso_walberla_codegen SHARED)
add_library(espresso::walberla ALIAS espresso_walberla)
add_library(espresso::walberla_codegen ALIAS espresso_walberla_codegen)

espresso_configure_walberla_target(espresso_walberla)
espresso_configure_walberla_target(espresso_walberla_codegen)

target_link_libraries(espresso_walberla PUBLIC MPI::MPI_CXX espresso::utils
target_link_libraries(
espresso_walberla PUBLIC MPI::MPI_CXX espresso::utils
PRIVATE espresso::walberla::cpp_flags espresso::walberla_codegen)
target_link_libraries(espresso_walberla_codegen
PRIVATE espresso::walberla::cpp_flags)

if(ESPRESSO_BUILD_WITH_CUDA AND WALBERLA_BUILD_WITH_CUDA)
if(WALBERLA_BUILD_WITH_CUDA)
espresso_add_gpu_library(espresso_walberla_cuda SHARED)
espresso_add_gpu_library(espresso_walberla_codegen_cuda SHARED)
add_library(espresso::walberla_cuda ALIAS espresso_walberla_cuda)
add_library(espresso::walberla_codegen_cuda ALIAS
espresso_walberla_codegen_cuda)
espresso_configure_walberla_target(espresso_walberla_cuda)
target_link_libraries(espresso_walberla_cuda PUBLIC espresso::utils
PRIVATE CUDA::cuda_driver CUDA::cudart)
espresso_configure_walberla_target(espresso_walberla_codegen_cuda)
target_link_libraries(
espresso_walberla_cuda PUBLIC espresso::utils
PRIVATE CUDA::cuda_driver CUDA::cudart espresso::walberla_codegen_cuda)
target_link_libraries(espresso_walberla_codegen_cuda PRIVATE CUDA::cuda_driver
CUDA::cudart)
endif()

add_subdirectory(src)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

foreach(precision double_precision single_precision)
target_sources(
espresso_walberla
espresso_walberla_codegen
PRIVATE DiffusiveFluxKernel_${precision}.cpp
DiffusiveFluxKernelThermalized_${precision}.cpp
DiffusiveFluxKernelWithElectrostatic_${precision}.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
foreach(n_species RANGE 1 5)
foreach(precision double_precision single_precision)
target_sources(
espresso_walberla
espresso_walberla_codegen
PRIVATE ReactionKernelBulk_${n_species}_${precision}.cpp
ReactionKernelIndexed_${n_species}_${precision}.cpp)
endforeach()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,39 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

target_sources(
espresso_walberla
PRIVATE StreamSweepSinglePrecision.cpp StreamSweepDoublePrecision.cpp
PackInfoPdfSinglePrecision.cpp PackInfoPdfDoublePrecision.cpp
PackInfoVecSinglePrecision.cpp PackInfoVecDoublePrecision.cpp
InitialPDFsSetterSinglePrecision.cpp
InitialPDFsSetterDoublePrecision.cpp Dynamic_UBB_single_precision.cpp
Dynamic_UBB_double_precision.cpp)
if(ESPRESSO_BUILD_WITH_WALBERLA_AVX)
target_sources(
espresso_walberla
PRIVATE CollideSweepSinglePrecisionLeesEdwardsAVX.cpp
CollideSweepDoublePrecisionLeesEdwardsAVX.cpp
CollideSweepSinglePrecisionThermalizedAVX.cpp
CollideSweepDoublePrecisionThermalizedAVX.cpp
StreamSweepSinglePrecisionAVX.cpp StreamSweepDoublePrecisionAVX.cpp)
else()
target_sources(
espresso_walberla
PRIVATE CollideSweepSinglePrecisionLeesEdwards.cpp
CollideSweepDoublePrecisionLeesEdwards.cpp
CollideSweepSinglePrecisionThermalized.cpp
CollideSweepDoublePrecisionThermalized.cpp)
endif()
if(ESPRESSO_BUILD_WITH_CUDA AND WALBERLA_BUILD_WITH_CUDA)
foreach(precision single_precision double_precision)
target_sources(espresso_walberla_codegen PRIVATE Dynamic_UBB_${precision}.cpp)
if(WALBERLA_BUILD_WITH_CUDA)
target_sources(espresso_walberla_codegen_cuda
PRIVATE Dynamic_UBB_${precision}CUDA.cu)
endif()
endforeach()

foreach(precision DoublePrecision SinglePrecision)
target_sources(
espresso_walberla_cuda
PRIVATE CollideSweepDoublePrecisionLeesEdwardsCUDA.cu
CollideSweepDoublePrecisionThermalizedCUDA.cu
CollideSweepSinglePrecisionLeesEdwardsCUDA.cu
CollideSweepSinglePrecisionThermalizedCUDA.cu
FieldAccessorsDoublePrecisionCUDA.cu
FieldAccessorsSinglePrecisionCUDA.cu
StreamSweepDoublePrecisionCUDA.cu
StreamSweepSinglePrecisionCUDA.cu
InitialPDFsSetterDoublePrecisionCUDA.cu
InitialPDFsSetterSinglePrecisionCUDA.cu
PackInfoPdfSinglePrecisionCUDA.cu
PackInfoPdfDoublePrecisionCUDA.cu
PackInfoVecSinglePrecisionCUDA.cu
PackInfoVecDoublePrecisionCUDA.cu
Dynamic_UBB_double_precisionCUDA.cu
Dynamic_UBB_single_precisionCUDA.cu)
endif()
espresso_walberla_codegen
PRIVATE PackInfoPdf${precision}.cpp PackInfoVec${precision}.cpp
InitialPDFsSetter${precision}.cpp)
if(ESPRESSO_BUILD_WITH_WALBERLA_AVX)
target_sources(
espresso_walberla_codegen
PRIVATE CollideSweep${precision}LeesEdwardsAVX.cpp
CollideSweep${precision}ThermalizedAVX.cpp
StreamSweep${precision}AVX.cpp)
else()
target_sources(
espresso_walberla_codegen
PRIVATE CollideSweep${precision}LeesEdwards.cpp
CollideSweep${precision}Thermalized.cpp
StreamSweep${precision}.cpp)
endif()
if(WALBERLA_BUILD_WITH_CUDA)
target_sources(
espresso_walberla_codegen_cuda
PRIVATE CollideSweep${precision}LeesEdwardsCUDA.cu
CollideSweep${precision}ThermalizedCUDA.cu
FieldAccessors${precision}CUDA.cu StreamSweep${precision}CUDA.cu
InitialPDFsSetter${precision}CUDA.cu
PackInfoPdf${precision}CUDA.cu PackInfoVec${precision}CUDA.cu)
endif()
endforeach()
6 changes: 4 additions & 2 deletions src/walberla_bridge/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ function(ESPRESSO_ADD_TEST)
cmake_parse_arguments(TEST "" "SRC;NAME;NUM_PROC" "DEPENDS" ${ARGN})
espresso_unit_test(
SRC ${TEST_SRC} NAME ${TEST_NAME} NUM_PROC ${TEST_NUM_PROC} DEPENDS
${TEST_DEPENDS} espresso::walberla espresso::utils)
${TEST_DEPENDS} espresso::walberla espresso::walberla_codegen
espresso::utils)
if(WALBERLA_BUILD_WITH_CUDA)
target_link_libraries(${TEST_NAME} PRIVATE espresso::walberla_cuda)
target_link_libraries(${TEST_NAME} PRIVATE espresso::walberla_cuda
espresso::walberla_codegen_cuda)
endif()
if(${TEST_SRC} MATCHES ".*\.cu$")
target_link_libraries(${TEST_NAME} PRIVATE espresso::walberla::cuda_flags)
Expand Down

0 comments on commit 33c57cb

Please sign in to comment.