mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
Now it properly fails if libmagic is not installed in the system.
The error message would look like:
```
CMake Error at cmake/modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Magic (missing: LIBMAGIC_LIBRARY LIBMAGIC_INCLUDE_DIR)
(Required is at least version "5.39")
Call Stack (most recent call first):
cmake/modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
cmake/modules/FindMagic.cmake:5 (find_package_handle_standard_args)
cmake/build_helpers.cmake:971 (find_package)
CMakeLists.txt:81 (addBundledLibraries)
```
### Problem description
The current `FindMagic.cmake` module doesn't properly report failure
about absent libmagic libs and #includes. This behavior leads to the
compile errors on the build stage (possibly after some time, which will
be simply wasted). This Find module should set the `Magic_FOUND`
variable and handle all required variables( LIBMAGIC_INCLUDE_DIR and
LIBMAGIC_LIBRARY) to present.
But the current module sets the `libmagic_FOUND` variable, so the CMake
assumes that it is found something. This behaviour should also be
handled by `find_package_handle_standard_args()` ("FPHSA"), and it is
actually handled, but as we requested the `Magic` package to be
required, the former function ("FPHSA") didn't stop the configure
process.
### Implementation description
- Clean up the unused ifs, as "FPHSA" already done it better.
- Use the proper name for "FPHSA" so it could set the proper
`Magic_FOUND` and could make sure that the requested package is
`REQUIRED`.
### Screenshots
Before:
```
-- Could NOT find libmagic (missing: LIBMAGIC_LIBRARY LIBMAGIC_INCLUDE_DIR)
```
<img width="1005" height="24" alt="изображение"
src="https://github.com/user-attachments/assets/082e2842-ff94-4418-8f86-86021c7dd23d"
/>
After:
```
CMake Error at cmake/modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Magic (missing: LIBMAGIC_LIBRARY LIBMAGIC_INCLUDE_DIR)
(Required is at least version "5.39")
Call Stack (most recent call first):
cmake/modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
cmake/modules/FindMagic.cmake:5 (find_package_handle_standard_args)
cmake/build_helpers.cmake:971 (find_package)
CMakeLists.txt:81 (addBundledLibraries)
```
### Additional things
Closes #2244 .