Error during developing ASPECT within a docker container

Dear all,

Should I put CMakeLists.txt in aspect-build directory?

I made myplugin.h and myplugin.cc, and put them in /home/dealii/aspect.
After that, I made aspect-build directory, move to the directory, and finally executed command written in ASPECT document below.

cmake -DCMAKE_BUILD=Debug -DDEAL_II_DIR=$HOME/deal.II-install $HOME/aspect

Then I got a messege below.

The source directory "/home/dealii/aspect" does not appear to contain CMakeLists.txt

Since there is no description about CMakeLists.txt in the manual, I did not make it.
So, my questions are (a)should I make it and if so, (b)what should I write in it?

Thank you for your consideration
Shin-ichiro

Shin-ichiro:
There are two ways you can add plugins to be compiled:

  • You put the .h file into include/aspect/... (where … corresponds to the plugin system you are writing a plugin for) and the .cc file into the corresponding soure/... directory, and then you add the name of the file to source/.../CMakeLists.txt.
  • You follow the example of the cookbooks in the cookbooks/ directory that have a plugin, i.e., you create a separate directory, place your .h and .cc files into it, and a CMakeLists.txt like the ones you can find in the cookbooks directories. Then call cmake . in your own cookbook directory and then make.

We generally recommend the second approach.

Best
W.

Bangerth:
Thank you for answering my question.

Isn’t it necessary to follow the section 3.1.3 of ASPECT manual to develop my plugin in a container?
Because I tried to make a container by following the section 3.1.2 of the manual, and execute a cookbooks/prescribed_velocity/CMakeLists.txt, then it worked.
It is a different procedure to the manual.

Which case should users follow the section 3.1.3 of the manual?

Best
W.

Shin-Ichiro:
Even within a container, you can go both ways. It is simply a question where you want to locate the files for your plugin. In the first way I described above, the files are located in the same directory as the ASPECT source files. In the second way, they are located in a separate directory. Both of these approaches will work with containers as well.

If you made things work for one of the existing cookbooks, just use the same approach for your own work.

Best
W.

Bangerth:
My problem was solved. Thank you for telling me how to write CMakeLists.txt.

For other user who will develop the software in a docker container:
After mounting a volume which contains your plugin and executing cmake, you might get huge number of same messages like ‘file problem creating directory’ and ‘file failed to open for writing’. It could be caused by --read-only option of a container.
You can avoid these errors by copying the mounted volume(directory) to new directory in the container, then cmake and make in the new directory.

As I am a novice of Docker and this software, it could be a bad way. If someone knows a better way, please comment here for me and other user.

Yes, copying files is a reasonable approach.

A separate approach is this: You can create a separate “build” directory for the plugin. Where right now you compile your plugin and build the shared library in the same directory as where you have the source files, the source files and building the shared library need not be in the same directory. Just create a writable directory in the virtual machine, and call

  cmake ...directory...to...where...you...store...the...plugin...source...files...

instead of cmake .. (When you say cmake ., the dot indicates the directory where you have the plugin source files: Namely, the current directory, which is what a single dot represents.) This way you can keep the source files in a read-only directory, modify it from outside the virtual machine as you want, and only keep the compiled files in the virtual machine. No need for copying around files any more.

Best
Wolfgang