lcm-proj / lcm

Lightweight Communications and Marshalling
GNU Lesser General Public License v2.1
944 stars 385 forks source link

Pass NAME_MISMATCHED to avoid warning #391

Closed ihilt closed 1 year ago

ihilt commented 1 year ago

It appears that all that is needed here is to pass NAME_MISMATCHED to avoid the following warning when running cmake. Took this path since the docs indicate this is the intended way to handle mismatched names for packages. They do note that this is usually a mistake but since LCM has been working this way for quite a while I tend to think this is an exception.

CMake Warning (dev) at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (GLib2_glib)
  does not match the name of the calling package (GLib2).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/FindGLib2.cmake:47 (find_package_handle_standard_args)
  cmake/FindGLib2.cmake:74 (_glib2_add_target)
  CMakeLists.txt:10 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.
judfs commented 1 year ago

I cannot build with this change.

$  mkdir build && cd build && cmake ..
...
-- Detecting CXX compile features - done
-- NAME_MISMATCHED (missing: FOUND_VAR GLib2_glib_FOUND REQUIRED_VARS) 
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find GLib2 (missing: glib)
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  cmake/FindGLib2.cmake:119 (find_package_handle_standard_args)
  CMakeLists.txt:10 (find_package)
$ cmake --version
cmake version 3.16.3

$ hostnamectl
  ...
  Operating System: Ubuntu 20.04.5 LTS
  Kernel: Linux 5.14.0-1058-oem
nosracd commented 1 year ago

@judfs Thanks for reporting this issue. I see that this PR has increased the minimum required cmake version from 3.1 to 3.17 and that the apt packages for 20.04 only provide 3.16. I'd rather not require focal users to install cmake via pip without further discussion, so I've reverted this change for now via 0066e9928114d05c784ee2ad439805bdcbea7742.