cmake_minimum_required(VERSION 3.18) project(mpigdb_examples) set(default_build_type "Release") if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "No build type was set. Setting build type to ${default_build_type}.") set(CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Choose the type to build" FORCE) endif() set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") if(NOT USE_SANITIZER) set(USE_SANITIZER "" CACHE STRING "use a build sanitizer" FORCE) endif() set_property(CACHE USE_SANITIZER PROPERTY STRINGS "" "Address" "Thread" "Undefined" "Leak" "Memory") if (USE_SANITIZER STREQUAL "Address") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") elseif (USE_SANITIZER STREQUAL "Thread") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread") elseif (USE_SANITIZER STREQUAL "Undefined") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined") elseif (USE_SANITIZER STREQUAL "Leak") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=leak") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak") elseif (USE_SANITIZER STREQUAL "Memory") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory") endif() set(CMAKE_EXPORT_COMPILE_COMMANDS ON) include(FetchContent) find_package(MPI REQUIRED COMPONENTS CXX) FetchContent_Declare( mdspan GIT_REPOSITORY https://github.com/kokkos/mdspan GIT_TAG mdspan-0.6.0 FIND_PACKAGE_ARGS ) FetchContent_MakeAvailable(mdspan) add_executable(heatdist heatdist.cc) target_link_libraries(heatdist PRIVATE MPI::MPI_CXX std::mdspan) target_compile_features(heatdist PRIVATE cxx_std_20) add_executable(crash crash.cc) target_link_libraries(crash PRIVATE MPI::MPI_CXX)