mariusbancila / stduuid

A C++17 cross-platform implementation for UUIDs
MIT License
742 stars 112 forks source link

{cmake} FindLibuuid vs FindLibUUID #77

Open asmaloney opened 1 year ago

asmaloney commented 1 year ago

I'm replacing an older UUID lib with stduuid.

The old one used FindLibUUID in its cmake files and it worked fine on Debian with cmake and uuid-dev installed (GitLab CI).

When I switched my stuff to stduuid, it is using FindLibuuid (lowercase uuid) and now my CI fails:

CMake Error at lib/extern/stduuid/CMakeLists.txt:32 (find_package):
  By not providing "FindLibuuid.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Libuuid", but
  CMake did not find one.

  Could not find a package configuration file provided by "Libuuid" with any
  of the following names:

    LibuuidConfig.cmake
    libuuid-config.cmake

  Add the installation prefix of "Libuuid" to CMAKE_PREFIX_PATH or set
  "Libuuid_DIR" to a directory containing one of the above files.  If
  "Libuuid" provides a separate development package or SDK, be sure it has
  been installed.

Looking at CMake, they include FindLibUUID as a module which is what I assume was being found before.

Is there another package I need to install on Debian to get FindLibuuid to work?

asmaloney commented 1 year ago

As a workaround I copied the FindLibUUID.cmake from CMake, changed the case to FindLibuuid (including vars), included it in my repo, and added it to CMAKE_MODULE_PATH.

Not ideal, but it works.

If anyone know the "right" way to find/include FindLibuuid, please let me know!

zzxzzk115 commented 1 year ago

I found a solution:

sudo apt-get install uuid-dev

Then you can simply link the library by name uuid and the include path is usr/include/uuid/.

mickeyze commented 1 year ago

Then you can simply link the library by name uuid and the include path is usr/include/uuid/.

Can you please provide the code snippet? Thanks

asmaloney commented 1 year ago

Then you can simply link the library by name uuid and the include path is usr/include/uuid/.

This isn't actually fixing the problem - it's just removing FindLibuuid and hardcoding paths.

zzxzzk115 commented 1 year ago

Then you can simply link the library by name uuid and the include path is usr/include/uuid/.

This isn't actually fixing the problem - it's just removing FindLibuuid and hardcoding paths.

Well, I totally agree. It's not a proper solution. Maybe I should detect which Linux distribution it runs on.

frank2 commented 1 year ago

The solution I found to fix this problem is adding the following line before including stduuid in CMake:

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/lib/stduuid/cmake")

After adding this line, stduuid was able to find the library just fine. I suspect Config.cmake.in isn't being executed in some configurations of using this library with CMake.

frank2 commented 1 year ago

Am running into this issue with Debian too, FWIW. I'm not too familiar with the inner-workings of this project so I would feel uncomfortable submitting a PR for the CMake fix, but I believe just adding the modules to the module path will make FindLibuuid.cmake execute again.

asmaloney commented 1 year ago

Thanks @frank2. That works. The included FindLibuuid.cmake seems a lot less robust than the one included with CMake. It does mean one less file to include in my lib though. 🤷