CMakeLists.txt 1.81 KB
Newer Older
1
# Packages are optional: if they are not present, certain code samples are not compiled
2
3
cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)

4
5
6
7
8
9
10
11
12
13
14
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()

15
16
17
18
set(NAME_OMP ${DWARF_PREFIX}_prng_omp)
set(NAME_SERIAL ${DWARF_PREFIX}_prng_serial)
set(NAME_MPI ${DWARF_PREFIX}_prng_mpi)

19
20
21
22
23
24
# C compiler settings

find_package(Common)

if (OPENMP_FOUND)
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
25
26
27
    add_executable(${NAME_OMP} random_openmp.c)
    target_link_libraries(${NAME_OMP} m)
    install(TARGETS ${NAME_OMP} DESTINATION bin)
28
29
    message("** Enabling '${NAME_OMP}': with OpenMP")

30
31
else()
     message("## Skipping 'random_openmp': no OpenMP support found")
32
#     dummy_install(${NAME_OMP} "OpenMP")
33
34
35
endif()

if (MPI_FOUND)
36
    cmake_policy(SET CMP0003 OLD)
37
38
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
    include_directories(${MPI_INCLUDE_PATH})
39
40
41
    add_executable(${NAME_MPI} random_mpi.c)
    target_link_libraries(${NAME_MPI} m ${MPI_LIBRARIES} stdc++)
    install(TARGETS ${NAME_MPI} DESTINATION bin)
42
43
    message("** Enabling '${NAME_MPI}': with MPI")

44
45
else()
    message("## Skipping 'random_mpi': no MPI support found")
46
#    dummy_install(${NAME_MPI} "MPI")
47
48
endif()

49
50
add_executable(${NAME_SERIAL} random.c)
target_link_libraries(${NAME_SERIAL} m)
51

52
install(TARGETS ${NAME_SERIAL} DESTINATION bin)
53
message("** Enabling '${NAME_SERIAL}': serial version")
54
55

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_FLAGS}")
56

57
unset(NAME)
58
# ==================================================================================================