-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
118 lines (90 loc) · 3.28 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
###########################################################################
## PLSA-MP
## Probabilistic latent semantic analysis (PLSA, multiprocessor version)
##
## Copyright (C) 2009-2021 by Raymond Wan, All rights reserved.
## Contact: [email protected]
##
## This file is part of PLSA-MP.
##
## PLSA-MP is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version
## 3 of the License, or (at your option) any later version.
##
## PLSA-MP is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
##
## You should have received a copy of the GNU General Public
## License along with PLSA-MP; if not, see
## <http://www.gnu.org/licenses/>.
###########################################################################
## Set the minimum required CMake version
cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
########################################
## Define some variables
## Testing compilation flags, some of which are suggested by the Valgrind 3.3 >
# set (MY_C_FLAGS "-pedantic -Wno-long-long -g -fno-inline -O0 -Wall")
## Release compilation flags, suggested by the Valgrind 3.3 book
set (MY_C_FLAGS "-O3 -Wall -Wno-unused-result -Wno-unused-but-set-variable")
set (TARGET_NAME_EXEC "plsa")
set (CURR_PROJECT_NAME "PLSA-MP")
## Define the project
project (${CURR_PROJECT_NAME} LANGUAGES C)
########################################
## Define the source files
## Source files for both the test executable and library
set (SRC_FILES
comm.c
debug.c
em-steps.c
input.c
main.c
output.c
parameters.c
run.c
wmalloc.c
)
########################################
## Detect OpenMP and MPI
find_package (MPI)
if (MPI_FOUND)
set (HAVE_MPI 1)
endif (MPI_FOUND)
find_package (OpenMP)
if (OPENMP_FOUND)
set (HAVE_OPENMP 1)
endif (OPENMP_FOUND)
########################################
## Set various values based on libraries found
if (MPI_FOUND)
include_directories (${MPI_INCLUDE_PATH})
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_COMPILE_FLAGS}")
set (LINK_FLAGS "${LINK_FLAGS} ${MPI_LINK_FLAGS}")
set (CMAKE_C_COMPILER "${MPI_COMPILER}")
endif (MPI_FOUND)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
endif (OPENMP_FOUND)
########################################
## Create the configuration file
## Configure a header file to pass some of the CMake settings
## to the source code
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/PLSA_MP_Config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/PLSA_MP_Config.h"
)
## Include the binary directory so that the created configuration
## file can be located
include_directories (${CMAKE_CURRENT_BINARY_DIR})
########################################
## Set initial compilation flags
## Set compiler flags based on global variable
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_C_FLAGS}")
########################################
## Define the executable
add_executable (${TARGET_NAME_EXEC} ${SRC_FILES})
## Link the executable to the math library
target_link_libraries (${TARGET_NAME_EXEC} m)