cmake_minimum_required(VERSION 3.5)
project(LabOpenMP_skeletons)

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

find_package(OpenMP)
if (OPENMP_FOUND)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()

# NOTE: FalseSharing.cpp only demonstrates the effect in an unoptimized build
# (the default CLion Debug profile). From -O1 upwards the compiler keeps the
# accumulator in a register, the shared cache line is no longer written on every
# iteration, and the difference between the two variants disappears.

add_executable(HelloWorld ../src/HelloWorld.cpp)
add_executable(MatrixSum ../src/MatrixSum.cpp)
add_executable(VectorNormalization ../src/Utils.hpp ../src/VectorNormalization.cpp)
add_executable(FalseSharing ../src/FalseSharing.cpp)
add_executable(MergeSort ../src/MergeSort.cpp)
