-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathCMakeLists.txt
228 lines (190 loc) · 6.69 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
cmake_minimum_required(VERSION 2.6)
# Set TARGET_SUPPORTS_SHARED_LIBS -- otherwise problems building shared libs on Macs (at least)
SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
option(INCLUDE_DRIVERS_IN_ALL "Include drivers in make all (set to ON for IDE project generation)" OFF)
IF(INCLUDE_DRIVERS_IN_ALL)
SET(EXCLUDE_DRIVERS_FROM_ALL "")
ELSE()
SET(EXCLUDE_DRIVERS_FROM_ALL "EXCLUDE_FROM_ALL")
ENDIF(INCLUDE_DRIVERS_IN_ALL)
#IF(APPLE)
# SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
# "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -flat_namespace -undefined suppress")
#ENDIF(APPLE)
# Set Camellia directories
set(CAMELLIA_SOURCE_DIR src)
set(DRIVER_DIR drivers)
if (ZLIB_LIB)
link_libraries(${ZLIB_LIB})
endif()
if (EXTRA_INCLUDE)
include_directories(${EXTRA_INCLUDE})
endif()
if (OMP_INCLUDE)
include_directories(${OMP_INCLUDE})
endif()
if(MPI_INCLUDE)
include_directories(${MPI_INCLUDE})
endif()
if(MPI_LINK_CC)
link_libraries(${MPI_LINK_CC})
endif()
if (MPI_LINK_FORTRAN)
link_libraries(${MPI_LINK_FORTRAN})
endif()
if(MPI_DIR)
MESSAGE("MPI_DIR = ${MPI_DIR}")
include_directories(${MPI_DIR}/include)
link_directories(${MPI_DIR})
link_libraries(mpi)
link_libraries(mpi_mpifh)
link_libraries(-L/usr/local/lib/gfortran/lib -lgfortran)
# link_libraries(mpi_f77)
endif()
if(SCALAPACK_LIB)
link_libraries(${SCALAPACK_LIB})
endif()
if(ADDITIONAL_LIBRARY_DIRS)
MESSAGE("ADDITIONAL_LIBRARY_DIRS: ${ADDITIONAL_LIBRARY_DIRS}")
MESSAGE("ADDITIONAL_LIBRARIES: ${ADDITIONAL_LIBRARIES}")
link_directories(${ADDITIONAL_LIBRARY_DIRS})
set(Trilinos_TPL_LIBRARIES ${Trilinos_TPL_LIBRARIES}
${ADDITIONAL_LIBRARIES})
# link_libraries(${ADDITIONAL_LIBRARIES})
endif()
MESSAGE(" Looking for Trilinos in ${TRILINOS_PATH}/lib/cmake/Trilinos
${TRILINOS_PATH} $ENV{TRILINOS_DIR}")
# Find Trilinos
find_package(Trilinos PATHS ${TRILINOS_PATH}/lib/cmake/Trilinos
${TRILINOS_PATH} $ENV{TRILINOS_DIR})
# If FIND_PACKAGE successfully found your Trilinos install, it will
# set the Boolean flag Trilinos_FOUND. The following IF statement
# fails with a FATAL_ERROR if Trilinos was not found. If it _was_
# found, it prints out the values of some Trilinos configuration
# details. You may find them useful for building your application
# that uses Trilinos.
IF(Trilinos_FOUND)
MESSAGE("\nFound Trilinos! Here are the details: ")
MESSAGE(" Trilinos_DIR = ${Trilinos_DIR}")
MESSAGE(" Trilinos_VERSION = ${Trilinos_VERSION}")
MESSAGE(" Trilinos_PACKAGE_LIST = ${Trilinos_PACKAGE_LIST}")
MESSAGE(" Trilinos_LIBRARIES = ${Trilinos_LIBRARIES}")
MESSAGE(" Trilinos_INCLUDE_DIRS = ${Trilinos_INCLUDE_DIRS}")
MESSAGE(" Trilinos_TPL_LIST = ${Trilinos_TPL_LIST}")
MESSAGE(" Trilinos_TPL_INCLUDE_DIRS = ${Trilinos_TPL_INCLUDE_DIRS}")
MESSAGE(" Trilinos_TPL_LIBRARIES = ${Trilinos_TPL_LIBRARIES}")
MESSAGE(" Trilinos_BUILD_SHARED_LIBS = ${Trilinos_BUILD_SHARED_LIBS}")
MESSAGE(" Trilinos_CXX_COMPILER = ${Trilinos_CXX_COMPILER}")
MESSAGE(" Trilinos_C_COMPILER = ${Trilinos_C_COMPILER}")
MESSAGE(" Trilinos_Fortran_COMPILER = ${Trilinos_Fortran_COMPILER}")
MESSAGE(" Trilinos_CXX_COMPILER_FLAGS = ${Trilinos_CXX_COMPILER_FLAGS}")
MESSAGE(" Trilinos_C_COMPILER_FLAGS = ${Trilinos_C_COMPILER_FLAGS}")
MESSAGE(" Trilinos_Fortran_COMPILER_FLAGS =
${Trilinos_Fortran_COMPILER_FLAGS}")
MESSAGE(" Trilinos_LINKER = ${Trilinos_LINKER}")
MESSAGE(" Trilinos_EXTRA_LD_FLAGS = ${Trilinos_EXTRA_LD_FLAGS}")
MESSAGE(" Trilinos_AR = ${Trilinos_AR}")
MESSAGE("End of Trilinos details\n")
ELSE()
MESSAGE(FATAL_ERROR "Could not find Trilinos!")
ENDIF()
# If you haven't already set the C++ compiler, use the same compiler
# that was used to build Trilinos on your machine.
IF(NOT CMAKE_CXX_COMPILER)
MESSAGE("Setting CXX compiler to ${Trilinos_CXX_COMPILER}.")
SET(CMAKE_CXX_COMPILER ${Trilinos_CXX_COMPILER})
ENDIF()
# Testing something:
#SET(CMAKE_CXX_COMPILER "echo")
#get_cmake_property(_variableNames VARIABLES)
#foreach (_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
#endforeach()
IF(NOT CMAKE_CXX_FLAGS)
# -fPIC allows shared libraries to be built against the Camellia library
SET(CMAKE_CXX_FLAGS ${Trilinos_CXX_COMPILER_FLAGS})
ENDIF()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
#MESSAGE("CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}")
# If you haven't already set the C compiler, use the same compiler
# that was used to build Trilinos on your machine.
IF(NOT CMAKE_C_COMPILER)
MESSAGE("Setting C compiler.")
SET(CMAKE_C_COMPILER ${Trilinos_C_COMPILER})
ENDIF()
IF (NOT CMAKE_C_FLAGS)
SET(CMAKE_C_FLAGS ${Trilinos_C_COMPILER_FLAGS})
ENDIF()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
#MESSAGE("CMAKE_C_FLAGS = ${CMAKE_C_FLAGS}")
# If you haven't already set the Fortran compiler, use the same compiler
# that was used to build Trilinos on your machine.
IF(NOT CMAKE_Fortran_COMPILER)
MESSAGE("Setting Fortran compiler.")
SET(CMAKE_Fortran_COMPILER ${Trilinos_Fortran_COMPILER})
ENDIF()
IF(NOT BUILD_SHARED_LIBS)
MESSAGE("Setting BUILD_SHARED_LIBS to ${Trilinos_BUILD_SHARED_LIBS}")
SET(BUILD_SHARED_LIBS ${Trilinos_BUILD_SHARED_LIBS})
ENDIF()
# Find MOAB
find_package(MOAB PATHS ${MOAB_PATH}/lib)
if (MOAB_FOUND)
ADD_DEFINITIONS(-DHAVE_MOAB)
include_directories(
${MOAB_INCLUDE_DIRS}
)
SET(ADDITIONAL_LIBRARIES ${ADDITIONAL_LIBRARIES} ${MOAB_LIBRARIES})
else()
MESSAGE("MOAB not found; MOAB_PATH = ${MOAB_PATH}.")
endif(MOAB_FOUND)
project(Camellia)
# Find all library source files
FILE(GLOB_RECURSE LIB_SOURCES "${CAMELLIA_SOURCE_DIR}/*.cpp" "${CAMELLIA_SOURCE_DIR}/include/*.h")
set(HEADERS
${CAMELLIA_SOURCE_DIR}/include
)
include_directories(
${Trilinos_TPL_INCLUDE_DIRS}
${Trilinos_INCLUDE_DIRS}
${CAMELLIA_SOURCE_DIR}/include
TPL/choice
)
link_directories(
${Trilinos_LIBRARY_DIRS}
${Trilinos_TPL_LIBRARY_DIRS}
#${MUMPS_PATH}/lib
)
if (MUMPS_DIR)
include_directories(${MUMPS_DIR}/include)
link_directories(${MUMPS_DIR})
endif()
link_libraries(
${Trilinos_LIBRARIES}
${Trilinos_TPL_LIBRARIES}
${ADDITIONAL_LIBRARIES}
)
add_library(Camellia ${LIB_SOURCES} ${HEADERS})
link_libraries(
Camellia
${Trilinos_LIBRARIES}
${Trilinos_TPL_LIBRARIES}
${ADDITIONAL_LIBRARIES}
# Xdmd
# hdf5_cpp
# dmumps
# mumps_common
# pord
)
# target_link_libraries(Camellia Xdmf)
FILE(GLOB ALL_HEADER_FILES "${HEADERS}/*.h" "${HEADERS}/*.hpp")
install (TARGETS Camellia DESTINATION lib)
install (FILES ${ALL_HEADER_FILES} DESTINATION include/Camellia)
# Enable testing (see unit_tests directory)
include(CTest)
enable_testing()
# Build Drivers
add_subdirectory(drivers ${EXCLUDE_DRIVERS_FROM_ALL})
add_subdirectory(examples)
add_subdirectory(unit_tests)
add_subdirectory(slow_tests)