Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmake #934

Draft
wants to merge 41 commits into
base: master
Choose a base branch
from
Draft

Cmake #934

wants to merge 41 commits into from

Conversation

Iximiel
Copy link
Member

@Iximiel Iximiel commented May 10, 2023

Description

I set up the CMake build generator: it mimic the build process that calls make install-build in the src/lib directory, but not yet the install procedure of the original autoconf.
It seems compiles plumed, plumed-static and plumed-runtime correctly, but I need to see if it works in a mac environment
It can survive in parallel with autoconf and, for user like me used to vscode, may also be useful for some QoL integration with some IDEs.
This branch still need some love:

  • Tests
  • CI and CI tests
  • implementation of all of the options from autoconf
  • installation procedure
  • I don't know if the copyright statements should also go in the CMakeLists.txt files
    I think it should remain a draft until these are not completed
Target release

I think this should aim to be in the next release, even if it does not touch the actual code

Type of contribution
  • Added a new build procedure
Tests
  • I added a new regtest or modified an existing regtest to validate my changes.
  • I verified that all regtests are passed successfully on GitHub Actions.

@GiovanniBussi
Copy link
Member

GiovanniBussi commented May 10, 2023

@Iximiel great!

I would suggest adding one thing to the todo list, which is possibility to compile plumed using pip. I know that for cmake projects this should be feasible (you can install cmake itself from pip).

Currently, in conda and macports we have two separate packages:

  • conda (or macports) install plumed with the library and executable
  • conda (or macports) install py-plumed with the python wrappers (it then loads at runtime the library)

In pip instead we have:

  • pip install plumed with the python wrappers, and you need to install the library on your own.

It would be nice to have instead something like:

  • pip install py-plumed with the python wrappers
  • pip install plumedlib with the library
  • pip install plumed which depends on both

This would allow people using pip to have a fully working plumed package without the need to separately compile plumed.

Regarding tests, I guess you will have to add a new job in the github action file.

@GiovanniBussi GiovanniBussi added the wip Do not merge label May 10, 2023
@codecov-commenter
Copy link

codecov-commenter commented May 10, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.06 🎉

Comparison is base (aadcb7e) 85.73% compared to head (1cea136) 85.79%.

❗ Current head 1cea136 differs from pull request most recent head 56ea9e9. Consider uploading reports for the commit 56ea9e9 to get more accurate results

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #934      +/-   ##
==========================================
+ Coverage   85.73%   85.79%   +0.06%     
==========================================
  Files         600      600              
  Lines       53472    54727    +1255     
==========================================
+ Hits        45843    46953    +1110     
- Misses       7629     7774     +145     
Impacted Files Coverage Δ
src/crystallization/EnvironmentSimilarity.cpp 94.06% <ø> (+0.02%) ⬆️
src/drr/DRR.h 100.00% <ø> (ø)
src/tools/Communicator.h 89.47% <ø> (ø)
src/tools/SwitchingFunction.cpp 95.95% <ø> (+0.14%) ⬆️
src/ves/TD_Multicanonical.cpp 96.53% <ø> (+0.10%) ⬆️
src/ves/TD_Uniform.cpp 98.11% <ø> (+0.11%) ⬆️
src/bias/MetaD.cpp 87.95% <100.00%> (+0.39%) ⬆️
src/drr/DRR.cpp 93.33% <100.00%> (+0.81%) ⬆️
src/drr/DynamicReferenceRestraining.cpp 90.55% <100.00%> (+0.29%) ⬆️
src/drr/drrtool.cpp 93.44% <100.00%> (-1.87%) ⬇️
... and 5 more

... and 260 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -0,0 +1,36 @@
#automatically generated CMakeLists.txt, may not work!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Iximiel are these file lists automatically generated? If so, is it possible not to include them in the repository?

