2
# ************************************************************************
4
# PyTrilinos: Python Interface to Trilinos
5
# Copyright (2009) Sandia Corporation
7
# Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8
# license for use of this work by or on behalf of the U.S. Government.
10
# This library is free software; you can redistribute it and/or modify
11
# it under the terms of the GNU Lesser General Public License as
12
# published by the Free Software Foundation; either version 2.1 of the
13
# License, or (at your option) any later version.
15
# This library is distributed in the hope that it will be useful, but
16
# WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
# Lesser General Public License for more details.
20
# You should have received a copy of the GNU Lesser General Public
21
# License along with this library; if not, write to the Free Software
22
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24
# Questions? Contact Bill Spotz (wfspotz@sandia.gov)
26
# ************************************************************************
29
INCLUDE(PackageLibraryMacros)
32
# Package-specific configuration options
33
IF(Trilinos_ENABLE_Epetra)
35
ENDIF(Trilinos_ENABLE_Epetra)
37
IF(Trilinos_ENABLE_Teuchos)
39
ENDIF(Trilinos_ENABLE_Teuchos)
42
SET(HAVE_NOX_EPETRA ON)
43
ENDIF(NOX_ENABLE_Epetra)
49
PACKAGE_CONFIGURE_FILE(${PACKAGE_NAME}_config.h)
52
# On Mac OS X Gnu compilers, add dynamic lookup for undefined symbols
53
# to the pytrilinos library and PyTrilinos extension modules
54
SET(EXTRA_LINK_ARGS "")
56
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
57
APPEND_SET(EXTRA_LINK_ARGS "-undefined dynamic_lookup")
62
# Add the current binary and source directories, the python include
63
# path, and the NumPy include path to the include directories
64
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
65
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
66
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
67
INCLUDE_DIRECTORIES(${NumPy_INCLUDE_DIR})
70
# Copy the pyfragments.swg file to the build directory
71
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/pyfragments.swg.in
72
${CMAKE_CURRENT_BINARY_DIR}/pyfragments.swg)
75
# Initialize the headers and sources
78
SET(HEADERS ${HEADERS}
79
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}_config.h
83
# Core PyTrilinos headers and sources
98
# PyTrilinos + Teuchos headers and sources
99
IF(PyTrilinos_ENABLE_Teuchos)
102
Teuchos_PythonParameter.h
106
Teuchos_PythonParameter.cpp
109
ENDIF(PyTrilinos_ENABLE_Teuchos)
112
# PyTrilinos + Epetra headers and sources
113
IF(PyTrilinos_ENABLE_Epetra)
116
Epetra_NumPyFEVector.h
117
Epetra_NumPyIntSerialDenseMatrix.h
118
Epetra_NumPyIntSerialDenseVector.h
119
Epetra_NumPyIntVector.h
120
Epetra_NumPyMultiVector.h
121
Epetra_NumPySerialDenseMatrix.h
122
Epetra_NumPySerialDenseVector.h
127
Epetra_NumPyFEVector.cpp
128
Epetra_NumPyIntSerialDenseMatrix.cpp
129
Epetra_NumPyIntSerialDenseVector.cpp
130
Epetra_NumPyIntVector.cpp
131
Epetra_NumPyMultiVector.cpp
132
Epetra_NumPySerialDenseMatrix.cpp
133
Epetra_NumPySerialDenseVector.cpp
134
Epetra_NumPyVector.cpp
137
ENDIF(PyTrilinos_ENABLE_Epetra)
140
# PyTrilinos + EpetraExt headers and sources
141
IF(PyTrilinos_ENABLE_EpetraExt)
151
ENDIF(PyTrilinos_ENABLE_EpetraExt)
154
# PyTrilinos + ML headers and sources
155
IF(PyTrilinos_ENABLE_ML)
161
ENDIF(PyTrilinos_ENABLE_ML)
164
# Define the target for the swig runtime header
165
SET(SWIG_RUNTIME swigpyrun.h)
167
OUTPUT ${SWIG_RUNTIME}
168
COMMAND ${SWIG_EXECUTABLE} -python -external-runtime
172
# Define the targets for the PyTrilinos library
175
HEADERS ${HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/${SWIG_RUNTIME}
179
SET_TARGET_PROPERTIES(pytrilinos
180
PROPERTIES LINK_FLAGS "${EXTRA_LINK_ARGS}"
184
# Define the PyTrilinos swig setup
185
SET(CMAKE_SWIG_FLAGS "")
186
GET_FILENAME_COMPONENT(PYTRILINOS_DOXDIR
187
${CMAKE_CURRENT_SOURCE_DIR}/../doc/Doxygen ABSOLUTE
189
APPEND_SET(CMAKE_SWIG_FLAGS -I${PYTRILINOS_DOXDIR})
192
# Loop over the PyTrilinos-enabled Trilinos modules and define the
193
# swig-generated PyTrilinos extension modules
194
FOREACH(MODULE ${PyTrilinos_MODULES})
195
# Alternate versions of the module name
196
STRING(TOUPPER ${MODULE} MODULE_UPPER)
197
STRING(REPLACE "." "_" MODULE_NODOT ${MODULE})
198
SET_SOURCE_FILES_PROPERTIES(${MODULE}.i PROPERTIES
201
# Determine the swig module output directory, name and unique target name
202
SWIG_MODULE_GET_OUTDIR_AND_MODULE(${MODULE}.i MODULE_OUTDIR MODULE_NAME)
203
IF(TARGET ${MODULE_NAME})
204
SET(PyTrilinos_TARGET_NAME ${MODULE_NODOT})
205
ELSE(TARGET ${MODULE_NAME})
206
SET(PyTrilinos_TARGET_NAME ${MODULE_NAME})
207
ENDIF(TARGET ${MODULE_NAME})
208
# Add the SWIG module
209
SWIG_ADD_MODULE(${PyTrilinos_TARGET_NAME} python "${MODULE_OUTDIR}"
210
"${MODULE_NAME}" ${MODULE}.i)
211
SWIG_LINK_LIBRARIES(${PyTrilinos_TARGET_NAME} pytrilinos)
212
# Choosing the Trilinos libraries to link against requires a little bit
214
IF("${MODULE_OUTDIR}" MATCHES "PyTrilinos/NOX/Epetra")
215
SET(TRILINOS_LIBS ${NOXEPETRA_LIBRARIES})
216
ELSEIF("${MODULE_OUTDIR}" MATCHES "PyTrilinos/NOX")
217
SET(TRILINOS_LIBS ${NOX_LIBRARIES})
218
ELSEIF("${MODULE_OUTDIR}" MATCHES "PyTrilinos/LOCA")
219
SET(TRILINOS_LIBS ${LOCA_LIBRARIES})
220
ELSE("${MODULE_OUTDIR}")
221
SET(TRILINOS_LIBS ${${MODULE_UPPER}_LIBRARIES})
222
ENDIF("${MODULE_OUTDIR}" MATCHES "PyTrilinos/NOX/Epetra")
223
SWIG_LINK_LIBRARIES(${PyTrilinos_TARGET_NAME} ${TRILINOS_LIBS})
224
SET_TARGET_PROPERTIES(${PyTrilinos_TARGET_NAME} PROPERTIES
225
LINK_FLAGS "${EXTRA_LINK_ARGS}"
227
ENDFOREACH(MODULE ${PyTrilinos_MODULES})
230
# Add the PyTrilinos subdirectory, which is top-level package
232
ADD_SUBDIRECTORY(PyTrilinos)