CMakeLists.txt 1.76 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# 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} prng_omp.c prng_shared.c)
    install(TARGETS ${NAME_OMP} DESTINATION bin)
    message("** Enabling '${NAME_OMP}': with OpenMP")
else()
     message("## Skipping 'prng_omp': no OpenMP support found")
#     dummy_install(${NAME} "OpenMP")
endif()

if (MPI_FOUND)
    cmake_policy(SET CMP0003 OLD)
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
    include_directories(${MPI_INCLUDE_PATH})
    add_executable(${NAME_MPI} prng_mpi.c prng_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")
endif()

add_executable(${NAME_SERIAL} prng_serial.c prng_shared.c)
message("** Enabling '${NAME_SERIAL}': serial version")

install(TARGETS ${NAME_SERIAL} DESTINATION bin)

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

unset(NAME)
# ==================================================================================================