cmake_minimum_required(VERSION 3.5)
project(LabMPI_solutions)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(MPI)
include_directories(${MPI_INCLUDE_PATH})

# --- Targets are listed in the order in which they appear in the handout ---

add_executable(HelloWorld ../src/HelloWorld.cpp)
target_compile_options(HelloWorld PRIVATE ${MPI_CXX_COMPILE_FLAGS})
target_link_libraries(HelloWorld ${MPI_CXX_LIBRARIES} ${MPI_CXX_LINK_FLAGS})

add_executable(ProbeMessageDemo ../src/demo_codes/ProbeMessageDemo.cpp)
target_compile_options(ProbeMessageDemo PRIVATE ${MPI_CXX_COMPILE_FLAGS})
target_link_libraries(ProbeMessageDemo ${MPI_CXX_LIBRARIES} ${MPI_CXX_LINK_FLAGS})

add_executable(SendAndReceive ../src/SendAndReceive.cpp)
target_compile_options(SendAndReceive PRIVATE ${MPI_CXX_COMPILE_FLAGS})
target_link_libraries(SendAndReceive ${MPI_CXX_LIBRARIES} ${MPI_CXX_LINK_FLAGS})

add_executable(NonBlockingSendAndReceive ../src/NonBlockingSendAndReceive.cpp)
target_compile_options(NonBlockingSendAndReceive PRIVATE ${MPI_CXX_COMPILE_FLAGS})
target_link_libraries(NonBlockingSendAndReceive ${MPI_CXX_LIBRARIES} ${MPI_CXX_LINK_FLAGS})

add_executable(BroadcastDemo ../src/demo_codes/BroadcastDemo.cpp)
target_compile_options(BroadcastDemo PRIVATE ${MPI_CXX_COMPILE_FLAGS})
target_link_libraries(BroadcastDemo ${MPI_CXX_LIBRARIES} ${MPI_CXX_LINK_FLAGS})

add_executable(ScatterDemo ../src/demo_codes/ScatterDemo.cpp)
target_compile_options(ScatterDemo PRIVATE ${MPI_CXX_COMPILE_FLAGS})
target_link_libraries(ScatterDemo ${MPI_CXX_LIBRARIES} ${MPI_CXX_LINK_FLAGS})

add_executable(GatherDemo ../src/demo_codes/GatherDemo.cpp)
target_compile_options(GatherDemo PRIVATE ${MPI_CXX_COMPILE_FLAGS})
target_link_libraries(GatherDemo ${MPI_CXX_LIBRARIES} ${MPI_CXX_LINK_FLAGS})

add_executable(ReduceDemo ../src/demo_codes/ReduceDemo.cpp)
target_compile_options(ReduceDemo PRIVATE ${MPI_CXX_COMPILE_FLAGS})
target_link_libraries(ReduceDemo ${MPI_CXX_LIBRARIES} ${MPI_CXX_LINK_FLAGS})

add_executable(VectorNormalization ../src/VectorNormalization.cpp ../src/Utils.hpp)
target_compile_options(VectorNormalization PRIVATE ${MPI_CXX_COMPILE_FLAGS})
target_link_libraries(VectorNormalization ${MPI_CXX_LIBRARIES} ${MPI_CXX_LINK_FLAGS})

add_executable(CustomTypeDemo ../src/demo_codes/CustomTypeDemo.cpp)
target_compile_options(CustomTypeDemo PRIVATE ${MPI_CXX_COMPILE_FLAGS})
target_link_libraries(CustomTypeDemo ${MPI_CXX_LIBRARIES} ${MPI_CXX_LINK_FLAGS})

add_executable(CustomOperationDemo ../src/demo_codes/CustomOperationDemo.cpp)
target_compile_options(CustomOperationDemo PRIVATE ${MPI_CXX_COMPILE_FLAGS})
target_link_libraries(CustomOperationDemo ${MPI_CXX_LIBRARIES} ${MPI_CXX_LINK_FLAGS})

add_executable(BestStudent ../src/BestStudent.cpp)
target_compile_options(BestStudent PRIVATE ${MPI_CXX_COMPILE_FLAGS})
target_link_libraries(BestStudent ${MPI_CXX_LIBRARIES} ${MPI_CXX_LINK_FLAGS})

add_executable(CommunicatorDemo ../src/demo_codes/CommunicatorDemo.cpp)
target_compile_options(CommunicatorDemo PRIVATE ${MPI_CXX_COMPILE_FLAGS})
target_link_libraries(CommunicatorDemo ${MPI_CXX_LIBRARIES} ${MPI_CXX_LINK_FLAGS})
