Skip to content
CMakeLists.txt 1.65 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}_prng_omp)
set(NAME_SERIAL ${DWARF_PREFIX}_prng_serial)
set(NAME_MPI ${DWARF_PREFIX}_prng_mpi)

# C compiler settings

find_package(Common)

if (OPENMP_FOUND)
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    add_executable(${NAME_OMP} random_openmp.c)
    target_link_libraries(${NAME_OMP} m)
    install(TARGETS ${NAME_OMP} DESTINATION bin)
else()
     message("## Skipping 'random_openmp': no OpenMP support found")
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
    include_directories(${MPI_INCLUDE_PATH})
    add_executable(${NAME_MPI} random_mpi.c)
    target_link_libraries(${NAME_MPI} m ${MPI_LIBRARIES} stdc++)
    install(TARGETS ${NAME_MPI} DESTINATION bin)
else()
    message("## Skipping 'random_mpi': no MPI support found")
add_executable(${NAME_SERIAL} random.c)
target_link_libraries(${NAME_SERIAL} m)
install(TARGETS ${NAME_SERIAL} DESTINATION bin)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_FLAGS}")
# ==================================================================================================