[aspect-devel] Including a separate directory in Aspect


#1

Hello,

I am trying to include a header file in one of the Aspect files and I am wondering what the best approach is? I was looking into using include_directories inside the cmake file, but I am not very familiar with cmake itself. Any help is appreciated

Thank you,
Kodi Neumiller


#2

Hi Kodi,

can you explain a bit more what exactly you want to do and what the problem is?
Is the header file you want to include something that has to be outside of the ASPECT include directory? (Because otherwise you can just include it like all the other header files.)
And if yes, where exactly do you need to include it? (Like, coulnd’t you use a shared library like we do for our plugins in the cookbooks, and then use the relative path in the .prm file?)

Cheers,
Juliane


#3

So we are trying to use a class that connects to our servers and this class is located outside the ASPECT directory. I actually saw that in AspectConfig.cmake.in it uses the FIND_PACKAGE command and is used to locate the deal.II. package. This would work better since we would not only need the directory but also the libraries associated with it. But when I use the command “FIND_PACKAGE(libdap4)” with our installed package I get an error:

Could not find a package configuration file provided by “libdap4” with any
of the following names:

libdap4Config.cmake
libdap4-config.cmake

Am I missing something?


#4

Kodi,

Since libdap4 is not a package known to cmake’s default list of packages it recognizes (it knows, for example, how to find MPI or BLAS or a bunch of other common packages), you will have to write your own “FindLIBDAP4.cmake” file. There are many examples out there on the internet how to write such a module. You can also look in the deal.II source directory under cmake/modules/ to see examples. Most of these FindXXX modules are not very complicated.

Best
W.


#5

Thank you for the help. Should the FindLIBDAP.cmake file be put inside the aspect/cmake folder?


#6

Yes, that would be the correct place for it. I think it is convention to put them into a further sub-folder aspect/cmake/modules.


#7

Okay, does the FindXXX.cmake file need to be called from within one of the other cmake files located in aspect?

UPDATE: Got it working, I was able to call the FindLIBDAP.cmake file using find_package(LIBDAP) in the CMakeLists.txt file.

Thanks for all the help! (Sorry I’m editing this reply, the forum limits me to 3 replies in the same topic)


#8

Yes. You need to INCLUDE the file that defines the module in the top-level CMakeLists.txt file and then call the functions you define there from the top-level file, or just have the code that needs to be executed right in the file that is being included.

Here are a couple of links (generally, the cmake documentation is very good and worth consulting):
https://cmake.org/cmake/help/v3.0/command/include.html
https://cmake.org/cmake/help/v3.0/command/find_package.html