Ideally, the build system will just use all the files in that directory. Can cmake do this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the base file is "automatically generated" by a homemade sh script (that I'm in doubt of including or not in the repository), but the ADDMODULEDEPENDENCIES macro arguments are them manually changed.
This because I wanted to reduce the "dependencies entanglement" and some circular dependency tree that exist if we use the list of dependencies in the "USE=" from the original Makefile (like core and tools).
I forgot to remove the lines "#automatically generated CMakeLists.txt, may not work!".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Iximiel these changes are only for readability right?

Please notice that these files are automatically generated
(see blas/import.sh and lapack/import.sh) from a gromacs repository. We did it some time ago, so you may need an older gromacs version (just do cd src/blas ; git log .).

Ideally, you could add these comments in the import.sh script, for consistency.

Another thing that I find very useful is to add comments with matching braces (see e.g. wrapper/Plumedh) because vim (yes :-)) can jump from one to the other.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these changes in the source files are for readability.
I'm thinking that I should remove them, since they are "off topic" for this PR, and then add them in another PR with the import.sh updated as well

Another thing that I find very useful is to add comments with matching braces (see e.g. wrapper/Plumedh) because vim (yes :-)) can jump from one to the other.

You mean #endif /*__PLUMED_blas_def_internal_h */ instead of #endif //__PLUMED_blas_def_internal_h?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean
#ifdef SOMETHING // {

#endif // }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean in addition to your comment

@GiovanniBussi
Copy link
Member

GiovanniBussi commented May 10, 2023 via email

@Iximiel
Copy link
Member Author

Iximiel commented May 10, 2023

If we keep this in the repository it will go out of sync very soon. Doesn’t cmake allow to use wildcards?

yes, we can use wildcard for getting the sources, but (source):

Note : We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the generated build system cannot know when to ask CMake to regenerate. The CONFIGURE_DEPENDS flag may not work reliably on all generators, or if a new generator is added in the future that cannot support it, projects using it will be stuck. Even if CONFIGURE_DEPENDS works reliably, there is still a cost to perform the check on every rebuild.

@GiovanniBussi
Copy link
Member

How much is the additional cost to do the check at every rebuild? Would it be possible to make automatically?

Ideally, automatically when doing "make" (as it is now). Alternatively when configuring with "cmake"

@Iximiel
Copy link
Member Author

Iximiel commented May 10, 2023

If you change a source file, the cost is the very like the same of automake, It needs to update the object and eventually relink it to it's archive or library.
If you change the cmakelist, if you are working on an IDE you'll have the makefiles regenerated and ready to build as soon you save the cmakelist, without the initial configuration, if you are working by hand you can call cmake --build . in the builld directory and if necessary will configure and generate the files to pass to make, and then call make to build the project

@GiovanniBussi
Copy link
Member

I see. Then can we perhaps have empty lists in the files stored on GitHub? If I understand correctly, the build system will then generate them when the users build.

Sorry for being picky on this but I think it's a bad idea to store files that should be generated automatically. We have an exception (./configure) because generating it from the source (./configure.ac) requires the user to install autoconf. By storing ./configure the user does not need to install anything (this is possibly the unique advantage of autoconf wrt cmake).

However, to make sure that ./configure and ./configure.ac are in sync, we have a specific test. And consider that ./configure.ac changes much more rarely than the number of times we add new .cpp files.

So, if you have to include those lists, I think somewhere on GitHub actions you have to check if they are consistent with the included file. And we will have to pay the price that whenever we add a new file we have to add it to the list or we receive an error.

Still I think that the best solution is not to include those lists.

If you change a source file, the cost is the very like the same of automake, It needs to update the object and eventually relink it to it's archive or library. If you change the cmakelist, if you are working on an IDE you'll have the makefiles regenerated and ready to build as soon you save the cmakelist, without the initial configuration, if you are working by hand you can call cmake --build . in the builld directory and if necessary will configure and generate the files to pass to make, and then call make to build the project

@Iximiel
Copy link
Member Author

Iximiel commented May 11, 2023

I see the point, having the list explicitly stored means you have to keep track of it and update the list in the right file each time you add one or more files.
In my opinion if you explicitly list the object in the Makefile or the sources in the CMakeLists.txt you have more control on you code.

We can add a consistency check for the various CMakeLists.txt in the main Makefile.

Just to be clear: the CMakeLists.txt are not created by the cmake generation process, they are created by a script, and the header "#automatically generated CMakeLists.txt, may not work!" is a reminder set by me, for the developer that has set up the make module and want to add it as a cmake module.
I'm adding that script in the maketools directory, or in a more appropriate directory

@Iximiel Iximiel mentioned this pull request May 12, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wip Do not merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants