-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
70 lines (52 loc) · 1.8 KB
/
CMakeLists.txt
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
project(commonlib)
cmake_minimum_required(VERSION 2.6)
enable_language(C)
SET(CMAKE_COMPILER_IS_GNUCC)
# SET(CMAKE_C_FLAGS "-lm")
INCLUDE(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG("-std=c99" HAVE_C99)
IF (HAVE_C99)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ")
ELSE(HAVE_C99)
MESSAGE(WARNING "C99 support not available, program may fail to compile!")
ENDIF(HAVE_C99)
find_package(MPI REQUIRED)
OPTION(USE_OPENMP "Use OpenMP?" ON)
OPTION(USE_MPI "Use MPI?" ON)
IF(USE_OPENMP)
FIND_PACKAGE(OpenMP)
ENDIF(USE_OPENMP)
IF(USE_MPI)
FIND_PACKAGE(MPI)
ENDIF(USE_MPI)
include_directories( ${MPI_C_INCLUDE_PATH})
if (MPI_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_C_FLAGS}")
endif()
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS} -fopenmp")
endif()
add_library(common common.c)
add_executable(gensumserial genSumVec.c)
find_library(M_LIB m)
target_link_libraries(gensumserial ${M_LIB})
target_link_libraries(gensumserial common)
add_executable(sumvec_openmp sumvec_openmp.c)
find_library(M_LIB m)
target_link_libraries(sumvec_openmp ${M_LIB})
target_link_libraries(sumvec_openmp common)
add_executable(sumvec_MPI sumvec_MPI.c)
target_link_libraries(sumvec_MPI ${MPI_C_LIBRARIES})
target_link_libraries(sumvec_MPI common)
target_link_libraries(sumvec_MPI ${M_LIB})
add_executable(sumvec_comb sumvec_comb.c)
target_link_libraries(sumvec_comb ${MPI_C_LIBRARIES})
target_link_libraries(sumvec_comb common)
target_link_libraries(sumvec_comb ${M_LIB})
enable_testing()
add_test(gensumserial ${PROJECT_BINARY_DIR}/gensumserial)
add_test(sumvec_openmp ${PROJECT_BINARY_DIR}/sumvec_openmp)
add_test(sumvec_MPI ${PROJECT_BINARY_DIR}/sumvec_MPI)
add_test(sumvec_comb ${PROJECT_BINARY_DIR}/sumvec_comb)
set_tests_properties(sumvec_openmp PROPERTIES ENVIRONMENT OMP_NUM_THREADS=2)