CMakeLists.txt 1.65 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
# Packages are optional: if they are not present, certain code samples are not compiled
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()

# C compiler settings

find_package(Common)

if (OPENMP_FOUND)
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    add_executable(integral1_openmp integral1_openmp.c)
    target_link_libraries(integral1_openmp m)
    add_executable(integral2_openmp integral2_openmp.c)
    target_link_libraries(integral2_openmp m)
    add_executable(integral3_openmp integral3_openmp.c)
    target_link_libraries(integral3_openmp m)
else()
     message("## Skipping 'integral 1/2/3 advanced': no OpenMP support found")
     dummy_install(${NAME} "OpenMP")
endif()

if (MPI_FOUND)
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
    include_directories(${MPI_INCLUDE_PATH})
    add_executable(integral1_mpi integral1_mpi.c)
    target_link_libraries(integral1_mpi m ${MPI_LIBRARIES})
    add_executable(integral2_mpi integral2_mpi.c)
    target_link_libraries(integral2_mpi m ${MPI_LIBRARIES})
    add_executable(integral3_mpi integral3_mpi.c)
    target_link_libraries(integral3_mpi m ${MPI_LIBRARIES})
else()
    message("## Skipping 'integral 1/2/3 advanced': no MPI support found")
    dummy_install(${NAME} "MPI")
endif()

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


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