Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make highway findable by CMake #1084

Closed
kfjahnke opened this issue Dec 15, 2022 · 7 comments
Closed

make highway findable by CMake #1084

kfjahnke opened this issue Dec 15, 2022 · 7 comments

Comments

@kfjahnke
Copy link

I'd like to find highway with my CMake build script, like so:

  find_package(HWY CONFIG REQUIRED)
  if (HWY_FOUND)
    message(STATUS "find_package: HWY_FOUND = true")
  endif()

Are there any plans to add CMake find_package support?

@jan-wassenberg
Copy link
Member

This sounds useful but I don't have experience with it. Are you (or anyone else) able to help add that?

@kfjahnke
Copy link
Author

I haven't done this, only used it. But the mechanism (especially with the CONFIG flavour) is very powerful and convenient for users. It requires the package's installation routine to put a Find.cmake file into the relevant folder (on my ubuntu 22.10 system, the path is /usr/share/cmake-3.24/Modules), so in your case that would be FindHwy.cmake. There, you specify a set of CMake variables which the user's CMakeLists.txt should receive if your package is installed on the user's machine. The relevant docu is here. Sorry I can't be more helpful at the moment.

@jan-wassenberg
Copy link
Member

I understand. This would indeed be nice to have. I'm also snowed under at the moment, literally and figuratively, and unable to get to this at the moment. But would welcome a patch if anyone is able to help.

@jan-wassenberg
Copy link
Member

@kfjahnke I just realized that someone has already written such a thing: https://github.com/cloudinary/ssimulacra2/blob/main/src/cmake/FindHWY.cmake

Is that what you're looking for? If so, we can contact them and see about importing their code.

@kfjahnke
Copy link
Author

Well found! That's precisely what I was looking for. I copied it here to my CMake module path and it worked as intended, finding an installed hwy package on my linux machine. Please ask the authors about importing the code to highway!

@jan-wassenberg
Copy link
Member

Thanks for confirming it works, glad to hear. Will do :)

copybara-service bot pushed a commit that referenced this issue Dec 19, 2022
copybara-service bot pushed a commit that referenced this issue Dec 19, 2022
copybara-service bot pushed a commit that referenced this issue Dec 19, 2022
copybara-service bot pushed a commit that referenced this issue Dec 20, 2022
copybara-service bot pushed a commit that referenced this issue Dec 20, 2022
@kfjahnke
Copy link
Author

Hang on a sec...
Previously, as a package user, you had to write (or copy) a Find script which would find a package for you, and this would then be part of your body of code - just like the Find script you took over from the jpeg xl body of code. This was error-prone and cumbersome, and oftentimes you'd end up copying code from somewhere else to do the job, but this was usually code from some other project which had written the Find script to suit their needs, and you had to go and ask for permission unless it was liberally licensed. So I could now take FindHWY.cmake into my body of code to help lux builders to locate highway. The new way is to provide the script upstream, which also allows upstream to tailor-make the script to provide precisely what it deems necessary. When provided by upstream, the Find... file has to be deployed to one of several 'usual suspect' folders, which your installation routine doesn't do (just providing the file in the repo has no effect per se, even though it removes the need to find it somewhere else). One further step up is providing code which will run in CONFIG mode, which extends the capabilites - the FindHWY.cmake script does not function with CONFIG mode. I googled a bit and found a tutorial here:
https://www.foonathan.net/2016/03/cmake-install/
I include a patch to your CMakeLists.txt which I think does what this tutorial proposes and installs the relevant content in the right places, avoiding FindHWY.cmake altogether:
add_cmake_find_file_installation.txt
This is made with git diff (sorry, the issue tracker accepts neither .diff nor .patch as extension), check it out - it's probably best to discuss that with the CMake guru in your project, I've just made it so it will work but it may be suboptimal. With highway installed like this, I can now find it both in MODULE and CONFIG mode. If you want to stick with FindHWY.cmake, add code to deploy it to where CMake modules go on the target machine, here on my system that's /usr/share/cmake-3.24/Modules, but this would depend on the installation. Hope that helps ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants