Advice on CMake code (total newbie here)


I just wrote my first CMake code today, after reading part of the CMake tutorial yesterday and while it does work so far, I was hoping to get some advice from more experienced CMakes users, since I’m sure the code is not very elegant and could be improved.

All the source code is in the project’s src directory, it is hybrid MPI+OpenMP code written in Fortran+C and it uses HDF5. By default I want a RELEASE build and the code installed in the build directory itself. I have two user options to select whether OpenMP (-DOpenMP) and the C code (-DGAUSS_C) should be used.

My main concern is that the code will be installed in different environments, with different compilers and compiler versions, so I need to take care of that in a clean and robust way. So far I have tried with different compilers: gnu, intel and cray.

I just have two CMakeLists.txt files, and I would be really grateful if you could give me some advice/suggestions on how to improve them. Since I cannot upload files here, I link them with The file in the root directory: and the one in the src directory:

Many thanks,