cmake: fix MATH_LIBRARY check on Windows MSVC#22564
Open
ServeurpersoCom wants to merge 1 commit into
Open
Conversation
Contributor
|
I had a similar error but it went away with a clean tree. |
Contributor
Author
You're right, if I delete the build folder it goes through, but doesn't the bug remain latent as soon as find_library(MATH_LIBRARY m) is called elsewhere in the configure step (downstream project, upstream submodule, or even a simple re-configure reloading the cache), since DEFINED still evaluates to TRUE with the value MATH_LIBRARY-NOTFOUND and breaks the link, whereas if (MATH_LIBRARY) correctly evaluates *-NOTFOUND as falsy per CMake's if() contract ? |
Member
|
We don’t want to call |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
cmake : fix MATH_LIBRARY check on Windows MSVC
find_library(MATH_LIBRARY m) returns MATH_LIBRARY-NOTFOUND on MSVC, but if (DEFINED MATH_LIBRARY) is still TRUE, leading to target_link_libraries(... PRIVATE MATH_LIBRARY-NOTFOUND) and a 'cannot open m.lib' link error. Use idiomatic if (MATH_LIBRARY) which evaluates *-NOTFOUND as false.
This restores the truthy check that was in place before #22355; DEFINED is too permissive when MATH_LIBRARY is set elsewhere as *-NOTFOUND by an unrelated find_library() call earlier in configure.
Discovered while rebasing two GGML downstream projects
Refs #9908 (original old issue with the same Windows MSVC symptom)
Additional information
Requirements