bombela / backward-cpp

A beautiful stack trace pretty printer for C++
MIT License
3.73k stars 471 forks source link

Fix NAME_MISMATCHED arg error on CMake>=3.17 #213

Closed christophebedard closed 3 years ago

christophebedard commented 3 years ago

On CMake 3.20.1, I was getting this error:

CMake Error at /opt/homebrew/Cellar/cmake/3.20.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:393 (message):
  The `NAME_MISMATCHED` argument may only be specified by the argument or the
  variable, not both.
Call Stack (most recent call first):
  ...  bombela/backward-cpp/BackwardConfig.cmake:94 (find_package_handle_standard_args)

This was introduced by #207.

I wasn't really sure what the error message meant, and there isn't much here: https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html. However, after trying various things I found some examples which put the NAME_MISMATCHED after the first argument (as opposed to the end): https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4123/diffs#198c8eb075549bab1c1c175ee891f4e076a29f2f_1648_1647.

This fixes the issue on macOS with CMake 3.20.1. I've also tested it on Ubuntu with CMake 3.16.3 (so <3.17) and it works fine of course.

Not sure why it was working for the author of #207 though. Maybe they were using CMake<3.17 and their issue was actually fixed by switching from DEFAULT_MSG to REQUIRED_VARS?