Skip to content

Do not elide find_package() if MONGO_USE_CCACHE is set #1031

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

Merged
merged 2 commits into from
Jun 7, 2022

Conversation

eramongodb
Copy link
Contributor

@eramongodb eramongodb commented Jun 7, 2022

Description

Fix overzealous elison of call to find_package() find_program() introduced in #1029 when MONGO_USE_CCACHE is set. CCACHE_EXECUTABLE still needs to be found and set when MONGO_USE_CCACHE is manually set by the user on initial configuration, not just post-configuration.

Copy link
Contributor

@vector-of-bool vector-of-bool left a comment

Choose a reason for hiding this comment

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

I discovered one other quirk of note. Also, I'm guessing you probably meant "find_program()" in the commit/PR message 🙂.

message (STATUS "Compiling with CCache enabled. Disable by setting MONGO_USE_CCACHE to OFF")
option (MONGO_USE_CCACHE "Use CCache when compiling" ON)
endif ()
endif (CCACHE_EXECUTABLE AND NOT DEFINED MONGO_USE_CCACHE)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason you're repeating the condition in the endif() call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to not lose track of the corresponding if () given the size of the block, a la #endif // COND or } // namespace <name>. I can remove if you think it is undesirable/unnecessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

It only tends to be a code smell as it is a very very old pattern that is disrecommended anymore in favor of just using prose-like comments for the purpose, but I don't feel strongly about it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer endif (<cond>) over endif () # cond since CMake actually detects and enforces <cond> matches, which is a maintainability bonus imo as it prevents (or at least tries to prevent) the possibility of prose-like comments becoming outdated/detached from the matching if ().

CMake Warning (dev) in example/CMakeLists.txt:
  A logical block opening on the line
    CMakeLists.txt:10 (if)
  closes on the line
    CMakeLists.txt:12 (endif)
  with mis-matching arguments.

Admittedly it gets confusing if there are any elseif() / else () blocks involved, so I avoid using it in such cases, but I still prefer using them if it's simple (but large) if() / endif() blocks. I may reconsider this stance after further thought. 🤔

@eramongodb eramongodb merged commit 237bcf8 into mongodb:master Jun 7, 2022
@eramongodb eramongodb deleted the ccache-bugfix branch June 7, 2022 22:02
@eramongodb
Copy link
Contributor Author

I'm guessing you probably meant "find_program()" in the commit/PR message

Fixed it in the commit message in the description, but not in the commit message header itself. 🤦

kevinAlbs added a commit that referenced this pull request Aug 31, 2022
kevinAlbs added a commit that referenced this pull request Aug 31, 2022
* Revert "Do not elide find_package() if MONGO_USE_CCACHE is set (#1031)"

This reverts commit 237bcf8.

* Revert "Disable ccache by default for versions older than 3.4.3 (#1029)"

This reverts commit f55cc6a.
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 this pull request may close these issues.

2 participants