[cig-commits] commit 2329 by bangerth to /var/svn/dealii/aspect

dealii.demon at gmail.com dealii.demon at gmail.com
Mon Mar 3 12:12:30 PST 2014


Revision 2329

Provide a way to set up a mini cmake project for plugins. Thanks to Matthias Maier for help with this!.

A   trunk/aspect/AspectConfig.cmake.in
U   trunk/aspect/CMakeLists.txt
U   trunk/aspect/doc/manual/manual.tex
U   trunk/aspect/doc/manual.pdf
U   trunk/aspect/doc/modules/changes.h
A   trunk/aspect/doc/plugin-CMakeLists.txt


http://www.dealii.org/websvn/revision.php?repname=Aspect+Repository&path=%2F&rev=2329&peg=2329

Diff:
Added: trunk/aspect/AspectConfig.cmake.in
===================================================================
--- trunk/aspect/AspectConfig.cmake.in	                        (rev 0)
+++ trunk/aspect/AspectConfig.cmake.in	2014-03-03 20:12:27 UTC (rev 2329)
@@ -0,0 +1,37 @@
+# Copyright (C) 2014 by the authors of the ASPECT code.
+#
+# This file is part of ASPECT.
+#
+# ASPECT 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 2, or (at your option)
+# any later version.
+#
+# ASPECT 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with ASPECT; see the file doc/COPYING.  If not see
+# <http://www.gnu.org/licenses/>.
+
+#  $Id$
+
+
+
+# This file provides a macro that authors can use to
+# set up a directory with source files that will then be
+# compiled into a run-time loadable plugin for Aspect.
+
+
+FIND_PACKAGE(deal.II 8.0 REQUIRED HINTS @DEAL_II_PATH@)
+SET(ASPECT_INCLUDE_DIRS "@CMAKE_SOURCE_DIR@/include")
+
+MACRO(ASPECT_SETUP_PLUGIN _target)
+  MESSAGE("Setting up plugin <${_target}>")
+  DEAL_II_SETUP_TARGET(${_target})
+  SET_PROPERTY(TARGET ${_target} APPEND PROPERTY
+    INCLUDE_DIRECTORIES "${ASPECT_INCLUDE_DIRS}"
+  )
+ENDMACRO()


Property changes on: trunk/aspect/AspectConfig.cmake.in
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/aspect/CMakeLists.txt
===================================================================
--- trunk/aspect/CMakeLists.txt	2014-03-03 19:00:27 UTC (rev 2328)
+++ trunk/aspect/CMakeLists.txt	2014-03-03 20:12:27 UTC (rev 2329)
@@ -1,3 +1,24 @@
+# Copyright (C) 2013, 2014 by the authors of the ASPECT code.
+#
+# This file is part of ASPECT.
+#
+# ASPECT 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 2, or (at your option)
+# any later version.
+#
+# ASPECT 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with ASPECT; see the file doc/COPYING.  If not see
+# <http://www.gnu.org/licenses/>.
+
+#  $Id$
+
+
 MESSAGE("====================================================")
 MESSAGE("============ Configuring ASPECT ====================")
 MESSAGE("====================================================")
@@ -42,6 +63,17 @@
 PROJECT(${TARGET})
 
 
+# Configure a cmake fragment that plugins can use to
+# set up compiler flags, include paths, etc to compile an
+# Aspect plugin
+CONFIGURE_FILE(
+  ${CMAKE_SOURCE_DIR}/AspectConfig.cmake.in
+  ${CMAKE_BINARY_DIR}/AspectConfig.cmake
+  @ONLY
+)
+
+
+# Next, set up the testsuite
 IF(EXISTS ${CMAKE_SOURCE_DIR}/tests/CMakeLists.txt)
   ENABLE_TESTING()
   ADD_SUBDIRECTORY(tests)

Modified: trunk/aspect/doc/manual/manual.tex
===================================================================
--- trunk/aspect/doc/manual/manual.tex	2014-03-03 19:00:27 UTC (rev 2328)
+++ trunk/aspect/doc/manual/manual.tex	2014-03-03 20:12:27 UTC (rev 2329)
@@ -1120,6 +1120,7 @@
 
 
 \section{Installation}
+\label{sec:installation}
 
 This is a brief explanation of how to install all the required software and
 spect{} itself.
@@ -5990,8 +5991,9 @@
 
   As discussed above, it is possible -- but not necessary -- to split this file
   into two: a header file, say 	exttt{my\_plugin.h}, and the
-  	exttt{my\_plugin.cc} file. We do this for all the existing plugins in
-  spect{} so that the documentation of these plugins shows up in the
+  	exttt{my\_plugin.cc} file (or, if you prefer, into multiple source files).
+  We do this for all the existing plugins in spect{} so that the documentation
+  of these plugins shows up in the
   doxygen-generated documentation. However, for your own plugins, there is
   typically no need for this split. The only occasion where this would be useful
   is if some plugin actually makes use of a different plugin (e.g., the
@@ -6040,9 +6042,61 @@
     installation. On the other hand, compiling the file into a shared library is
     a bit more that you need to do yourself. Nevertheless, this is the preferred
     approach.
+    
+    In practice, the compiler line above can become tedious because it includes
+    paths to the spect{} and \dealii{} header files, but possibly also other
+    things such as Trilinos headers, etc. Having to remember all of these pieces
+    is a hassle, and a much easier way is in fact to set up a mini-CMake project
+    for this. To this end, simply copy the file \url{doc/plugin-CMakeLists.txt}
+    to the directory where you have your plugin source files and rename it to
+    	exttt{CMakeLists.txt}. In essence, this file just has the following
+    content:
+    egin{lstlisting}[frame=single]
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
+
+FIND_PACKAGE(Aspect REQUIRED HINTS ${ASPECT_DIR} ../ $ENV{ASPECT_DIR})
+DEAL_II_INITIALIZE_CACHED_VARIABLES()
+
+PROJECT(my_plugin)
+ADD_LIBRARY(my_plugin SHARED source_1.cc source_2.cc)
+ASPECT_SETUP_PLUGIN(my_plugin)
+    \end{lstlisting}
   \end{itemize}
+  You can then just run the commands
+    egin{verbatim}
+ cmake -DASPECT_DIR=/path/to/aspect .
+ make
+    \end{verbatim}
+    and it should compile your plugin files into a shared library
+    	exttt{my\_plugin.so}. Of course, you may want to choose different names
+    for the source files 	exttt{source\_1.cc}, 	exttt{source\_2.cc} or the name of
+    the plugin 	exttt{my\_plugin}.
+    
+    In essence, what these few lines do is that they find an spect{}
+    installation (i.e., the directory where you configured and compiled it,
+    which may be the same directory as where you keep your sources, or a
+    different one, as discussed in Section~
ef{sec:installation}) in either the
+    directory explicitly specified in the 	exttt{ASPECT\_DIR} variable passed
+    to 	exttt{cmake}, the shell environment, or just one directory up. It then
+    sets up compiler paths and similar, and the following lines simply define
+    the name of a plugin, list the source files for it, and define everything
+    that's necessary to compile them into a shared library. Calling
+    	exttt{make} on the command line then simply compiles everything.
 \end{itemize}
 
+
ote{Complex projects built on spect{} often require plugins of more than
+just one kind. For example, they may have plugins for the geometry, the
+material model, and for postprocessing. In such cases, you can either define
+multiple shared libraries by repeating the calls to 	exttt{PROJECT},
+	exttt{ADD\_LIBRARY} and 	exttt{ASPECT\_SETUP\_PLUGIN} for each shared
+library in your
+	exttt{CMakeLists.txt} file above, or you can just compile all of your source
+files into a single shared library. In the latter case, you only need to list a
+single library in your input file, but each plugin will still be selectable in
+the various sections of your input file as long as each of your classes has a
+corresponding 	exttt{ASPECT\_REGISTER\_*} statement somewhere in the file
+where you have its definition.}
+
 
ote{If you choose to compile your plugins into a shared library yourself, you
   will need to recompile them every time you upgrade your spect{} installation
   since we do not guarantee that the spect{} application binary interface

Modified: trunk/aspect/doc/manual.pdf
===================================================================
(Binary files differ)

Modified: trunk/aspect/doc/modules/changes.h
===================================================================
--- trunk/aspect/doc/modules/changes.h	2014-03-03 19:00:27 UTC (rev 2328)
+++ trunk/aspect/doc/modules/changes.h	2014-03-03 20:12:27 UTC (rev 2329)
@@ -8,6 +8,15 @@
 </p>
 
 <ol>
+  <li>New: Aspect now installs a file <code>AspectConfig.cmake</code>
+  into the same directory as the executable that can be used by
+  plugins to set up compiler flags, include paths, etc, to compile
+  a set of source files into a shared library that can then be
+  loaded at run time from the input file. See the manual for more
+  information about this mechanism.
+  <br>
+  (Matthias Maier, Wolfgang Bangerth 2014/03/03)
+
   <li>New: The manual now contains a cookbook section introducing a
   model that runs in a two-dimensional annulus.
   <br>

Added: trunk/aspect/doc/plugin-CMakeLists.txt
===================================================================
--- trunk/aspect/doc/plugin-CMakeLists.txt	                        (rev 0)
+++ trunk/aspect/doc/plugin-CMakeLists.txt	2014-03-03 20:12:27 UTC (rev 2329)
@@ -0,0 +1,40 @@
+# Copyright (C) 2014 by the authors of the ASPECT code.
+#
+# This file is part of ASPECT.
+#
+# ASPECT 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 2, or (at your option)
+# any later version.
+#
+# ASPECT 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with ASPECT; see the file doc/COPYING.  If not see
+# <http://www.gnu.org/licenses/>.
+
+#  $Id$
+
+
+# -----------------------------------------------------------------
+# This file is a sample CMakeLists.txt file that plugins can use to
+# configure and build a shared library that can then be loaded via
+# the input file. For more information, see the manual.
+#
+# For actual use, you may want to use a different name than
+# <my_plugin> for the project, and for the names of the source files
+# below.
+# -----------------------------------------------------------------
+
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
+
+FIND_PACKAGE(Aspect REQUIRED HINTS ${ASPECT_DIR} ../ $ENV{ASPECT_DIR})
+DEAL_II_INITIALIZE_CACHED_VARIABLES()
+
+PROJECT(my_plugin)
+ADD_LIBRARY(my_plugin SHARED source_1.cc source_2.cc)
+ASPECT_SETUP_PLUGIN(my_plugin)


Property changes on: trunk/aspect/doc/plugin-CMakeLists.txt
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property


More information about the CIG-COMMITS mailing list