Skip to content
CMakeLists.txt 1.74 KiB
Newer Older
# Packages are optional: if they are not present, certain code samples are not compiled
cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)

find_package(OpenMP)   # Built-in in CMake
find_package(MPI)      # Built-in in CMake

include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/common.cmake)

# ==================================================================================================

if ("${DWARF_PREFIX}" STREQUAL "")
  set(DWARF_PREFIX 7_montecarlo)
endif()
set(NAME_OMP ${DWARF_PREFIX}_pi_omp)
set(NAME_SERIAL ${DWARF_PREFIX}_pi_serial)
set(NAME_MPI ${DWARF_PREFIX}_pi_mpi)


# C compiler settings

find_package(Common)

if (OPENMP_FOUND)
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    add_executable(${NAME_OMP} pi_omp.c pi_shared.c)
    install(TARGETS ${NAME_OMP} DESTINATION bin)
    message("** Enabling '${NAME_OMP}': with OpenMP")
else()
     message("## Skipping 'pi_omp': no OpenMP support found")
    cmake_policy(SET CMP0003 OLD)
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
    include_directories(${MPI_INCLUDE_PATH})
    add_executable(${NAME_MPI} pi_mpi.c pi_shared.c)
    target_link_libraries(${NAME_MPI} ${MPI_LIBRARIES} stdc++)
    install(TARGETS ${NAME_MPI} DESTINATION bin)
    message("** Enabling '${NAME_MPI}': with MPI")
else()
     message("## Skipping '${NAME_MPI}': no OpenMP support found")
#     dummy_install(${NAME} "OpenMP")
add_executable(${NAME_SERIAL} pi_serial.c pi_shared.c)
message("** Enabling '${NAME_SERIAL}': serial version")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_FLAGS}")
# ==================================================================================================