CMakeLists.txt 1.82 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
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()
14
15
16
17
set(NAME_OMP ${DWARF_PREFIX}_integral1d_omp)
set(NAME_SERIAL ${DWARF_PREFIX}_integral1d_serial)
set(NAME_MPI ${DWARF_PREFIX}_integral1d_mpi)

18
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} integral1d_OMP.c)
    target_link_libraries(${NAME_OMP} m)
    install(TARGETS ${NAME_OMP} DESTINATION bin)
28
    message("** Enabling '${NAME_OMP}': with OpenMP")
29
30
else()
     message("## Skipping 'integral1d_OMP': no OpenMP support found")
31
#     dummy_install(${NAME} "OpenMP")
32
33
34
endif()

if (MPI_FOUND)
35
    cmake_policy(SET CMP0003 OLD)
36
37
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
    include_directories(${MPI_INCLUDE_PATH})
38
39
40
    add_executable(${NAME_MPI} integral1d_mpi.c)
    target_link_libraries(${NAME_MPI} m ${MPI_LIBRARIES} stdc++)
    install(TARGETS ${NAME_MPI} DESTINATION bin)
41
    message("** Enabling '${NAME_MPI}': with MPI")
42
43
else()
    message("## Skipping 'integral1d_mpi': no MPI support found")
44
#    dummy_install(${NAME} "MPI")
45
46
endif()

47
48
49
add_executable(${NAME_SERIAL} integral1d.c)
target_link_libraries(${NAME_SERIAL} m)
install(TARGETS ${NAME_SERIAL} DESTINATION bin)
50
message("** Enabling '${NAME_SERIAL}': serial version")
51
52


53
54
55
56
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_FLAGS}")


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