CMakeLists.txt 2.4 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
18
19
20
21
22
set(NAME1_OMP ${DWARF_PREFIX}_integral1_omp)
set(NAME1_SERIAL ${DWARF_PREFIX}_integral1_serial)
set(NAME1_MPI ${DWARF_PREFIX}_integral1_mpi)
set(NAME2_OMP ${DWARF_PREFIX}_integral2_omp)
set(NAME2_SERIAL ${DWARF_PREFIX}_integral2_serial)
set(NAME2_MPI ${DWARF_PREFIX}_integral2_mpi)
set(NAME3_OMP ${DWARF_PREFIX}_integral3_omp)
set(NAME3_SERIAL ${DWARF_PREFIX}_integral3_serial)
set(NAME3_MPI ${DWARF_PREFIX}_integral3_mpi)
23
24
25
26
27
28
29

# C compiler settings

find_package(Common)

if (OPENMP_FOUND)
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
30
31
32
33
34
35
36
37
38
    add_executable(${NAME1_OMP} integral1_openmp.c)
    target_link_libraries(${NAME1_OMP} m)
    install(TARGETS ${NAME1_OMP} DESTINATION bin)
    add_executable(${NAME2_OMP} integral2_openmp.c)
    target_link_libraries(${NAME2_OMP} m)
    install(TARGETS ${NAME2_OMP} DESTINATION bin)
    add_executable(${NAME3_OMP} integral3_openmp.c)
    target_link_libraries(${NAME3_OMP} m)
    install(TARGETS ${NAME3_OMP} DESTINATION bin)
39
40
else()
     message("## Skipping 'integral 1/2/3 advanced': no OpenMP support found")
41
#     dummy_install(${NAME} "OpenMP")
42
43
44
45
46
endif()

if (MPI_FOUND)
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
    include_directories(${MPI_INCLUDE_PATH})
47
48
49
50
51
52
53
54
55
    add_executable(${NAME1_MPI} integral1_mpi.c)
    target_link_libraries(${NAME1_MPI} m ${MPI_LIBRARIES} stdc++)
    install(TARGETS ${NAME1_MPI} DESTINATION bin)
    add_executable(${NAME2_MPI} integral2_mpi.c)
    target_link_libraries(${NAME2_MPI} m ${MPI_LIBRARIES} stdc++)
    install(TARGETS ${NAME2_MPI} DESTINATION bin)
    add_executable(${NAME3_MPI} integral3_mpi.c)
    target_link_libraries(${NAME3_MPI} m ${MPI_LIBRARIES} stdc++)
    install(TARGETS ${NAME3_MPI} DESTINATION bin)
56
57
else()
    message("## Skipping 'integral 1/2/3 advanced': no MPI support found")
58
#    dummy_install(${NAME} "MPI")
59
60
61
62
63
64
endif()

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


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