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

Generated cc files are deleted on cmake --target clear #396

Closed
DraTeots opened this issue Mar 22, 2023 · 2 comments · Fixed by #397
Closed

Generated cc files are deleted on cmake --target clear #396

DraTeots opened this issue Mar 22, 2023 · 2 comments · Fixed by #397

Comments

@DraTeots
Copy link
Contributor

DraTeots commented Mar 22, 2023

TL;DR; Clean removes all .cc files but leaves everything else

  • OS version: e.g. Debian Mint (Ubuntu) 22.04
  • Compiler version: gcc 11.3, cmake version 3.26.0
  • PODIO version: master at c7328d6
  • Reproduced by:
# on project that generates podio model: 

cmake -B build ./                   # configure
cmake --build build --target all    # build 
cmake --build build --target clean  # clean 
cmake --build build --target all    # <= will never build again
  • Goal:

On configuration stage cmake generates files for data model:

  • datamodel/(headers)
  • src/(.cc)
  • podio_generated_files.cmake

When one runs

cmake --target clean

Clean removes all .cc files but leaves all other generated files.

What is anticipated:

Since file generation is done only on the first configuration stage I would prefer that clean would not touch any of generated files. In my development workflow which I believe to be common, in terms of build steps I do something like this:

# 
configure
build
build
clean   # <= the code will not compile after this, as files are removed and new `configure` is needed 
build
clean
build
...

Also IDE-s usually have an option like "Rebuild project" which is "clean+build" for projects with podio data model that will always fail.

P.S. even if you would not agree on anticipated clean behavior, there is an issue that some generated files are deleted but others - are not

@jmcarcell
Copy link
Member

What you are asking for is not trivial to do, see https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#cmake-does-not-generate-a-make-distclean-target-why
Do you need to clean? I actually believe your workflow to be uncommon; you can develop and then only the parts that have changed will be compiled / regenerated if needed, so where is the need for cleaning? The same applies for IDEs, or am I missing something? (I don't think I have needed to clean unless you do something like changing from a non-SIO to a SIO build but even then everything still compiles)

@tmadlener
Copy link
Collaborator

I tend to agree that clean should rarely (never?) be necessary. One of the reasons we generate an additional podio_generated_files.cmake is to make sure that cmake only "sees" the files that have actually been generated for the datamodel library, "ignoring" other files that might be present in the directories. However if some IDEs run it as part of a "Rebuild" then we might have to accommodate for that. However, for me simply using build has not failed in quite some time, even with switching branches and build options quite frequently.

Clean removes all .cc files but leaves all other generated files.

That sounds like a small bug regardless of the rest. In principle all generated files should be removed via the clean target, because we explicitly generate the following well into podio_generated_files.cmake

SET_PROPERTIES(SOURCE ${headers} PROPERTY GENERATED TRUE)

I am not entirely sure why this is working for the .cc files but not the headers (or the src/selection.xml that we also generate). Especially since the GENERATED property should be visible globally with CMake > 3.20. I tested the clean target with make as the build tool and that seems to simply ignore the GENERATED property entirely and not remove any files at all, while ninja at least removes the .cc files.

Taking all this into account I think we could remove the GENERATED property from our generated files, which would keep them from being removed by clean.

tmadlener added a commit to tmadlener/podio that referenced this issue Mar 23, 2023
Keep them in place even if the clean target is specified. See AIDASoft#396
tmadlener added a commit that referenced this issue Apr 3, 2023
Keep them in place even if the clean target is specified. See #396
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants