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

set the path for ffi headers (cmake build) #2970

Closed
wants to merge 8 commits into from

Conversation

dimpase
Copy link
Contributor

@dimpase dimpase commented Oct 20, 2023

Fixes #2965

Split off from #2968 (see it for the discussion)

Includes the commit from #2968

use pkg_ macro for FFI detection, add include path

Instead of calling pkg-config directly,
and then ignore most of what can be obtained from pkg-config,
we use pkg_check_modules cmake macro.

We also add the include path for ffi.h to compile flags
@dimpase
Copy link
Contributor Author

dimpase commented Oct 20, 2023

@mahrud @d-torrance

@dimpase dimpase changed the title set the path for ffi headers set the path for ffi headers (cmake build) Oct 20, 2023
@@ -1,3 +1,6 @@
################### This file is made obsolete by the PR 2968 #######################
# This is public domain code
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure this is true? My guess is that it has an Apache license since it's included in the LLVM source (see https://github.com/llvm/llvm-project/blob/main/llvm/cmake/modules/FindFFI.cmake)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not %100 sure, no. It's good to dig it up

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot where I saw this, but CMake FindModules are always under the lightest license (after all, it's barely code ... and who would want to copyright code for findin something open source)

@dimpase
Copy link
Contributor Author

dimpase commented Oct 20, 2023

OK, so here is a minimal change, just one line (calling pkg_get_variable - I suppose this macro has no side effects/hidden variables)

@mahrud
Copy link
Member

mahrud commented Oct 21, 2023

Sure. I think using it as a backup (as long as it doesn't give an error if pkg-config doesn't find ffi) makes a lot of sense.

Two requests:

  1. There seem to be too many unrelated commits, including a revert commit. Could you prune those?
  2. Could yo also rewrite the execute_process line using pkg_get_variable, so we don't call pkg-config every time cmake runs?

@dimpase
Copy link
Contributor Author

dimpase commented Oct 21, 2023

  1. I can squash, or whoever does the PR merging can use GitHub's option to squash PR into one commit.

  2. no, unfortunately pkg-config deals with versions without variables, so this pkg_ command won't work here.

@dimpase
Copy link
Contributor Author

dimpase commented Oct 21, 2023

  1. no, unfortunately pkg-config deals with versions without variables, so this pkg_ command won't work here.

OTOH it's possible to condition calling pkg-config on the value of a CACHE variable, so that
it's only called once.

@dimpase
Copy link
Contributor Author

dimpase commented Oct 22, 2023

OK, so this appears to work.
After the 1st run of cmake I see

$ grep LIBFFI CMakeCache.txt 
LIBFFI_VERSION:STRING=3.4.4

And if I manually edit CMakeCache.txt to change it so that, say,

LIBFFI_VERSION:STRING=3.4.42

then this value does not get overwritten on the subsequent run of cmake.

execute_process(COMMAND pkg-config --modversion libffi
OUTPUT_VARIABLE LIBFFI_VERSION_ OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LIBFFI_VERSION ${LIBFFI_VERSION_} CACHE STRING "FFI version")
endif()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be much cleaner if this code block was inside FindFFI.cmake. FindModules are usually supposed to set the version variable anyway, so this would be an improvement to the current one.

@mahrud
Copy link
Member

mahrud commented Oct 23, 2023

Give #2974 a try. If it solves your problem, I think this can be closed.

@mahrud
Copy link
Member

mahrud commented Oct 25, 2023

#2974 passes all tests now.

@DanGrayson DanGrayson closed this Oct 26, 2023
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 this pull request may close these issues.

4 participants